deluge.ui.web package
Submodules
deluge.ui.web.auth module
- class deluge.ui.web.auth.Auth(config)
Bases:
JSONComponent
The component that implements authentication 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:
Template
A template that adds some built-ins to the rendering
- builtins = {'_': <function _>, 'escape': <function escape>, 'version': '2.1.1.dev99'}
- 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(*args: Any, **kwargs: Any)
Bases:
Resource
,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.
- exception deluge.ui.web.json_api.JSONException(inner_exception)
Bases:
Exception
- class deluge.ui.web.json_api.WebApi
Bases:
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 (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:
boolean
- 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 successful, 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 successful, False otherwise.
- set_config(config)
Sets the configuration dictionary for the web interface.
- Parameters:
config (dictionary) – The configuration options to update
- set_theme(theme)
Sets a new Theme to the WebUI
- Parameters:
theme (str) – the theme to apply
- 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:
JSONComponent
Utility functions for the Web UI that do not fit in the WebApi.
- get_languages()
Get the available translated languages
- Returns:
list – of tuples
[(lang-id, language-name), ...]
- get_themes()
Get the available themes
- Returns:
list – of themes
[theme1, theme2, ...]
- 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:
PluginManagerBase
,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:
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 separate daemon process (starts a twisted reactor). If False shares the process and twisted reactor from WebUI plugin or tests.
- get_themes()
- install_signal_handlers()
- set_theme(theme)
- shutdown(*args)
- start()
Start the DelugeWeb server
- start_normal()
- start_ssl()
- stop()
- class deluge.ui.web.server.Flag
Bases:
Resource
- getChild(path, request)
Retrieve a ‘child’ resource from me.
Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().
This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.
For example, the URL /foo/bar/baz will normally be:
| site.resource.getChild('foo').getChild('bar').getChild('baz').
However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.
Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.
- render(request)
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
- class deluge.ui.web.server.GetText
Bases:
Resource
- render(request)
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
- class deluge.ui.web.server.LookupResource(name, *directories)
Bases:
Resource
,Component
- add_directory(directory, path='')
- getChild(path, request)
Retrieve a ‘child’ resource from me.
Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().
This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.
For example, the URL /foo/bar/baz will normally be:
| site.resource.getChild('foo').getChild('bar').getChild('baz').
However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.
Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.
- remove_directory(directory, path='')
- render(request)
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
- class deluge.ui.web.server.MockGetText
Bases:
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)
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
- class deluge.ui.web.server.Render
Bases:
Resource
- getChild(path, request)
Retrieve a ‘child’ resource from me.
Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().
This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.
For example, the URL /foo/bar/baz will normally be:
| site.resource.getChild('foo').getChild('bar').getChild('baz').
However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.
Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.
- render(request)
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
- class deluge.ui.web.server.ScriptResource
Bases:
Resource
,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)
Retrieve a ‘child’ resource from me.
Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().
This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.
For example, the URL /foo/bar/baz will normally be:
| site.resource.getChild('foo').getChild('bar').getChild('baz').
However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.
Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.
- 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)
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
- class deluge.ui.web.server.TopLevel
Bases:
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
- getChildWithDefault(path, request)
Retrieve a static or dynamically generated child resource from me.
First checks if a resource was added manually by putChild, and then call getChild to check for dynamic resources. Only override if you want to affect behaviour of all child lookups, rather than just dynamic ones.
This will check to see if I have a pre-registered child resource of the given name, and call getChild if I do not.
@see: L{IResource.getChildWithDefault}
- get_themes()
- remove_script(script)
Removes a script from the server.
- Parameters:
script (string) – The path to the script
- render(request)
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
- set_theme(theme)
- property stylesheets
- class deluge.ui.web.server.Tracker
Bases:
Resource
- getChild(path, request)
Retrieve a ‘child’ resource from me.
Implement this to create dynamic resource generation – resources which are always available may be registered with self.putChild().
This will not be called if the class-level variable ‘isLeaf’ is set in your subclass; instead, the ‘postpath’ attribute of the request will be left as a list of the remaining path elements.
For example, the URL /foo/bar/baz will normally be:
| site.resource.getChild('foo').getChild('bar').getChild('baz').
However, if the resource returned by ‘bar’ has isLeaf set to true, then the getChild call will never be made on it.
Parameters and return value have the same meaning and requirements as those defined by L{IResource.getChildWithDefault}.
- on_got_icon(icon, request)
- render(request)
Render a given resource. See L{IResource}’s render method.
I delegate to methods of self with the form ‘render_METHOD’ where METHOD is the HTTP that was used to make the request. Examples: render_GET, render_HEAD, render_POST, and so on. Generally you should implement those methods instead of overriding this one.
render_METHOD methods are expected to return a byte string which will be the rendered page, unless the return value is C{server.NOT_DONE_YET}, in which case it is this class’s responsibility to write the results using C{request.write(data)} and then call C{request.finish()}.
Old code that overrides render() directly is likewise expected to return a byte string or NOT_DONE_YET.
@see: L{IResource.render}
- 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.absolute_base_url(base)
Returns base as absolute URL for links
- 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
Module contents
- deluge.ui.web.start()