当前位置: 首页>>代码示例>>Python>>正文


Python SimpleXMLRPCDispatcher._dispatch方法代码示例

本文整理汇总了Python中SimpleXMLRPCServer.SimpleXMLRPCDispatcher._dispatch方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleXMLRPCDispatcher._dispatch方法的具体用法?Python SimpleXMLRPCDispatcher._dispatch怎么用?Python SimpleXMLRPCDispatcher._dispatch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimpleXMLRPCServer.SimpleXMLRPCDispatcher的用法示例。


在下文中一共展示了SimpleXMLRPCDispatcher._dispatch方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _dispatch

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import _dispatch [as 别名]
 def _dispatch(self, *args, **kw):
     try:
         result = SimpleXMLRPCDispatcher._dispatch(self, *args, **kw)
         # 	self.logger.debug("Result: %s" % (result, ))
         return result
     except:
         self.logger.exception("Error while processing request")
         raise
开发者ID:tubav,项目名称:OpenTeagle_API,代码行数:10,代码来源:xmlrpc.py

示例2: _dispatch

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import _dispatch [as 别名]
 def _dispatch(self, method, params):
     try:
         return SimpleXMLRPCDispatcher._dispatch(self, method, params)
     except Exception, e:
         message  = "XML-RPC request caused exception:\n"
         message += "Method: %s\n" % (method)
         message += "Parameters: %s" % (str(params))
         self.logger.exception(message)
         raise
开发者ID:NETWAYS,项目名称:ingraph,代码行数:11,代码来源:xmlrpc.py

示例3: _dispatch

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import _dispatch [as 别名]
 def _dispatch(self, method, params):
     """ Custom _dispatch so we can log time used to execute method.
     """
     start = datetime.utcnow()
     try:
         result = SimpleXMLRPCDispatcher._dispatch(self, method, params)
     except:
         logger.debug('Time: %s %s %s', datetime.utcnow() - start, str(method), str(params)[0:50])
         raise
     logger.debug('Time: %s %s %s', datetime.utcnow() - start, str(method), str(params)[0:50])
     return result
开发者ID:sibiaoluo,项目名称:beaker,代码行数:13,代码来源:main.py

示例4: _dispatch

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import _dispatch [as 别名]
 def _dispatch(self, method, params):
     """
     Custom _dispatch so we can log exceptions and the time taken to
     execute each method.
     """
     start = datetime.utcnow()
     try:
         result = SimpleXMLRPCDispatcher._dispatch(self, method, params)
     except:
         logger.exception('Error handling XML-RPC call %s', str(method))
         logger.debug('Time: %s %s %s', datetime.utcnow() - start, str(method), str(params)[0:50])
         raise
     logger.debug('Time: %s %s %s', datetime.utcnow() - start, str(method), str(params)[0:50])
     return result
开发者ID:sujithshankar,项目名称:beaker,代码行数:16,代码来源:main.py

示例5: _dispatch

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import _dispatch [as 别名]
    def _dispatch(self, method, params):
        """Dispatches an RPC call.

        :param method: the name of the function to call
        :type method: string
        :param params: the arguments to pass to method
        :type params: list

        """
        requires_auth = method in self.methods_requiring_authentication
        if requires_auth:
            if not len(params) >= 2:
                raise RPCAuthenticationError('<no_username_given>')
            username, password, params = params[0], params[1], params[2:]
            if (username, password) != (self.username, self.password):
                raise RPCAuthenticationError(username)
        return SimpleXMLRPCDispatcher._dispatch(self, method, params)
开发者ID:camgunz,项目名称:zdstack,代码行数:19,代码来源:RPCServer.py

示例6: ServerGateway

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import _dispatch [as 别名]
class ServerGateway(object):
    def __init__(self, prefix):
        self.prefix = prefix
        try:
            # Python 2.4
            self.dispatcher = SimpleXMLRPCDispatcher()
        except TypeError:
            # Python 2.5
            self.dispatcher = SimpleXMLRPCDispatcher(allow_none=False, encoding=None)

    def add_function(self, name, func):
        self.dispatcher.register_function(func, ".".join([self.prefix, name]))

    def connect( self, func=None, name=None):
        def _connector(func):
            self.add_function(not name and func.__name__ or name, func)
            return func

        if not func:
            return _connector
        else:
            _connector(func)
            return func

    def __call__(self, request, *args, **kwargs):
        if kwargs:
            raise RuntimeError("Xmlrpc server gateway cannot handle key variable argumets")

        def custom_dispatch(method, params):
            return self.dispatcher._dispatch(method, params + tuple(args))

        response = HttpResponse()
        if len(request.POST):
            response.write(self.dispatcher._marshaled_dispatch(request.raw_post_data, custom_dispatch))
        else:
            methods = self.dispatcher.system_listMethods()

            response['Content-Type'] = 'text/plain'
            for method in methods:
                # __doc__
                help = self.dispatcher.system_methodHelp(method)
                response.write("%s:\n    %s\n\n" % (method, help))

        response['Content-Length'] = str(len(response.content))
        return response
开发者ID:pombredanne,项目名称:turbion,代码行数:47,代码来源:xmlrpc.py

示例7: XmlRpc

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import _dispatch [as 别名]
class XmlRpc(object):
    def __init__(self, encoding=None, allow_none=True, use_datetime=0):
        self.__queue = []
        self.__encoding = encoding
        self.__allow_none = allow_none
        self.__use_datetime = use_datetime
        self.__dispatcher = SimpleXMLRPCDispatcher(allow_none=allow_none, encoding=encoding)
        
    def splitfmt(self):
        return "xml"
        
    def initiate_request(self, method, args, kwargs, completion):
        if kwargs: raise NotImplemented("Keyword arguments not supported in XML-RPC mode")
        self.__queue.append(completion)
        return xmlrpc_dumps(args, method, encoding=self.__encoding, allow_none=self.__allow_none)
        
    def handle_response(self, rstr):
        completion = self.__queue.pop(0)
        try:
            response = xmlrpc_loads(rstr, self.__use_datetime)
            completion(response[0][0], None)
        except Fault as f:
            completion(None, f)
    
    def dispatch_request(self, reqstr):
        p,m = xmlrpc_loads(reqstr, self.__use_datetime)
        try:
            rsp = self.__dispatcher._dispatch(m, p)
            response = xmlrpc_dumps((rsp,), allow_none=self.__allow_none, encoding=self.__encoding)
        except Fault as fault:
            response = xmlrpc_dumps(fault, allow_none=self.__allow_none, encoding=self.__encoding)
        except:
            exc_type, exc_value, exc_tb = sys.exc_info()
            response = xmlrpc_dumps(
                Fault(1, "%s:%s" % (exc_type, exc_value)),
                encoding=self.__encoding, allow_none=self.__allow_none)
        return response
        
    def register_function(self, func, name=None):
        self.__dispatcher.register_function(func, name)
        
开发者ID:evolvIQ,项目名称:streamrpc,代码行数:42,代码来源:protocol.py

示例8: _dispatch

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import _dispatch [as 别名]
    def _dispatch(self, method, params):
        """Executes the requested method and measure how long it took

        :param method: method name
        :param params: method parameters
        :return: Returns a tuple: the method result and the measured time, unless it is a sys method,
        doesn't need to measure sys methods
        :raise xmlrpclib.Fault:
        """
        logger.info("CALL {}({})".format(method, ", ".join([repr(p) for p in params])))
        try:
            before = datetime.now()
            if params:
                cavity = None
                first = params[0]
                print type(first), first
                if isinstance(first, str):
                    print self._cavities
                    cavity = self._cavities.get(first, None)
                    print 'cavity is', cavity
                    if cavity is not None:
                        logger.set_tid(cavity)
                        logger.info('hahaha')
            result = SimpleXMLRPCDispatcher._dispatch(self, method, params)
            delta = datetime.now() - before
            delta = unicode('%s.%06d' % (delta.seconds, delta.microseconds))
            if not method.startswith('sys'):
                return result, delta
            else:
                return result
        except Exception:
            exc_type, exc_value, exc_tb = sys.exc_info()
            tb = traceback.format_exc()
            msg = "%s: %s\n%s" % (exc_type, exc_value, tb)
            logger.exception("FAULT {}: {}".format(method, msg))
            raise xmlrpclib.Fault(1, msg)
开发者ID:davidvoler,项目名称:ate_meteor,代码行数:38,代码来源:server.py

示例9: _dispatch

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import _dispatch [as 别名]
 def _dispatch(self, method, params):
     if not method.startswith('system.'):
         # Add store to all of our own methods
         params = (self.store,)+tuple(params)
     return SimpleXMLRPCDispatcher._dispatch(self, method, params)
开发者ID:pombredanne,项目名称:pydotorg.pypi,代码行数:7,代码来源:rpc.py

示例10: _dispatch

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import _dispatch [as 别名]
 def _dispatch(self, method, auth, response_method, params):
     params = (self.auth, response_method, params)
     SimpleXMLRPCDispatcher._dispatch(self, method, params)
开发者ID:fedora-conary,项目名称:rmake-2,代码行数:5,代码来源:rpclib.py

示例11: _dispatch

# 需要导入模块: from SimpleXMLRPCServer import SimpleXMLRPCDispatcher [as 别名]
# 或者: from SimpleXMLRPCServer.SimpleXMLRPCDispatcher import _dispatch [as 别名]
    def _dispatch(self, method, params):

        retn = SimpleXMLRPCDispatcher._dispatch(self, method, params)
        retn = translate(retn)
        return retn
开发者ID:roundup-tracker,项目名称:roundup,代码行数:7,代码来源:xmlrpc.py


注:本文中的SimpleXMLRPCServer.SimpleXMLRPCDispatcher._dispatch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。