deluge.core.rpcserver

RPCServer Module

exception deluge.core.rpcserver.DelugeError
Bases: exceptions.Exception
class deluge.core.rpcserver.DelugeRPCProtocol

Bases: twisted.internet.protocol.Protocol

connectionLost(reason)

This method is called when the client is disconnected.

Parameter:reason (str) – the reason the client disconnected.
connectionMade()
This method is called when a new client connects.
dataReceived(data)

This method is called whenever data is received from a client. The only message that a client sends to the server is a RPC Request message. If the RPC Request message is valid, then the method is called in a thread with dispatch().

Parameter:data (str) – the data from the client. It should be a zlib compressed rencoded string.
dispatch(request_id, method, args, kwargs)

This method is run when a RPC Request is made. It will run the local method and will send either a RPC Response or RPC Error back to the client.

Parameters:
  • request_id (int) – the request_id from the client (sent in the RPC Request)
  • method (str) – the local method to call. It must be registered with the RPCServer.
  • args (list) – the arguments to pass to method
  • kwargs (dict) – the keyword-arguments to pass to method
sendData(data)

Sends the data to the client.

Parameter:data – the object that is to be sent to the client. This should be one of the RPC message types.
exception deluge.core.rpcserver.NotAuthorizedError
Bases: deluge.core.rpcserver.DelugeError
class deluge.core.rpcserver.RPCServer(port=58846, interface='', allow_remote=False, listen=True)

Bases: deluge.component.Component

This class is used to handle rpc requests from the client. Objects are registered with this class and their methods are exported using the export decorator.

Parameters:
  • port (int) – the port the RPCServer will listen on
  • interface (str) – the interface to listen on, this may override the allow_remote setting
  • allow_remote (bool) – set True if the server should allow remote connections
  • listen (bool) – if False, will not start listening.. This is only useful in Classic Mode
emit_event(event)

Emits the event to interested clients.

Parameter:event (deluge.event.DelugeEvent) – the event to emit
get_method_list()

Returns a list of the exported methods.

Returns:the exported methods
Return type:list
get_object_method(name)

Returns a registered method.

Parameter:name (str) – the name of the method, usually in the form of ‘object.method’
Returns:method
Raises KeyError:
 if name is not registered
register_object(obj, name=None)

Registers an object to export it’s rpc methods. These methods should be exported with the export decorator prior to registering the object.

Parameters:
  • obj (object) – the object that we want to export
  • name (str) – the name to use, if None, it will be the class name of the object
class deluge.core.rpcserver.ServerContextFactory

Bases: object

getContext()

Create an SSL context.

This loads the servers cert/private key SSL files for use with the SSL transport.

deluge.core.rpcserver.check_ssl_keys()
Check for SSL cert/key and create them if necessary
deluge.core.rpcserver.export(auth_level=5)

Decorator function to register an object’s method as an RPC. The object will need to be registered with an RPCServer to be effective.

Parameters:
  • func (function) – the function to export
  • auth_level (int) – the auth level required to call this method
deluge.core.rpcserver.generate_ssl_keys()
This method generates a new SSL key/cert.

Previous topic

deluge.core.preferencesmanager

Next topic

deluge.core.torrent

This Page