def default(self, *args, **params): # pylint: disable=W0613 """ Handle all XML-RPC calls. It was necessary to make enough changes to the stock CherryPy :class:`cherrypy._cptools.XMLRPCController` to support plugin RMI and prepending the client address that we just rewrote it. It clearly wasn't written with inheritance in mind.""" rpcparams, rpcmethod = xmlrpcutil.process_body() if rpcmethod == 'ERRORMETHOD': raise Exception("Unknown error processing XML-RPC request body") elif "." not in rpcmethod: address = (cherrypy.request.remote.ip, cherrypy.request.remote.name) rpcparams = (address, ) + rpcparams handler = getattr(self, rpcmethod, None) if not handler or not getattr(handler, "exposed", False): raise Exception('Method "%s" is not supported' % rpcmethod) else: try: handler = self.rmi[rpcmethod] except KeyError: raise Exception('Method "%s" is not supported' % rpcmethod) method_start = time.time() try: body = handler(*rpcparams, **params) finally: Bcfg2.Server.Statistics.stats.add_value(rpcmethod, time.time() - method_start) xmlrpcutil.respond(body, 'utf-8', True) return cherrypy.serving.response.body
def default(self, *args, **params): # pylint: disable=W0613 """ needed to make enough changes to the stock XMLRPCController to support plugin.__rmi__ and prepending client address that we just rewrote. it clearly wasn't written with inheritance in mind :( """ rpcparams, rpcmethod = xmlrpcutil.process_body() if rpcmethod == 'ERRORMETHOD': raise Exception("Unknown error processing XML-RPC request body") elif "." not in rpcmethod: address = (cherrypy.request.remote.ip, cherrypy.request.remote.name) rpcparams = (address, ) + rpcparams handler = getattr(self, rpcmethod, None) if not handler or not getattr(handler, "exposed", False): raise Exception('Method "%s" is not supported' % rpcmethod) else: try: handler = self.rmi[rpcmethod] except KeyError: raise Exception('Method "%s" is not supported' % rpcmethod) method_start = time.time() try: body = handler(*rpcparams, **params) finally: Bcfg2.Statistics.stats.add_value(rpcmethod, time.time() - method_start) xmlrpcutil.respond(body, 'utf-8', True) return cherrypy.serving.response.body
def default (self, *vpath, **params): '''Обработчик по умолчанию''' cherrypy.request.body.fp.bytes_read = 0 try: body = cherrypy.request.body.read () rpc_params, rpc_method = xmlrpcutil.get_xmlrpclib ().loads ( body if isinstance (body, str) else body.encode ('utf-8') ) except: cherrypy.log.error ('Parsing request error', 'RPC', logging.WARNING, True) raise Exception ('Invalid request', -32700) method = self._find_method (rpc_method) if method: body = self._call_method (method, rpc_method, rpc_params, vpath, params) else: raise Exception ('Method "{}" not found'.format (rpc_method), -32601) conf = cherrypy.serving.request.toolmaps ['tools'].get ('xmlrpc', {}) xmlrpcutil.respond ( body, conf.get ('encoding', 'utf-8'), conf.get ('allow_none', 0) ) return cherrypy.serving.response.body
def default(self, *vpath, **params): rpcparams, rpcmethod = _xmlrpc.process_body() subhandler = self for attr in str(rpcmethod).split('.'): subhandler = getattr(subhandler, attr, None) if subhandler and getattr(subhandler, 'exposed', False): body = subhandler(*(vpath + rpcparams), **params) else: # https://github.com/cherrypy/cherrypy/issues/533 # if a method is not found, an xmlrpclib.Fault should be returned # raising an exception here will do that; see # cherrypy.lib.xmlrpcutil.on_error raise Exception('method "%s" is not supported' % attr) conf = cherrypy.serving.request.toolmaps['tools'].get('xmlrpc', {}) # SOUTHPAW allow_none = 1 # /SOUTHPAW _xmlrpc.respond(body, conf.get('encoding', 'utf-8'), # SOUTHPAW # conf.get('allow_none', 0)) conf.get('allow_none', allow_none)) # /SOUTHPAW return cherrypy.serving.response.body
def default(self, *vpath, **params): # needed to make enough changes to the stock XMLRPCController # to support plugin.__rmi__ and prepending client address that # we just rewrote. it clearly wasn't written with inheritance # in mind :( rpcparams, rpcmethod = xmlrpcutil.process_body() if "." not in rpcmethod: address = (cherrypy.request.remote.ip, cherrypy.request.remote.name) rpcparams = (address, ) + rpcparams handler = getattr(self, rpcmethod) if not handler or not getattr(handler, "exposed", False): raise Exception('method "%s" is not supported' % attr) else: try: handler = self.rmi[rpcmethod] except: raise Exception('method "%s" is not supported' % rpcmethod) method_start = time.time() try: body = handler(*rpcparams, **params) finally: self.stats.add_value(rpcmethod, time.time() - method_start) xmlrpcutil.respond(body, 'utf-8', True) return cherrypy.serving.response.body
def default(self, *vpath, **params): rpcparams, rpcmethod = _xmlrpc.process_body() subhandler = self for attr in str(rpcmethod).split("."): subhandler = getattr(subhandler, attr, None) if subhandler and getattr(subhandler, "exposed", False): body = subhandler(*(vpath + rpcparams), **params) else: # https://bitbucket.org/cherrypy/cherrypy/issue/533 # if a method is not found, an xmlrpclib.Fault should be returned # raising an exception here will do that; see # cherrypy.lib.xmlrpcutil.on_error raise Exception('method "%s" is not supported' % attr) conf = cherrypy.serving.request.toolmaps["tools"].get("xmlrpc", {}) _xmlrpc.respond(body, conf.get("encoding", "utf-8"), conf.get("allow_none", 0)) return cherrypy.serving.response.body
def default(self, *vpath, **params): rpcparams, rpcmethod = _xmlrpc.process_body() subhandler = self for attr in str(rpcmethod).split('.'): subhandler = getattr(subhandler, attr, None) if subhandler and getattr(subhandler, "exposed", False): body = subhandler(*(vpath + rpcparams), **params) else: # http://www.cherrypy.org/ticket/533 # if a method is not found, an xmlrpclib.Fault should be returned # raising an exception here will do that; see # cherrypy.lib.xmlrpcutil.on_error raise Exception('method "%s" is not supported' % attr) conf = cherrypy.serving.request.toolmaps['tools'].get("xmlrpc", {}) _xmlrpc.respond(body, conf.get('encoding', 'utf-8'), conf.get('allow_none', 0)) return cherrypy.serving.response.body
def default(self, *vpath, **params): '''Обработчик по умолчанию''' cherrypy.request.body.fp.bytes_read = 0 try: body = cherrypy.request.body.read() rpc_params, rpc_method = xmlrpcutil.get_xmlrpclib().loads( body if isinstance(body, str) else body.encode('utf-8')) except: cherrypy.log.error('Parsing request error', 'RPC', logging.WARNING, True) raise Exception('Invalid request', -32700) method = self._find_method(rpc_method) if method: body = self._call_method(method, rpc_method, rpc_params, vpath, params) else: raise Exception('Method "{}" not found'.format(rpc_method), -32601) conf = cherrypy.serving.request.toolmaps['tools'].get('xmlrpc', {}) xmlrpcutil.respond(body, conf.get('encoding', 'utf-8'), conf.get('allow_none', 0)) return cherrypy.serving.response.body