Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

'''
Created on 21-Jul-2010

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

from shop2020.thriftpy.model.v1.widgets import WidgetService

class WidgetClient:
    
    host = "localhost"
    port = "9010"
    
    def __init__(self):
        try:
            self.config_client = ConfigClient()
            self.host = self.config_client.get_property("widget_service_hostname")
            self.port = self.config_client.get_property("widget_service_port")
            
        except:
            log_entry("error getting data from config")
        
    def __start__(self):
        self.transport = TSocket.TSocket(self.host, self.port)
        self.transport = TFramedTransport(self.transport)
        self.protocol = TBinaryProtocol(self.transport)    
        self.client = WidgetService.Client(self.protocol)
        self.transport.open()
        
    def get_client(self):
        return self.client