Rev 2926 | Blame | Compare with Previous | Last modification | View Log | RSS feed
'''Created on 25-Mar-2010@author: ashish'''from shop2020.thriftpy.config.ttypes import ConfigExceptionfrom thrift.transport import TSocketfrom thrift.transport.TTransport import TFramedTransportfrom thrift.protocol.TBinaryProtocol import TBinaryProtocolfrom shop2020.thriftpy.config import Configurationclass ConfigClient:def __init__(self, host='localhost', port=9999):self.host = hostself.port = portself.start_client()def start_client(self):try:self.transport = TSocket.TSocket(self.host, self.port)self.transport = TFramedTransport(self.transport)self.protocol = TBinaryProtocol(self.transport)self.client = Configuration.Client(self.protocol)self.transport.open()except:raise ConfigException(101, 'unable to load the client')def get_property(self, key):return self.client.getPropetry(key)def set_property(self, key, value):return self.client.loadProperty(key, value)def reloadProperties(self):return self.client.reloadProperties()if __name__ == '__main__':#test config clienttry:config_client = ConfigClient()print config_client.get_property("export_entities_path")config_client.set_property('export_entities_path', 'abc')print config_client.get_property("export_entities_path")config_client.reloadProperties()print config_client.get_property('export_entities_path')except:print "error while putting up config client"