def __call__(self, *args, **kwargs): url = self._get_url() postdata = self._get_postdata(args, kwargs) #respdata = urllib2.urlopen(url, postdata).read() respdata = self._post(url, postdata).read() resp = Response.from_dict(jsonrpc.jsonutil.decode(respdata)) resp = self._eventhandler.proc_response(resp) return resp.get_result()
def batch_call(self, methods): '''call several methods at once, return a list of (result, error) pairs :param names: a dictionary { method: (args, kwargs) } :returns: a list of pairs (result, error) where only one is not None ''' result = None if hasattr(methods, 'items'): methods = methods.items() data = [getattr(self, k)._get_postdata(*v) for k, v in methods] postdata = '{0}'.format(','.join(data)) respdata = self._post(self._get_url(), postdata).read() resp = Response.from_json(respdata) try: result = resp.get_result() except AttributeError: result = [res.get_output() for res in resp] return result
def batch_call(self, methods): '''call several methods at once, return a list of (result, error) pairs :param names: a dictionary { method: (args, kwargs) } :returns: a list of pairs (result, error) where only one is not None ''' result = None if hasattr(methods, 'items'): methods = methods.items() data = [ getattr(self, k)._get_postdata(*v) for k, v in methods ] postdata = '[%s]' % ','.join(data) respdata = self._post(self._get_url(), postdata).read() resp = Response.from_json(respdata) try: result = resp.get_result() except AttributeError: result = [res.get_output() for res in resp] return result