deluge.ui.web.json_api

class deluge.ui.web.json_api.EventQueue

This class subscribes to events from the core and stores them until all the subscribed listeners have received the events.

add_listener(listener_id, event)

Add a listener to the event queue.

Parameters:
  • listener_id (string) – A unique id for the listener
  • event (string) – The event name
get_events(listener_id)

Retrieve the pending events for the listener.

Parameter:listener_id (string) – A unique id for the listener
remove_listener(listener_id, event)

Remove a listener from the event queue.

Parameters:
  • listener_id (string) – The unique id for the listener
  • event (string) – The event name
class deluge.ui.web.json_api.WebApi

The component that implements all the methods required for managing the web interface. The complete web json interface also exposes all the methods available from the core RPC.

add_host(host, port, username='', password='')

Adds a host to the list.

Parameters:
  • host (string) – the hostname
  • port (int) – the port
  • username (string) – the username to login as
  • password (string) – the password to login with
add_torrents(torrents)

Add torrents by file

Parameter:torrents (list) – A list of dictionaries containing the torrent path and torrent options to add with.

Usage

>>> json_api.web.add_torrents([{
        "path": "/tmp/deluge-web/some-torrent-file.torrent",
        "options": {"download_path": "/home/deluge/"}
    }])
connect(host_id)

Connect the client to a daemon

Parameter:host_id (string) – the id of the daemon in the host list
Returns:the methods the daemon supports
Return type:list
connected()

The current connection state.

Returns:True if the client is connected
Return type:booleon
deregister_event_listener(event)

Remove an event listener from the event queue.

Parameter:event (string) – The event name
disconnect()
Disconnect the web interface from the connected daemon.
download_torrent_from_url(url, cookie=None)

Download a torrent file from a url to a temporary directory.

Parameter:url (string) – the url of the torrent
Returns:the temporary file name of the torrent file
Return type:string
get_config()

Get the configuration dictionary for the web interface.

Return type:dictionary
Returns:the configuration
get_events()
Retrieve the pending events for the session.
get_host(host_id)

Return the information about a host

Parameter:host_id (string) – the id of the host
Returns:the host information
Return type:list
get_host_status(host_id)

Returns the current status for the specified host.

Parameter:host_id (string) – the hash id of the host
get_hosts()
Return the hosts in the hostlist.
get_torrent_files(torrent_id)

Gets the files for a torrent in tree format

Parameter:torrent_id (string) – the id of the torrent to retrieve.
Returns:The torrents files in a tree
Return type:dictionary
get_torrent_info(filename)

Return information about a torrent on the filesystem.

Parameter:filename (string) – the path to the torrent
Returns:information about the torrent:
{
    "filename": the torrent file,
    "name": the torrent name,
    "size": the total size of the torrent,
    "files": the files the torrent contains,
    "info_hash" the torrents info_hash
}
Return type:dictionary
register_event_listener(event)

Add a listener to the event queue.

Parameter:event (string) – The event name
remove_host(connection_id)

Removes a host for the list

Parameter:host_id (string) – the hash id of the host
set_config(config)

Sets the configuration dictionary for the web interface.

Parameter:config (dictionary) – The configuration options to update
start_daemon(port)
Starts a local daemon.
stop_daemon(host_id)

Stops a running daemon.

Parameter:host_id (string) – the hash id of the host
update_ui(keys, filter_dict)

Gather the information required for updating the web interface.

Parameters:
  • keys (list) – the information about the torrents to gather
  • filter_dict (dictionary) – the filters to apply when selecting torrents.
Returns:

The torrent and ui information.

Return type:

dictionary

deluge.ui.web.json_api.export(auth_level=None)

Decorator function to register an object’s method as a RPC. The object will need to be registered with a :class:JSON to be effective.

Parameters:
  • func (function) – the function to export
  • auth_level (int) – the auth level required to call this method

Previous topic

deluge.ui.web.gen_gettext

Next topic

deluge.ui.web.pluginmanager

This Page