Subversion Repositories SmartDukaan

Rev

Rev 304 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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