Subversion Repositories SmartDukaan

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
155 ashish 1
'''
2
Created on 17-May-2010
3
 
4
@author: ashish
5
'''
6
from shop2020.config.client.ConfigClient import ConfigClient
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.model.v1.catalog import InventoryService
12
 
574 chandransh 13
class InventoryClient:    
155 ashish 14
    def __init__(self):
15
        try:
16
            self.config_client = ConfigClient()
17
            self.host = self.config_client.get_property("catalog_service_server_host")
384 ashish 18
            self.port = self.config_client.get_property("catalog_service_server_port")
155 ashish 19
        except:
20
            log_entry("error getting data from config")
574 chandransh 21
            self.host = "localhost"
22
            self.port = "9001"
23
        self.__start__()
155 ashish 24
 
25
    def __start__(self):
26
        self.transport = TSocket.TSocket(self.host, self.port)
27
        self.transport = TFramedTransport(self.transport)
28
        self.protocol = TBinaryProtocol(self.transport)    
29
        self.client = InventoryService.Client(self.protocol)
30
        self.transport.open()
31
 
32
    def get_client(self):
33
        return self.client
34
 
35