Move the list_methods rpc to the daemon object and rename it to 'get_method_list'
This commit is contained in:
parent
27cf34f85b
commit
c399f7c9b3
|
@ -118,3 +118,10 @@ class Daemon(object):
|
||||||
:returns: str, the version number
|
:returns: str, the version number
|
||||||
"""
|
"""
|
||||||
return deluge.common.get_version()
|
return deluge.common.get_version()
|
||||||
|
|
||||||
|
@export()
|
||||||
|
def get_method_list(self):
|
||||||
|
"""
|
||||||
|
Returns a list of the exported methods.
|
||||||
|
"""
|
||||||
|
return self.rpccserver.get_method_list()
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# rpcserver.py
|
# rpcserver.py
|
||||||
#
|
#
|
||||||
# Copyright (C) 2008 Andrew Resch <andrewresch@gmail.com>
|
# Copyright (C) 2008,2009 Andrew Resch <andrewresch@gmail.com>
|
||||||
#
|
#
|
||||||
# Deluge is free software.
|
# Deluge is free software.
|
||||||
#
|
#
|
||||||
|
@ -200,20 +200,6 @@ class DelugeRPCProtocol(Protocol):
|
||||||
self.transport.loseConnection()
|
self.transport.loseConnection()
|
||||||
finally:
|
finally:
|
||||||
return
|
return
|
||||||
elif method == "daemon.list_methods":
|
|
||||||
# This is a method used to populate the json-rpc interface in the
|
|
||||||
# webui
|
|
||||||
try:
|
|
||||||
ret = self.factory.methods.keys()
|
|
||||||
except Exception, e:
|
|
||||||
# Send error packet here
|
|
||||||
log.exception(e)
|
|
||||||
else:
|
|
||||||
self.sendData((RPC_RESPONSE, request_id, (ret)))
|
|
||||||
if not ret:
|
|
||||||
self.transport.loseConnection()
|
|
||||||
finally:
|
|
||||||
return
|
|
||||||
|
|
||||||
if method in self.factory.methods:
|
if method in self.factory.methods:
|
||||||
try:
|
try:
|
||||||
|
@ -306,18 +292,34 @@ class RPCServer(component.Component):
|
||||||
if not name:
|
if not name:
|
||||||
name = obj.__class__.__name__.lower()
|
name = obj.__class__.__name__.lower()
|
||||||
|
|
||||||
log.debug("dir: %s", dir(obj))
|
|
||||||
for d in dir(obj):
|
for d in dir(obj):
|
||||||
if d[0] == "_":
|
if d[0] == "_":
|
||||||
continue
|
continue
|
||||||
if getattr(getattr(obj, d), '_rpcserver_export', False):
|
if getattr(getattr(obj, d), '_rpcserver_export', False):
|
||||||
log.debug("Registering method: %s", name + "." + d)
|
log.debug("Registering method: %s", name + "." + d)
|
||||||
#self.server.register_function(getattr(obj, d), name + "." + d)
|
|
||||||
self.factory.methods[name + "." + d] = getattr(obj, d)
|
self.factory.methods[name + "." + d] = getattr(obj, d)
|
||||||
|
|
||||||
def get_object_method(self, name):
|
def get_object_method(self, name):
|
||||||
|
"""
|
||||||
|
Returns a registered method.
|
||||||
|
|
||||||
|
:param name: str, the name of the method, usually in the form of 'object.method'
|
||||||
|
|
||||||
|
:returns: method
|
||||||
|
|
||||||
|
:raises KeyError: if `:param:name` is not registered
|
||||||
|
|
||||||
|
"""
|
||||||
return self.factory.methods[name]
|
return self.factory.methods[name]
|
||||||
|
|
||||||
|
def get_method_list(self):
|
||||||
|
"""
|
||||||
|
Returns a list of the exported methods.
|
||||||
|
|
||||||
|
:returns: list, the exported methods
|
||||||
|
"""
|
||||||
|
return self.factory.methods.keys()
|
||||||
|
|
||||||
def __generate_ssl_keys(self):
|
def __generate_ssl_keys(self):
|
||||||
"""
|
"""
|
||||||
This method generates a new SSL key/cert.
|
This method generates a new SSL key/cert.
|
||||||
|
|
Loading…
Reference in New Issue