Subversion Repositories SmartDukaan

Rev

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

'''
Created on 05-Jan-2010

@author: rajveer
'''
from shop2020.config.client.ConfigClient import ConfigClient
from shop2020.utils.Utils import log_entry
from thrift.transport.TSocket import TSocket
from thrift.transport.TTransport import TFramedTransport
from thrift.protocol.TBinaryProtocol import TBinaryProtocol
from shop2020.thriftpy.utils import HelperService

class HelperClient:
    
    
    
    def __init__(self):
        try:
            self.config_client = ConfigClient()
            self.host = self.config_client.get_property("helper_service_server_host")
            self.port = self.config_client.get_property("helper_service_server_port")
        except:
            self.host = "localhost"
            self.port = "9008"
            log_entry(self, "error getting data from config")
        self.__start__()
        
    def __start__(self):
        self.transport = TSocket(self.host, self.port)
        self.transport = TFramedTransport(self.transport)
        self.protocol = TBinaryProtocol(self.transport)    
        self.client = HelperService.Client(self.protocol)
        self.transport.open()
        
    def get_client(self):
        return self.client