deluge.ui package
Subpackages
- deluge.ui.console package
- Subpackages
- deluge.ui.console.cmdline package
- deluge.ui.console.modes package
- Subpackages
- Submodules
- deluge.ui.console.modes.add_util module
- deluge.ui.console.modes.addtorrents module
- deluge.ui.console.modes.basemode module
- deluge.ui.console.modes.cmdline module
- deluge.ui.console.modes.connectionmanager module
- deluge.ui.console.modes.eventview module
- deluge.ui.console.modes.torrentdetail module
- Module contents
- deluge.ui.console.utils package
- deluge.ui.console.widgets package
- Submodules
- deluge.ui.console.console module
- deluge.ui.console.eventlog module
- deluge.ui.console.main module
- deluge.ui.console.parser module
- Module contents
- Subpackages
- deluge.ui.gtk3 package
- Submodules
- deluge.ui.gtk3.aboutdialog module
- deluge.ui.gtk3.addtorrentdialog module
- deluge.ui.gtk3.common module
- deluge.ui.gtk3.connectionmanager module
- deluge.ui.gtk3.createtorrentdialog module
- deluge.ui.gtk3.details_tab module
- deluge.ui.gtk3.dialogs module
- deluge.ui.gtk3.edittrackersdialog module
- deluge.ui.gtk3.files_tab module
- deluge.ui.gtk3.filtertreeview module
- deluge.ui.gtk3.gtkui module
- deluge.ui.gtk3.ipcinterface module
- deluge.ui.gtk3.listview module
- deluge.ui.gtk3.mainwindow module
- deluge.ui.gtk3.menubar module
- deluge.ui.gtk3.menubar_osx module
- deluge.ui.gtk3.new_release_dialog module
- deluge.ui.gtk3.options_tab module
- deluge.ui.gtk3.path_chooser module
- deluge.ui.gtk3.path_combo_chooser module
- deluge.ui.gtk3.peers_tab module
- deluge.ui.gtk3.piecesbar module
- deluge.ui.gtk3.pluginmanager module
- deluge.ui.gtk3.preferences module
- deluge.ui.gtk3.queuedtorrents module
- deluge.ui.gtk3.removetorrentdialog module
- deluge.ui.gtk3.sidebar module
- deluge.ui.gtk3.status_tab module
- deluge.ui.gtk3.statusbar module
- deluge.ui.gtk3.systemtray module
- deluge.ui.gtk3.tab_data_funcs module
- deluge.ui.gtk3.toolbar module
- deluge.ui.gtk3.torrentdetails module
- deluge.ui.gtk3.torrentview module
- deluge.ui.gtk3.torrentview_data_funcs module
- deluge.ui.gtk3.trackers_tab module
- Module contents
- deluge.ui.web package
Submodules
deluge.ui.client module
- class deluge.ui.client.Client
Bases:
object
This class is used to connect to a daemon process and issue RPC requests.
- property auth_levels_mapping
- property auth_levels_mapping_reverse
- connect(host='127.0.0.1', port=58846, username='', password='', skip_authentication=False)
Connects to a daemon process.
- Parameters
host – str, the hostname of the daemon
port – int, the port of the daemon
username – str, the username to login with
password – str, the password to login with
- Returns
a Deferred object that will be called once the connection has been established or fails
- connected()
Check to see if connected to a daemon.
- Returns
bool, True if connected
- connection_info()
Get some info about the connection or return None if not connected.
- Returns
a tuple of (host, port, username) or None if not connected
- deregister_event_handler(event, handler)
Deregisters a event handler.
- Parameters
event – str, the name of the event
handler – function, the function registered
- disconnect()
Disconnects from the daemon.
- force_call(block=False)
- get_auth_level()
Returns the authentication level the daemon returned upon authentication.
- Returns
the authentication level
- Return type
int
- get_auth_user()
Returns the current authenticated username.
- Returns
the authenticated username
- Return type
str
- get_bytes_recv()
Returns the number of bytes received from the daemon.
- Returns
the number of bytes received
- Return type
int
- get_bytes_sent()
Returns the number of bytes sent to the daemon.
- Returns
the number of bytes sent
- Return type
int
- is_classicmode()
Deprecated: Use is_standalone
- is_localhost()
Checks if the current connected host is a localhost or not.
- Returns
bool, True if connected to a localhost
- is_standalone()
Checks to see if the client has been started in standalone mode.
- Returns
bool, True if in standalone mode
- register_event_handler(event, handler)
Registers a handler that will be called when an event is received from the daemon.
- Params event
str, the event to handle
- Params handler
func, the handler function, f(args)
- set_disconnect_callback(cb)
Set a function to be called whenever the client is disconnected from the daemon for any reason.
- start_classic_mode()
Deprecated: Use start_standalone
- start_daemon(port, config)
Starts a daemon process.
- Parameters
port (int) – Port for the daemon to listen on.
config (str) – Config path to pass to daemon.
- Returns
bool – True is successfully started the daemon, False otherwise.
- start_standalone()
Starts a daemon in the same process as the client.
- stop_classic_mode()
Deprecated: Use stop_standalone
- stop_standalone()
Stops the daemon process in the client.
- class deluge.ui.client.DaemonProxy
Bases:
object
- class deluge.ui.client.DaemonSSLProxy(event_handlers=None)
Bases:
deluge.ui.client.DaemonProxy
- authenticate(username, password)
- call(method, *args, **kwargs)
Makes a RPCRequest to the daemon. All methods should be in the form of ‘component.method’.
- Params method
str, the method to call in the form of ‘component.method’
- Params args
the arguments to call the remote method with
- Params kwargs
the keyword arguments to call the remote method with
- Returns
a twisted.Deferred object that will be activated when a RPCResponse or RPCError is received from the daemon
- connect(host, port)
Connects to a daemon at host:port
- Parameters
host – str, the host to connect to
port – int, the listening port on the daemon
- Returns
twisted.Deferred
- deregister_event_handler(event, handler)
Deregisters a event handler.
- Parameters
event (str) – the name of the event
handler (function) – the function registered
- disconnect()
- get_bytes_recv()
- get_bytes_sent()
- pop_deferred(request_id)
Pops a Deferred object. This is generally called once we receive the reply we were waiting on from the server.
- Parameters
request_id (int) – the request_id of the Deferred to pop
- register_event_handler(event, handler)
Registers a handler function to be called when :param:event is received from the daemon.
- Parameters
event (str) – the name of the event to handle
handler (function) – the function to be called when :param:event is emitted from the daemon
- set_disconnect_callback(cb)
Set a function to be called when the connection to the daemon is lost for any reason.
- class deluge.ui.client.DaemonStandaloneProxy(event_handlers=None)
Bases:
deluge.ui.client.DaemonProxy
- call(method, *args, **kwargs)
- deregister_event_handler(event, handler)
Deregisters a event handler.
- Parameters
event (str) – the name of the event
handler (function) – the function registered
- disconnect()
- register_event_handler(event, handler)
Registers a handler function to be called when :param:event is received from the daemon.
- Parameters
event (str) – the name of the event to handle
handler (function) – the function to be called when :param:event is emitted from the daemon
- class deluge.ui.client.DelugeRPCClientFactory(daemon, event_handlers)
Bases:
twisted.internet.protocol.ClientFactory
- clientConnectionFailed(connector, reason)
Called when a connection has failed to connect.
It may be useful to call connector.connect() - this will reconnect.
@type reason: L{twisted.python.failure.Failure}
- clientConnectionLost(connector, reason)
Called when an established connection is lost.
It may be useful to call connector.connect() - this will reconnect.
@type reason: L{twisted.python.failure.Failure}
- protocol
alias of
deluge.ui.client.DelugeRPCProtocol
- startedConnecting(connector)
Called when a connection has been started.
You can call connector.stopConnecting() to stop the connection attempt.
@param connector: a Connector object.
- class deluge.ui.client.DelugeRPCProtocol
Bases:
deluge.transfer.DelugeTransferProtocol
- connectionMade()
Called when a connection is made.
This may be considered the initializer of the protocol, because it is called when the connection is completed. For clients, this is called once the connection to the server has been established; for servers, this is called after an accept() call stops blocking and a socket has been received. If you need to send any greeting or initial message, do it here.
- message_received(request)
This method is called whenever we receive a message from the daemon.
- Parameters
request – a tuple that should be either a RPCResponse, RCPError or RPCSignal
- send_request(request)
Sends a RPCRequest to the server.
- Parameters
request – RPCRequest
- class deluge.ui.client.DelugeRPCRequest
Bases:
object
This object is created whenever there is a RPCRequest to be sent to the daemon. It is generally only used by the DaemonProxy’s call method.
- args = None
- format_message()
Returns a properly formatted RPCRequest based on the properties. Will raise a TypeError if the properties haven’t been set yet.
- Returns
a properly formatted RPCRequest
- kwargs = None
- method = None
- request_id = None
- class deluge.ui.client.DottedObject(daemon, method)
Bases:
object
This is used for dotted name calls to client
- class deluge.ui.client.RemoteMethod(daemon, method)
Bases:
deluge.ui.client.DottedObject
This is used when something like ‘client.core.get_something()’ is attempted.
- deluge.ui.client.format_kwargs(kwargs)
deluge.ui.common module
The ui common module contains methods and classes that are deemed useful for all the interfaces.
- class deluge.ui.common.FileTree(paths)
Bases:
object
Convert a list of paths in a file tree.
- Parameters
paths (list) – The paths to be converted.
- get_tree()
Return the tree, after first converting all file lists to a tuple.
- Returns
the file tree.
- Return type
dictionary
- walk(callback)
Walk through the file tree calling the callback function on each item contained.
- Parameters
callback (function) – The function to be used as a callback, it should have the signature func(item, path) where item is a tuple for a file and dict for a directory.
- class deluge.ui.common.FileTree2(paths)
Bases:
object
Converts a list of paths in to a file tree.
- Parameters
paths (list) – The paths to be converted
- get_tree()
Return the tree.
- Returns
the file tree.
- Return type
dictionary
- walk(callback)
Walk through the file tree calling the callback function on each item contained.
- Parameters
callback (function) – The function to be used as a callback, it should have the signature func(item, path) where item is a tuple for a file and dict for a directory.
- class deluge.ui.common.TorrentInfo(filename='', filetree=1, torrent_file=None)
Bases:
object
Collects information about a torrent file.
- Parameters
filename (str, optional) – The path to the .torrent file.
filetree (int, optional) – The version of filetree to create (defaults to 1).
torrent_file (dict, optional) – A bdecoded .torrent file contents.
- as_dict(*keys)
The torrent info as a dictionary, filtered by keys.
- Parameters
keys (str) – A space-separated string of keys.
- Returns
dict – The torrent info dict with specified keys.
- property filedata
The contents of the .torrent file.
- Returns
bytes – The bencoded metainfo.
- property files
The files that the torrent contains.
- Returns
list – The list of torrent files.
- property files_tree
A tree of the files the torrent contains.
{ "some_directory": { "some_file": (index, size, download) } }
- Returns
dict – The tree of files.
- classmethod from_metadata(metadata, trackers=None)
Create a TorrentInfo from metadata and trackers
- Parameters
metadata (dict) – A bdecoded info section of torrent file.
trackers (list of lists, optional) – The trackers to include.
- property info_hash
The calculated torrent info_hash.
- Returns
str – The torrent info_hash.
- property metainfo
Returns the torrent metainfo dictionary.
This is the bdecoded torrent file contents.
- Returns
dict – The metainfo dictionary.
- property name
The name of the torrent.
- Returns
str – The torrent name.
deluge.ui.coreconfig module
- class deluge.ui.coreconfig.CoreConfig
Bases:
deluge.component.Component
- start()
- stop()
deluge.ui.countries module
deluge.ui.hostlist module
- class deluge.ui.hostlist.HostList
Bases:
object
This class contains methods for adding, removing and looking up hosts in hostlist.conf.
- add_default_host()
- add_host(hostname, port, username, password)
Add a new host to hostlist.
- Parameters
hostname (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
str – The new host id.
- check_info_exists(hostname, port, username, skip_host_id=None)
Check for existing host entries with the same details.
- Parameters
hostname (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.
skip_host_id (str) – A host_id to skip to check if other hosts match details.
- Raises
ValueError – Host details already exist.
- connect_host(host_id)
Connect to host daemon
- get_host_info(host_id)
Get the host details for host_id.
- Parameters
host_id (str) – The host id to get info on.
- Returns
list – A list of (host_id, hostname, port, username).
- get_host_status(host_id)
Gets the current status (online/offline) of the host
- Parameters
host_id (str) – The host id to check status of.
- Returns
tuple – A tuple of strings (host_id, status, version).
- get_hosts_info()
Get information of all the hosts in the hostlist.
- Returns
list of lists – Host information in the format [(host_id, hostname, port, username)].
- remove_host(host_id)
Removes the host entry from hostlist config.
- Parameters
host_id (str) – The host id to remove.
- Returns
bool – True is successfully removed, False otherwise.
- update_host(host_id, hostname, port, username, password)
Update the supplied host id with new connection details.
- Parameters
host_id (str) – The host id to update.
hostname (str) – The new IP or hostname of the deluge daemon.
port (int) – The new port of the deluge daemon.
username (str) – The new username to login to the daemon with.
password (str) – The new password to login to the daemon with.
- deluge.ui.hostlist.default_hostlist()
Create a new hosts key for hostlist with a localhost entry
- deluge.ui.hostlist.mask_hosts_password(hosts)
Replace passwords in hosts list with *’s for log output
- deluge.ui.hostlist.migrate_config_2_to_3(config)
Mirgrates old hostlist config files to new file version
- deluge.ui.hostlist.migrate_hostlist(old_filename, new_filename)
Check for old hostlist filename and save details to new filename
- deluge.ui.hostlist.validate_host_info(hostname, port)
Checks that hostname and port are valid.
- Parameters
hostname (str) – The IP or hostname of the deluge daemon.
port (int) – The port of the deluge daemon.
- Raises
ValueError – Host details are not valid with reason.
deluge.ui.sessionproxy module
- class deluge.ui.sessionproxy.SessionProxy
Bases:
deluge.component.Component
The SessionProxy component is used to cache session information client-side to reduce the number of RPCs needed to provide a rich user interface.
It will query the Core for only changes in the status of the torrents and will try to satisfy client requests from the cache.
- create_status_dict(torrent_ids, keys)
Creates a status dict from the cache.
- Parameters
torrent_ids (list of strings) – the torrent_ids
keys (list of strings) – the status keys
- Returns
a dict with the status information for the torrent_ids
- Return type
dict
- get_torrent_status(torrent_id, keys)
Get a status dict for one torrent.
- Parameters
torrent_id (string) – the torrent_id
keys (list of strings) – the status keys
- Returns
a dict of status information
- Return type
dict
- get_torrents_status(filter_dict, keys)
Get a dict of torrent statuses.
The filter can take 2 keys, state and id. The state filter can be one of the torrent states or the special one Active. The id key is simply a list of torrent_ids.
- Parameters
filter_dict (dict) – the filter used for this query
keys (list of strings) – the status keys
- Returns
a dict of torrent_ids and their status dicts
- Return type
dict
- on_torrent_added(torrent_id, from_state)
- on_torrent_removed(torrent_id)
- on_torrent_state_changed(torrent_id, state)
- start()
- stop()
deluge.ui.tracker_icons module
- class deluge.ui.tracker_icons.FaviconParser
Bases:
html.parser.HTMLParser
A HTMLParser which extracts favicons from a HTML page
- get_icons()
Returns a list of favicons extracted from the HTML page
- Returns
a list of favicons
- Return type
list
- handle_endtag(tag)
- handle_starttag(tag, attrs)
- exception deluge.ui.tracker_icons.InvalidIconError
Bases:
Exception
- exception deluge.ui.tracker_icons.NoIconsError
Bases:
Exception
- class deluge.ui.tracker_icons.TrackerIcon(filename)
Bases:
object
Represents a tracker’s icon
- __init__(filename)
Initialises a new TrackerIcon object
- Parameters
filename (string) – the filename of the icon
- get_cached_icon()
Returns the cached icon data.
- get_data()
Returns the TrackerIcon’s image data as a string
- Returns
the image data
- Return type
string
- get_filename(full=True)
Returns the TrackerIcon image’s filename
- Parameters
full (boolean) – an (optional) arg to indicate whether or not to return the full path
- Returns
the path of the TrackerIcon’s image
- Return type
string
- get_mimetype()
Returns the mimetype of this TrackerIcon’s image
- Returns
the mimetype of the image
- Return type
string
- set_cached_icon(data)
Set the cached icon data.
- class deluge.ui.tracker_icons.TrackerIcons(icon_dir=None, no_icon=None)
Bases:
deluge.component.Component
A TrackerIcon factory class
- __init__(icon_dir=None, no_icon=None)
Initialises a new TrackerIcons object
- Parameters
icon_dir (string) – the (optional) directory of where to store the icons
no_icon (string) – the (optional) path name of the icon to show when no icon can be fetched
- check_icon_is_valid(icon_name)
Performs a sanity check on icon_name
- Parameters
icon_name (string) – the name of the icon to check
- Returns
the name of the validated icon
- Return type
string
- Raises
InvalidIconError
- static del_tmp_file(result, tmp_file)
Remove tmp_file created when downloading tracker page
- download_icon(icons, host)
Downloads the first available icon from icons
- Parameters
icons (list) – a list of icons
host (string) – the tracker’s host name
- Returns
a Deferred which fires with the downloaded icon’s filename
- Return type
Deferred
- download_page(host, filename, url=None)
Downloads a tracker host’s page
If no url is provided, it bases the url on the host
- Parameters
host (
str
) – The tracker hostfilename (
str
) – Location to download pageurl (
Optional
[str
]) – The url of the host
- Return type
Deferred
[str
]- Returns
The filename of the tracker host’s page
- fetch(host)
Fetches (downloads) the icon for the given host. When the icon is downloaded a callback is fired on the the queue of callers to this function.
- Parameters
host (string) – the host to obtain the TrackerIcon for
- Returns
a Deferred which fires with the TrackerIcon for the given host
- Return type
Deferred
- get(host)
Returns a TrackerIcon for the given tracker’s host from the icon cache.
- Parameters
host (string) – the host for the TrackerIcon
- Returns
the TrackerIcon for the host
- Return type
- has(host)
Returns True or False if the tracker icon for the given host exists or not.
- Parameters
host (string) – the host for the TrackerIcon
- Returns
True or False
- Return type
bool
- host_to_url(host)
Given a host, returns the URL to fetch
- Parameters
host (string) – the tracker host
- Returns
the url of the tracker
- Return type
string
- on_download_icon_complete(icon_name, host)
Runs any download cleanup functions
- Parameters
icon_name (string) – the filename of the icon that finished downloading
host (string) – the host the icon completed to download for
- Returns
the icon that finished downloading
- Return type
- on_download_icon_fail(f, host, icons=None)
Recovers from a download error
- Parameters
f (Failure) – the failure that occurred
host (string) – the host the icon failed to download for
icons (list) – the (optional) list of remaining icons
- Returns
a Deferred if recovery was possible else the original failure
- Return type
Deferred or Failure
- on_download_page_complete(page)
Runs any download clean up functions
- Parameters
page (string) – the page that finished downloading
- Returns
the page that finished downloading
- Return type
string
- on_download_page_fail(failure)
Runs any download failure clean-up functions
- Parameters
failure (
Failure
) – The failure that occurred.- Return type
Failure
- Returns
The original failure.
- on_parse_complete(icons, host)
Runs any parse clean up functions
- Parameters
icons (list) – the icons that were extracted from the page
host (string) – the host the icons are for
- Returns
the icons that were extracted from the page
- Return type
list
- on_parse_fail(f)
Recovers from a parse error
- Parameters
f (Failure) – the failure that occurred
- Returns
a Deferred if recovery was possible else the original failure
- Return type
Deferred or Failure
- parse_html_page(page)
Parses the html page for favicons
- Parameters
page (string) – the page to parse
- Returns
a Deferred which callbacks a list of available favicons (url, type)
- Return type
Deferred
- resize_icon(icon)
Resizes the given icon to be 16x16 pixels
- Parameters
icon (TrackerIcon) – the icon to resize
- Returns
the resized icon
- Return type
- store_icon(icon, host)
Stores the icon for the given host Callbacks any pending deferreds waiting on this icon
- Parameters
icon (TrackerIcon or None) – the icon to store
host (string) – the host to store it for
- Returns
the stored icon
- Return type
TrackerIcon or None
- deluge.ui.tracker_icons.extension_to_mimetype(extension)
Given a filename extension, returns the appropriate mimetype
- Parameters
extension (string) – the filename extension
- Returns
the mimetype for the given filename extension
- Return type
string
- Raises
KeyError – if given an invalid filename extension
- deluge.ui.tracker_icons.host_to_icon_name(host, mimetype)
Given a host, returns the appropriate icon name
- Parameters
host (string) – the host in question
mimetype (string) – the mimetype of the icon
- Returns
the icon’s filename
- Return type
string
- deluge.ui.tracker_icons.icon_name_to_host(icon)
Given a host’s icon name, returns the host name
- Parameters
icon (string) – the icon name
- Returns
the host name
- Return type
string
- deluge.ui.tracker_icons.mimetype_to_extension(mimetype)
Given a mimetype, returns the appropriate filename extension
- Parameters
mimetype (string) – the mimetype
- Returns
the filename extension for the given mimetype
- Return type
string
- Raises
KeyError – if given an invalid mimetype
- deluge.ui.tracker_icons.url_to_host(url)
Given a URL, returns the host it belongs to
- Parameters
url (string) – the URL in question
- Returns
the host of the given URL
- Return type
string
deluge.ui.ui module
deluge.ui.ui_entry module
Main starting point for Deluge
- deluge.ui.ui_entry.start_ui()
Entry point for ui script