Subversion Repositories SmartDukaan

Rev

Rev 3006 | Rev 3124 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
581 rajveer 1
'''
2
Created on 05-Jan-2010
3
 
4
@author: rajveer
5
'''
6
from shop2020.config.client.ConfigClient import ConfigClient
7
from shop2020.utils.Utils import log_entry
8
from thrift.transport.TSocket import TSocket
9
from thrift.transport.TTransport import TFramedTransport
10
from thrift.protocol.TBinaryProtocol import TBinaryProtocol
11
from shop2020.thriftpy.utils import HelperService
12
 
13
class HelperClient:
14
 
15
 
3007 chandransh 16
 
581 rajveer 17
    def __init__(self):
18
        try:
19
            self.config_client = ConfigClient()
20
            self.host = self.config_client.get_property("helper_service_server_host")
21
            self.port = self.config_client.get_property("helper_service_server_port")
22
        except:
3007 chandransh 23
            self.host = "localhost"
24
            self.port = "9008"
581 rajveer 25
            log_entry(self, "error getting data from config")
3006 chandransh 26
        self.__start__()
581 rajveer 27
 
28
    def __start__(self):
29
        self.transport = TSocket(self.host, self.port)
30
        self.transport = TFramedTransport(self.transport)
31
        self.protocol = TBinaryProtocol(self.transport)    
32
        self.client = HelperService.Client(self.protocol)
33
        self.transport.open()
34
 
35
    def get_client(self):
36
        return self.client