def call(self, method, *args, **kwargs): provider = self.registry.get_random_provider(self.interface, version=self.version, group=self.group) client = HttpClient(url="http://{0}{1}".format(provider.location, provider.path)) try: return client.call(method, *args, **kwargs) except HTTPError, e: raise ConnectionFail(None, e.filename)
def test_client_every_new(): user_provider = HttpClient(url="http://{0}{1}".format('zookeeper:38081/', 'com.ofpay.demo.api.UserProvider2')) print user_provider.getUser('A003') print user_provider.queryUser( {u'age': 18, u'time': 1428463514153, u'sex': u'MAN', u'id': u'A003', u'name': u'zhangsan'}) print user_provider.queryAll() print user_provider.isLimit('MAN', 'Joe') print user_provider('getUser', 'A005')
def call(self, method, *args, **kwargs): provides = self.registry.get_provides(self.interface, version=self.version, group=self.group) if len(provides) == 0: raise NoProvider('can not find provide', self.interface) ip_port, service_url = random.choice(provides.items()) # print service_url.location client = HttpClient(url="http://{0}{1}".format(ip_port, service_url.path)) try: return client.call(method, *args, **kwargs) except HTTPError, e: raise ConnectionFail(None, e.filename)
def call(self, method, *args, **kwargs): provides = self.registry.get_provides(self.interface, version=self.version, group=self.group) if len(provides) == 0: raise NoProvider('can not find provide', self.interface) ip_port, service_url = random.choice(provides.items()) # print service_url.location client = HttpClient( url="http://{0}{1}".format(ip_port, service_url.path)) try: return client.call(method, *args, **kwargs) except HTTPError, e: raise ConnectionFail(None, e.filename)
def print_labels(self, cr, uid, ids, b64_data, data_format="epl2", context=None): if not b64_data: return False for company in self.browse(cr, uid, ids, context=context): api = HttpClient( url=company.printer_proxy_url, username=company.printer_proxy_username, password=company.printer_proxy_password ) api.call("output", printer_name=company.printer_proxy_device_name, data=b64_data, format=data_format) return True
def get_client(): config = get_config() rpcport = int(config.get("rpcport", 8732)) user = config.get("rpcuser") password = config.get("rpcpassword") host = config.get("rpchost", "localhost") return HttpClient(url="http://" + host + ":" + str(rpcport), username=user, password=password)
def test_client(): user_provider = HttpClient(url="http://{0}{1}".format('172.19.3.111:38080/', 'com.ofpay.demo.api.UserProvider')) for x in range(number): user_provider.getUser('A003') user_provider.queryUser( {u'age': 18, u'time': 1428463514153, u'sex': u'MAN', u'id': u'A003', u'name': u'zhangsan'}) # user_provider.queryAll() user_provider.isLimit('MAN', 'Joe') user_provider('getUser', 'A005')
def test_client(): user_provider = HttpClient(url="http://{0}{1}".format( '172.19.3.111:38080/', 'com.ofpay.demo.api.UserProvider')) for x in range(number): user_provider.getUser('A003') user_provider.queryUser({ u'age': 18, u'time': 1428463514153, u'sex': u'MAN', u'id': u'A003', u'name': u'zhangsan' }) # user_provider.queryAll() user_provider.isLimit('MAN', 'Joe') user_provider('getUser', 'A005')
def walletcmd(self, method, *params): return HttpClient(**self.walletcfg).call(method, *params)
def walletcmd(self, wallet, method, *params): return HttpClient(**wallet).call(method, *params)