示例#1
0
文件: proxy.py 项目: timovwb/jsonrpc
    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()
示例#2
0
文件: proxy.py 项目: zanachka/jsonrpc
    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()
示例#3
0
文件: proxy.py 项目: zanachka/jsonrpc
    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
示例#4
0
	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