Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
2821 chandransh 1
'''
2
Created on 01-Aug-2011
3
 
4
@author: Chandranshu
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.warehouse import WarehouseService
12
 
13
class WarehouseClient:
14
    def __init__(self):
15
        try:
16
            self.config_client = ConfigClient()
17
            self.host = self.config_client.get_property("warehouse_service_server_host")
18
            self.port = self.config_client.get_property("warehouse_service_server_port")
19
        except:
20
            #log_entry("error getting data from config")
21
            self.host = "localhost"
22
            self.port = "9013"
23
        self.__start__()
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 = WarehouseService.Client(self.protocol)
30
        self.transport.open()
31
 
32
    def get_client(self):
33
        return self.client