deluge.ui.web package

Submodules

deluge.ui.web.auth module

class deluge.ui.web.auth.Auth

Bases: deluge.ui.web.json_api.JSONComponent

The component that implements authentification into the JSON interface.

change_password(old_password, new_password)

Change the password.

Parameters:
  • old_password (string) – the current password
  • new_password (string) – the password to change to
check_password(password)
check_request(request, method=None, level=None)

Check to ensure that a request is authorised to call the specified method of authentication level.

Parameters:
  • request (twisted.web.http.Request) – The HTTP request in question
  • method (function) – Check the specified method
  • level (integer) – Check the specified auth level
Raises:

Exception

check_session(session_id=None)

Check a session to see if it’s still valid.

Returns:True if the session is valid, False if not.
Return type:booleon
delete_session()

Removes a session.

Parameters:session_id (string) – the id for the session to remove
login(password)

Test a password to see if it’s valid.

Parameters:password (string) – the password to test
Returns:a session id or False
Return type:string or False
exception deluge.ui.web.auth.AuthError

Bases: exceptions.Exception

An exception that might be raised when checking a request for authentication.

deluge.ui.web.auth.get_session_id(session_id)

Checks a session id against its checksum

deluge.ui.web.auth.make_checksum(session_id)
deluge.ui.web.auth.make_expires(timeout)

deluge.ui.web.common module

class deluge.ui.web.common.Template(text=None, filename=None, uri=None, format_exceptions=False, error_handler=None, lookup=None, output_encoding=None, encoding_errors='strict', module_directory=None, cache_args=None, cache_impl='beaker', cache_enabled=True, cache_type=None, cache_dir=None, cache_url=None, module_filename=None, input_encoding=None, disable_unicode=False, module_writer=None, bytestring_passthrough=False, default_filters=None, buffer_filters=(), strict_undefined=False, imports=None, future_imports=None, enable_loop=True, preprocessor=None, lexer_cls=None)

Bases: mako.template.Template

A template that adds some built-ins to the rendering

builtins = {'version': '1.4.0.dev347', '_': <function <lambda> at 0x7fb14334d410>, 'escape': <function escape at 0x7fb14334d488>}
render(*args, **data)
deluge.ui.web.common.compress(contents, request)
deluge.ui.web.common.escape(text)

Used by the gettext.js template to escape translated strings so they don’t break the script.

deluge.ui.web.json_api module

class deluge.ui.web.json_api.EventQueue

Bases: object

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.

Parameters: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.JSON

Bases: Resource, deluge.component.Component

A Twisted Web resource that exposes a JSON-RPC interface for web clients to use.

connect(host='localhost', port=58846, username='', password='')

Connects the client to a daemon

disable()
enable()
get_remote_methods(result=None)

Updates remote methods from the daemon.

on_get_methods(methods)

Handles receiving the method names.

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 (string) – the name to use, if None, it will be the class name of the object
render(request)

Handles all the POST requests made to the /json controller.

class deluge.ui.web.json_api.JSONComponent(name, interval=1, depend=None)

Bases: deluge.component.Component

exception deluge.ui.web.json_api.JSONException(inner_exception)

Bases: exceptions.Exception

class deluge.ui.web.json_api.WebApi

Bases: deluge.ui.web.json_api.JSONComponent

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

Parameters:torrents (list) – A list of dictionaries containing the torrent path and torrent options to add with.
json_api.web.add_torrents([{
    "path": "/tmp/deluge-web/some-torrent-file.torrent",
    "options": {"download_location": "/home/deluge/"}
}])
connect(host_id)

Connect the client to a daemon

Parameters: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.

Parameters: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.

Parameters: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

Parameters: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.

Parameters:host_id (string) – the hash id of the host
get_hosts()

Return the hosts in the hostlist.

get_magnet_info(uri)

Return information about a magnet link.

Parameters:uri (string) – the magnet link
Returns:information about the magnet link:
{
    "name": the torrent name,
    "info_hash": the torrents info_hash,
    "files_tree": empty value for magnet links
}
Return type:dictionary
get_plugin_info(name)
get_plugin_resources(name)
get_plugins()
get_torrent_files(torrent_id)

Gets the files for a torrent in tree format

Parameters: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.

Parameters:filename (string) – the path to the torrent
Returns:information about the torrent:
{
    "name": the torrent name,
    "files_tree": the files the torrent contains,
    "info_hash" the torrents info_hash
}
Return type:dictionary
get_torrent_status(torrent_id, keys)
register_event_listener(event)

Add a listener to the event queue.

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

Removes a host for the list

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

Sets the configuration dictionary for the web interface.

Parameters:config (dictionary) – The configuration options to update
start()
start_daemon(port)

Starts a local daemon.

stop()
stop_daemon(host_id)

Stops a running daemon.

Parameters: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

upload_plugin(filename, path)
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

deluge.ui.web.pluginmanager module

class deluge.ui.web.pluginmanager.PluginManager

Bases: deluge.pluginmanagerbase.PluginManagerBase, deluge.component.Component

disable_plugin(name)
enable_plugin(name)
get_plugin_resources(name)
start()

Start up the plugin manager

stop()

Stop the plugin manager

update()
deluge.ui.web.pluginmanager.gather_info(plugin)

deluge.ui.web.server module

class deluge.ui.web.server.DelugeWeb

Bases: deluge.component.Component

install_signal_handlers()
shutdown(*args)
start(start_reactor=True)
start_normal()
start_ssl()
stop()
class deluge.ui.web.server.Flag

Bases: Resource

getChild(path, request)
render(request)
class deluge.ui.web.server.GetText

Bases: Resource

render(request)
class deluge.ui.web.server.LookupResource(name, *directories)

Bases: Resource, deluge.component.Component

add_directory(directory, path='')
getChild(path, request)
remove_directory(directory, path='')
render(request)
class deluge.ui.web.server.Render

Bases: Resource

getChild(path, request)
render(request)
class deluge.ui.web.server.ScriptResource

Bases: Resource, deluge.component.Component

add_script(path, filepath, type=None)

Adds a script or scripts to the script resource.

Parameters:
  • path (string) – The path of the script (this supports globbing)
  • filepath (string) – The physical location of the script
  • type – The type of script to add (normal, debug, dev)
  • type – string
add_script_folder(path, filepath, type=None, recurse=True)

Adds a folder of scripts to the script resource.

Parameters:
  • path (string) – The path of the folder
  • filepath (string) – The physical location of the script
  • type – The type of script to add (normal, debug, dev)
  • type – string
  • recurse – Whether or not to recurse into other folders
  • recurse – bool
getChild(path, request)
get_scripts(type=None)

Returns a list of the scripts that can be used for producing script tags.

Parameters:
  • type – The type of scripts to get (normal, debug, dev)
  • type – string
remove_script(path, type=None)

Removes a script or folder of scripts from the script resource.

Parameters:
  • path (string) – The path of the folder
  • type – The type of script to add (normal, debug, dev)
  • type – string
render(request)
class deluge.ui.web.server.ServerContextFactory
getContext()

Creates an SSL context.

class deluge.ui.web.server.TopLevel

Bases: Resource

addSlash = True
add_script(script)

Adds a script to the server so it is included in the <head> element of the index page.

Parameters:script (string) – The path to the script
getChild(path, request)
getChildWithDefault(path, request)
remove_script(script)

Removes a script from the server.

Parameters:script (string) – The path to the script
render(request)
stylesheets
class deluge.ui.web.server.Tracker

Bases: Resource

getChild(path, request)
on_got_icon(icon, request)
render(request)
class deluge.ui.web.server.Upload

Bases: Resource

Twisted Web resource to handle file uploads

render(request)

Saves all uploaded files to the disk and returns a list of filenames, each on a new line.

deluge.ui.web.server.rpath(*paths)

Convert a relative path into an absolute path relative to the location of this script.

deluge.ui.web.web module

class deluge.ui.web.web.Web

Bases: deluge.ui.ui._UI

help = 'Starts the Deluge web interface'
server
start()
class deluge.ui.web.web.WebUI(args)

Bases: deluge.ui.ui.UI

deluge.ui.web.web.start()

Module contents