Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
304 ashish 1
'''
2
Created on 28-Jun-2010
3
 
4
@author: ashish
5
'''
6
from shop2020.config.client.ConfigClient import ConfigClient
7
from shop2020.utils.Utils import log_entry
8
from shop2020.thriftpy.datalogger import DataLogger
9
from thrift.protocol.TBinaryProtocol import TBinaryProtocol
10
from thrift.transport.TTransport import TFramedTransport
11
from thrift.transport.TSocket import TSocket
12
 
13
 
14
class DataLoggingClient:
15
 
16
    host = "localhost"
17
    port = "9007"
18
 
19
    def __init__(self):
20
        try:
21
            self.config_client = ConfigClient()
22
            self.host = self.config_client.get_property("datalogging_service_local_hostname")
23
            self.port = self.config_client.get_property("datalogging_service_local_wrapper_port")
24
            self.__start__()
25
        except:
26
            log_entry("DataLoggingClient","error getting data from config")
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 = DataLogger.Client(self.protocol)
33
        self.transport.open()
34
 
35
    def get_client(self):
36
        return self.client