deluge.ui.web package¶
Submodules¶
deluge.ui.web.auth module¶
-
class
deluge.ui.web.auth.
Auth
(config)¶ 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
-
start
()¶
-
stop
()¶
-
-
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
(*args, **kwargs)¶ Bases:
mako.template.Template
A template that adds some built-ins to the rendering
-
builtins
= {'_': <function _>, 'escape': <function escape>, 'version': '2.0.3'}¶
-
render
(*args, **data)¶
-
-
deluge.ui.web.common.
escape
(text)¶ Used by gettext.js template to escape any translated language strings that might contain newlines or quotes as they would 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:
twisted.web.resource.Resource
,deluge.component.Component
A Twisted Web resource that exposes a JSON-RPC interface for web clients to use.
-
deregister_object
(obj)¶ Deregisters an objects exported rpc methods.
- Parameters
obj (object) – The object that was previously registered.
-
get_remote_methods
(result=None)¶ Updates remote methods from the daemon.
- Returns
t.i.d.Deferred – A deferred returning the available remote methods
-
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, uses the object class name.
-
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:
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.
-
XSS_VULN_KEYS
= ['name', 'message', 'comment', 'tracker_status', 'peers']¶
-
add_host
(host, port, username='', password='')¶ Adds a host to the list.
- Parameters
host (str) – The IP or hostname of the deluge daemon.
port (int) – The port of the deluge daemon.
username (str) – The username to login to the daemon with.
password (str) – The password to login to the daemon with.
- Returns
tuple –
- A tuple of (bool, str). If True will contain the host_id, otherwise
if False will contain the error message.
-
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 web client to a daemon.
- Parameters
host_id (str) – The id of the daemon in the host list.
- Returns
Deferred – List of methods the daemon supports.
-
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
-
disable
()¶
-
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
-
edit_host
(host_id, host, port, username='', password='')¶ Edit host details in the hostlist.
- Parameters
host_id (str) – The host identifying hash.
host (str) – The IP or hostname of the deluge daemon.
port (int) – The port of the deluge daemon.
username (str) – The username to login to the daemon with.
password (str) – The password to login to the daemon with.
- Returns
bool – True if succesful, False otherwise.
-
enable
()¶
-
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_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)¶ Parse a magnet URI for hash and name.
-
get_plugin_info
(name)¶ Get the details for a plugin.
-
get_plugin_resources
(name)¶ Get the resource data files for a plugin.
-
get_plugins
()¶ All available and enabled plugins within WebUI.
Note
This does not represent all plugins from deluge.client.core.
- Returns
dict – A dict containing ‘available_plugins’ and ‘enabled_plugins’ lists.
-
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)¶ Get the status for a torrent, filtered by status keys.
-
register_event_listener
(event)¶ Add a listener to the event queue.
- Parameters
event (string) – The event name
-
remove_host
(host_id)¶ Removes a host from the hostlist.
- Parameters
host_id (str) – The host identifying hash.
- Returns
bool – True if succesful, False otherwise.
-
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)¶ Upload a plugin to config.
-
-
class
deluge.ui.web.json_api.
WebUtils
¶ Bases:
deluge.ui.web.json_api.JSONComponent
Utility functions for the webui that do not fit in the WebApi.
-
get_languages
()¶ Get the available translated languages
- Returns
list – of tuples [(lang-id, language-name), …]
-
-
deluge.ui.web.json_api.
export
(auth_level=5)¶ 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)¶ Disable a plugin.
- Parameters
plugin_name (str) – The plugin name.
- Returns
Deferred –
- A deferred with callback value True or False indicating
whether the plugin is disabled or not.
-
enable_plugin
(name)¶ Enable a plugin.
- Parameters
plugin_name (str) – The plugin name.
- Returns
Deferred –
- A deferred with callback value True or False indicating
whether the plugin is enabled or not.
-
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
(options=None, daemon=True)¶ Bases:
deluge.component.Component
-
__init__
(options=None, daemon=True)¶ Setup the DelugeWeb server.
- Parameters
options (argparse.Namespace) – The web server options.
daemon (bool) – If True run web server as a seperate daemon process (starts a twisted reactor). If False shares the process and twisted reactor from WebUI plugin or tests.
-
install_signal_handlers
()¶
-
shutdown
(*args)¶
-
start
()¶ Start the DelugeWeb server
-
start_normal
()¶
-
start_ssl
()¶
-
stop
()¶
-
-
class
deluge.ui.web.server.
Flag
(*args, **kwargs)¶ Bases:
twisted.web.resource.Resource
-
getChild
(path, request)¶
-
render
(request)¶
-
-
class
deluge.ui.web.server.
GetText
(*args, **kwargs)¶ Bases:
twisted.web.resource.Resource
-
render
(request)¶
-
-
class
deluge.ui.web.server.
LookupResource
(name, *directories)¶ Bases:
twisted.web.resource.Resource
,deluge.component.Component
-
add_directory
(directory, path='')¶
-
getChild
(path, request)¶
-
remove_directory
(directory, path='')¶
-
render
(request)¶
-
-
class
deluge.ui.web.server.
MockGetText
(*args, **kwargs)¶ Bases:
twisted.web.resource.Resource
GetText Mocking class
This class will mock the file gettext.js in case it does not exists. It will be used to define the _ (underscore) function for translations, and will return the string to translate, as is.
-
render
(request)¶
-
-
class
deluge.ui.web.server.
Render
¶ Bases:
twisted.web.resource.Resource
-
getChild
(path, request)¶
-
render
(request)¶
-
-
class
deluge.ui.web.server.
ScriptResource
¶ Bases:
twisted.web.resource.Resource
,deluge.component.Component
-
add_script
(path, filepath, script_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
script_type – The type of script to add (normal, debug, dev)
script_type – string
-
add_script_folder
(path, filepath, script_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
script_type – The type of script to add (normal, debug, dev)
script_type – string
recurse – Whether or not to recurse into other folders
recurse – bool
-
getChild
(path, request)¶
-
get_scripts
(script_type=None)¶ Returns a list of the scripts that can be used for producing script tags.
- Parameters
script_type – The type of scripts to get (normal, debug, dev)
script_type – string
-
has_script_type_files
(script_type)¶ Returns whether all the script files exist for this script type.
- Parameters
script_type (str) – The script type to check (normal, debug, dev).
- Returns
bool – True if the files for this script type exist, otherwise False.
-
remove_script
(path, script_type=None)¶ Removes a script or folder of scripts from the script resource.
- Parameters
path (string) – The path of the folder
script_type – The type of script to add (normal, debug, dev)
script_type – string
-
render
(request)¶
-
-
class
deluge.ui.web.server.
Themes
(*args, **kwargs)¶ Bases:
twisted.web.static.File
-
getChild
(path, request)¶
-
-
class
deluge.ui.web.server.
TopLevel
¶ Bases:
twisted.web.resource.Resource
-
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:
twisted.web.resource.Resource
-
getChild
(path, request)¶
-
on_got_icon
(icon, request)¶
-
render
(request)¶
-
-
class
deluge.ui.web.server.
Upload
(*args, **kwargs)¶ Bases:
twisted.web.resource.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.