Subversion Repositories SmartDukaan

Rev

Rev 2747 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2747 Rev 3124
Line 1... Line 1...
1
'''
1
'''
2
Created on 28-Jul-2011
2
Updated on 31-Aug-2011
3
 
3
 
4
@author: Chandranshu
4
@author: rajveer
5
'''
5
'''
6
from shop2020.config.client.ConfigClient import ConfigClient
6
from shop2020.thriftpy.payments.PaymentService import Client
7
from shop2020.utils.Utils import log_entry
-
 
8
from thrift.transport import TSocket
-
 
9
from thrift.transport.TTransport import TFramedTransport
-
 
10
from thrift.protocol.TBinaryProtocol import TBinaryProtocol
-
 
11
from shop2020.thriftpy.payments import PaymentService
7
from shop2020.clients.GenericClient import GenericClient
12
 
8
 
13
 
-
 
14
class PaymentClient:
9
class PaymentClient(GenericClient):
-
 
10
            
15
    def __init__(self):
11
    def __init__(self):
16
        try:
-
 
17
            self.config_client = ConfigClient()
-
 
18
            self.host = self.config_client.get_property("payments_service_server_host")
-
 
19
            self.port = self.config_client.get_property("payments_service_server_port")
12
        GenericClient.__init__(self, "payments_service_server_host", "payments_service_server_port")
20
        except:
-
 
21
            log_entry("error getting data from config")
-
 
22
            self.host = "localhost"
-
 
23
            self.port = "9012"
-
 
24
        self.__start__()
13
        self.__start__()
25
        
14
        
26
    def __start__(self):
15
    def __start__(self):
27
        self.transport = TSocket.TSocket(self.host, self.port)
-
 
28
        self.transport = TFramedTransport(self.transport)
-
 
29
        self.protocol = TBinaryProtocol(self.transport)    
-
 
30
        self.client = PaymentService.Client(self.protocol)
16
        self.client = Client(self.protocol)
31
        self.transport.open()
-
 
32
        
17
        
33
    def get_client(self):
18
    def get_client(self):
34
        return self.client
-
 
35
    
-
 
36
19
        return self.client
-
 
20
37
21