deluge package¶
Subpackages¶
- deluge.core package
- Submodules
- deluge.core.alertmanager module
- deluge.core.authmanager module
- deluge.core.core module
- deluge.core.daemon module
- deluge.core.eventmanager module
- deluge.core.filtermanager module
- deluge.core.pluginmanager module
- deluge.core.preferencesmanager module
- deluge.core.rpcserver module
- deluge.core.torrent module
- deluge.core.torrentmanager module
- Module contents
- deluge.plugins package
- deluge.ui package
- Subpackages
- deluge.ui.console package
- Subpackages
- deluge.ui.console.commands package
- Submodules
- deluge.ui.console.commands.add module
- deluge.ui.console.commands.cache module
- deluge.ui.console.commands.config module
- deluge.ui.console.commands.connect module
- deluge.ui.console.commands.debug module
- deluge.ui.console.commands.gui module
- deluge.ui.console.commands.halt module
- deluge.ui.console.commands.help module
- deluge.ui.console.commands.info module
- deluge.ui.console.commands.manage module
- deluge.ui.console.commands.move module
- deluge.ui.console.commands.pause module
- deluge.ui.console.commands.plugin module
- deluge.ui.console.commands.quit module
- deluge.ui.console.commands.recheck module
- deluge.ui.console.commands.resume module
- deluge.ui.console.commands.rm module
- deluge.ui.console.commands.status module
- deluge.ui.console.commands.update-tracker module
- Module contents
- deluge.ui.console.modes package
- Submodules
- deluge.ui.console.modes.add_util module
- deluge.ui.console.modes.addtorrents module
- deluge.ui.console.modes.alltorrents module
- deluge.ui.console.modes.basemode module
- deluge.ui.console.modes.column module
- deluge.ui.console.modes.connectionmanager module
- deluge.ui.console.modes.eventview module
- deluge.ui.console.modes.format_utils module
- deluge.ui.console.modes.input_popup module
- deluge.ui.console.modes.legacy module
- deluge.ui.console.modes.popup module
- deluge.ui.console.modes.preference_panes module
- deluge.ui.console.modes.preferences module
- deluge.ui.console.modes.torrent_actions module
- deluge.ui.console.modes.torrentdetail module
- Module contents
- deluge.ui.console.commands package
- Submodules
- deluge.ui.console.colors module
- deluge.ui.console.commander module
- deluge.ui.console.eventlog module
- deluge.ui.console.main module
- deluge.ui.console.statusbars module
- Module contents
- Subpackages
- deluge.ui.gtkui package
- Submodules
- deluge.ui.gtkui.aboutdialog module
- deluge.ui.gtkui.addtorrentdialog module
- deluge.ui.gtkui.common module
- deluge.ui.gtkui.connectionmanager module
- deluge.ui.gtkui.createtorrentdialog module
- deluge.ui.gtkui.details_tab module
- deluge.ui.gtkui.dialogs module
- deluge.ui.gtkui.edittrackersdialog module
- deluge.ui.gtkui.files_tab module
- deluge.ui.gtkui.filtertreeview module
- deluge.ui.gtkui.gtkui module
- deluge.ui.gtkui.ipcinterface module
- deluge.ui.gtkui.listview module
- deluge.ui.gtkui.mainwindow module
- deluge.ui.gtkui.menubar module
- deluge.ui.gtkui.menubar_osx module
- deluge.ui.gtkui.new_release_dialog module
- deluge.ui.gtkui.notification module
- deluge.ui.gtkui.options_tab module
- deluge.ui.gtkui.path_chooser module
- deluge.ui.gtkui.path_combo_chooser module
- deluge.ui.gtkui.peers_tab module
- deluge.ui.gtkui.piecesbar module
- deluge.ui.gtkui.pluginmanager module
- deluge.ui.gtkui.preferences module
- deluge.ui.gtkui.queuedtorrents module
- deluge.ui.gtkui.removetorrentdialog module
- deluge.ui.gtkui.sidebar module
- deluge.ui.gtkui.status_tab module
- deluge.ui.gtkui.statusbar module
- deluge.ui.gtkui.systemtray module
- deluge.ui.gtkui.toolbar module
- deluge.ui.gtkui.torrentdetails module
- deluge.ui.gtkui.torrentview module
- deluge.ui.gtkui.torrentview_data_funcs module
- Module contents
- deluge.ui.web package
- deluge.ui.console package
- Submodules
- deluge.ui.Win32IconImagePlugin module
- deluge.ui.client module
- deluge.ui.common module
- deluge.ui.coreconfig module
- deluge.ui.countries module
- deluge.ui.languages module
- deluge.ui.sessionproxy module
- deluge.ui.tracker_icons module
- deluge.ui.ui module
- Module contents
- Subpackages
Submodules¶
deluge.bencode module¶
- deluge.bencode.bdecode(x)¶
- deluge.bencode.bencode(x)¶
- deluge.bencode.decode_dict(x, f)¶
- deluge.bencode.decode_int(x, f)¶
- deluge.bencode.decode_list(x, f)¶
- deluge.bencode.decode_string(x, f)¶
- deluge.bencode.encode_bencached(x, r)¶
- deluge.bencode.encode_bool(x, r)¶
- deluge.bencode.encode_dict(x, r)¶
- deluge.bencode.encode_int(x, r)¶
- deluge.bencode.encode_list(x, r)¶
- deluge.bencode.encode_string(x, r)¶
deluge.common module¶
Common functions for various parts of Deluge to use.
- class deluge.common.VersionSplit(ver)¶
Bases: object
Used for comparing version numbers.
Parameters: ver (string) – the version - __cmp__(ver)¶
The comparison method.
Parameters: ver (VersionSplit) – the version to compare with
- deluge.common.create_auth_file()¶
- deluge.common.create_localclient_account(append=False)¶
- deluge.common.create_magnet_uri(infohash, name=None, trackers=[])¶
Creates a magnet uri
Parameters: - infohash (string) – the info-hash of the torrent
- name (string) – the name of the torrent (optional)
- trackers (list of strings) – the trackers to announce to (optional)
Returns: a magnet uri string
Return type: string
- deluge.common.decode_string(s, encoding='utf8')¶
Decodes a string and return unicode. If it cannot decode using :param:encoding then it will try latin1, and if that fails, try to detect the string encoding. If that fails, decode with ignore.
Parameters: - s (string) – string to decode
- encoding (string) – the encoding to use in the decoding
Returns: s converted to unicode
Return type: unicode
- deluge.common.fdate(seconds, date_only=False, precision_secs=False)¶
Formats a date time string in the locale’s date representation based on the systems timezone
Parameters: - seconds (float) – time in seconds since the Epoch
- precision_secs (bool) – include seconds in time format
Returns: a string in the locale’s datetime representation or “” if seconds < 0
Return type: string
- deluge.common.fpcnt(dec)¶
Formats a string to display a percentage with two decimal places
Parameters: dec (float) – the ratio in the range [0.0, 1.0] Returns: a formatted string representing a percentage Return type: string Usage
>>> fpcnt(0.9311) '93.11%'
- deluge.common.fpeer(num_peers, total_peers)¶
Formats a string to show ‘num_peers’ (‘total_peers’)
Parameters: - num_peers (int) – the number of connected peers
- total_peers (int) – the total number of peers
Returns: a formatted string: num_peers (total_peers), if total_peers < 0, then it will not be shown
Return type: string
Usage
>>> fpeer(10, 20) '10 (20)' >>> fpeer(10, -1) '10'
- deluge.common.free_space(path)¶
Gets the free space available at ‘path’
Parameters: path (string) – the path to check Returns: the free space at path in bytes Return type: int Raises InvalidPathError: if the path is not valid
- deluge.common.fsize(fsize_b)¶
Formats the bytes value into a string with KiB, MiB or GiB units
Parameters: fsize_b (int) – the filesize in bytes Returns: formatted string in KiB, MiB or GiB units Return type: string Usage
>>> fsize(112245) '109.6 KiB'
- deluge.common.fsize_short(fsize_b)¶
Formats the bytes value into a string with K, M or G units
Parameters: fsize_b (int) – the filesize in bytes Returns: formatted string in K, M or G units Return type: string Usage
>>> fsize(112245) '109.6 K'
- deluge.common.fspeed(bps)¶
Formats a string to display a transfer speed utilizing fsize()
Parameters: bps (int) – bytes per second Returns: a formatted string representing transfer speed Return type: string Usage
>>> fspeed(43134) '42.1 KiB/s'
- deluge.common.ftime(seconds)¶
Formats a string to show time in a human readable form
Parameters: seconds (int) – the number of seconds Returns: a formatted time string, will return ‘’ if seconds == 0 Return type: string Usage
>>> ftime(23011) '6h 23m'
- deluge.common.get_default_config_dir(filename=None)¶
Parameters: filename (string) – if None, only the config path is returned, if provided, a path including the filename will be returned Returns: a file path to the config directory and optional filename Return type: string
- deluge.common.get_default_download_dir()¶
Returns: the default download directory Return type: string
- deluge.common.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
- deluge.common.get_path_size(path)¶
Gets the size in bytes of ‘path’
Parameters: path (string) – the path to check for size Returns: the size in bytes of the path or -1 if the path does not exist Return type: int
- deluge.common.get_pixmap(fname)¶
Provides easy access to files in the deluge/ui/data/pixmaps folder within the Deluge egg
Parameters: fname (string) – the filename to look for Returns: a path to a pixmap file included with Deluge Return type: string
- deluge.common.get_translations_path()¶
Get the absolute path to the directory containing translation files
- deluge.common.get_version()¶
Returns the program version from the egg metadata
Returns: the version of Deluge Return type: string
- deluge.common.is_ip(ip)¶
A simple test to see if ‘ip’ is valid
Parameters: ip (string) – the ip to check Returns: True or False Return type: bool ** Usage **
>>> is_ip("127.0.0.1") True
- deluge.common.is_magnet(uri)¶
A check to determine if a uri is a valid bittorrent magnet uri
Parameters: uri (string) – the uri to check Returns: True or False Return type: bool Usage
>>> is_magnet("magnet:?xt=urn:btih:SU5225URMTUEQLDXQWRB2EQWN6KLTYKN") True
- deluge.common.is_url(url)¶
A simple test to check if the URL is valid
Parameters: url (string) – the url to test Returns: True or False Return type: bool Usage
>>> is_url("http://deluge-torrent.org") True
- deluge.common.open_file(path, timestamp=None)¶
Opens a file or folder using the system configured program.
Parameters: - path (str) – The path to the file or folder to open.
- timestamp (int, optional) – An event request timestamp.
- deluge.common.open_url_in_browser(url)¶
Opens a url in the desktop’s default browser
Parameters: url (string) – the url to open
- deluge.common.osx_check()¶
Checks if the current platform is Mac OS X
Returns: True or False Return type: bool
- deluge.common.path_join(*parts)¶
An implementation of os.path.join that always uses / for the separator to ensure that the correct paths are produced when working with internal paths on Windows.
- deluge.common.resource_filename(module, path)¶
- deluge.common.set_env_variable(name, value)¶
Parameters: - name – environment variable name
- value – environment variable value
This function ensures that changes to an environment variable are applied to each copy of the environment variables used by a process. Starting from Python 2.4, os.environ changes only apply to the copy Python keeps (os.environ) and are no longer automatically applied to the other copies for the process.
On Microsoft Windows, each process has multiple copies of the environment variables, one managed by the OS and one managed by the C library. We also need to take care of the fact that the C library used by Python is not necessarily the same as the C library used by pygtk and friends. This because the latest releases of pygtk and friends are built with mingw32 and are thus linked against msvcrt.dll. The official gtk+ binaries have always been built in this way.
Basen on _putenv in TransUtils.py from sourceforge project gramps http://sourceforge.net/p/gramps/code/HEAD/tree/branches/maintenance/gramps32/src/TransUtils.py
- deluge.common.set_language(lang)¶
Set the language to use.
gettext and GtkBuilder will load the translations from the specified language.
Parameters: lang (str) – the language, e.g. “en”, “de” or “en_GB”
- deluge.common.setup_translations(setup_gettext=True, setup_pygtk=False)¶
- deluge.common.show_file(path, timestamp=None)¶
Shows (highlights) a file or folder using the system configured file manager.
Parameters: - path (str) – The path to the file or folder to show.
- timestamp (int, optional) – An event request timestamp.
- deluge.common.translate_size_units()¶
- deluge.common.unicode_argv()¶
Gets sys.argv as list of unicode objects on any platform.
- deluge.common.utf8_encoded(s, encoding='utf8')¶
Returns a utf8 encoded string of s
Parameters: - s (basestring) – (unicode) string to (re-)encode
- encoding (string) – the encoding to use in the decoding
Returns: a utf8 encoded string of s
Return type: str
- deluge.common.vista_check()¶
Checks if the current platform is Windows Vista
Returns: True or False Return type: bool
- deluge.common.windows_check()¶
Checks if the current platform is Windows
Returns: True or False Return type: bool
- deluge.common.xml_decode(string)¶
Unescape a string that was previously encoded for use within xml.
Parameters: string (string) – The string to escape Returns: The unescaped version of the string. Return type: string
- deluge.common.xml_encode(string)¶
Escape a string for use within an xml element or attribute.
Parameters: string (string) – The string to escape Returns: An escaped version of the string. Return type: string
deluge.component module¶
- class deluge.component.Component(name, interval=1, depend=None)¶
Bases: object
Component objects are singletons managed by the ComponentRegistry. When a new Component object is instantiated, it will be automatically registered with the ComponentRegistry.
The ComponentRegistry has the ability to start, stop, pause and shutdown the components registered with it.
Events:
- start() - This method is called when the client has connected to a
- Deluge core.
- stop() - This method is called when the client has disconnected from a
- Deluge core.
- update() - This method is called every 1 second by default while the
- Componented is in a Started state. The interval can be specified during instantiation. The update() timer can be paused by instructing the ComponentRegistry to pause this Component.
- shutdown() - This method is called when the client is exiting. If the
- Component is in a “Started” state when this is called, a call to stop() will be issued prior to shutdown().
States:
A Component can be in one of these 5 states.
- Started - The Component has been started by the ComponentRegistry
- and will have it’s update timer started.
- Starting - The Component has had it’s start method called, but it hasn’t
- fully started yet.
Stopped - The Component has either been stopped or has yet to be started.
- Stopping - The Component has had it’s stop method called, but it hasn’t
- fully stopped yet.
- Paused - The Component has had it’s update timer stopped, but will
- still be considered in a Started state.
- shutdown()¶
- start()¶
- stop()¶
- update()¶
- exception deluge.component.ComponentAlreadyRegistered¶
Bases: exceptions.Exception
- class deluge.component.ComponentRegistry¶
Bases: object
The ComponentRegistry holds a list of currently registered Component objects. It is used to manage the Components by starting, stopping, pausing and shutting them down.
- deregister(obj)¶
Deregisters a component from the registry. A stop will be issued to the component prior to deregistering it.
Parameters: obj (object) – the Component object
- pause(names=[])¶
Pauses Components that are currently in a Started state. If names is specified, then it will only pause those Components, and if not it will pause all the registered Components.
Parameters: names (list) – a list of Components to pause Returns: a Deferred object that will fire once all Components have been sucessfully paused Return type: twisted.internet.defer.Deferred
- register(obj)¶
Registers a component object with the registry. This is done automatically when a Component object is instantiated.
Parameters: obj (object) – the Component object Raises ComponentAlreadyRegistered: if a component with the same name is already registered.
- resume(names=[])¶
Resumes Components that are currently in a Paused state. If names is specified, then it will only resume those Components, and if not it will resume all the registered Components.
Parameters: names (list) – a list of Components to resume Returns: a Deferred object that will fire once all Components have been successfully resumed Return type: twisted.internet.defer.Deferred
- shutdown()¶
Shutdowns all Components regardless of state. This will call stop() on call the components prior to shutting down. This should be called when the program is exiting to ensure all Components have a chance to properly shutdown.
Returns: a Deferred object that will fire once all Components have been successfully shut down Return type: twisted.internet.defer.Deferred
- start(names=[])¶
Starts Components that are currently in a Stopped state and their dependencies. If names is specified, will only start those Components and their dependencies and if not it will start all registered components.
Parameters: names (list) – a list of Components to start Returns: a Deferred object that will fire once all Components have been sucessfully started Return type: twisted.internet.defer.Deferred
- stop(names=[])¶
Stops Components that are currently not in a Stopped state. If names is specified, then it will only stop those Components, and if not it will stop all the registered Components.
Parameters: names (list) – a list of Components to start Returns: a Deferred object that will fire once all Components have been sucessfully stopped Return type: twisted.internet.defer.Deferred
- update()¶
Updates all Components that are in a Started state.
- deluge.component.get(name)¶
Return a reference to a component.
Parameters: name (string) – the Component name to get Returns: the Component object Return type: object Raises KeyError: if the Component does not exist
deluge.config module¶
Deluge Config Module
This module is used for loading and saving of configuration files.. or anything really.
The format of the config file is two json encoded dicts:
<version dict> <content dict>
The version dict contains two keys: file and format. The format version is controlled by the Config class. It should only be changed when anything below it is changed directly by the Config class. An example of this would be if we changed the serializer for the content to something different.
The config file version is changed by the ‘owner’ of the config file. This is to signify that there is a change in the naming of some config keys or something similar along those lines.
The content is simply the dict to be saved and will be serialized before being written.
Converting
Since the format of the config could change, there needs to be a way to have the Config object convert to newer formats. To do this, you will need to register conversion functions for various versions of the config file. Note that this can only be done for the ‘config file version’ and not for the ‘format’ version as this will be done internally.
- class deluge.config.Config(filename, defaults=None, config_dir=None)¶
Bases: object
This class is used to access/create/modify config files
Parameters: - filename – the name of the config file
- defaults – dictionary of default values
- config_dir – the path to the config directory
- __delitem__(key)¶
See del_item()
- __getitem__(key)¶
See get_item()
- __setitem__(key, value)¶
See set_item()
- apply_all()¶
Calls all set functions
Usage
>>> config = Config("test.conf", defaults={"test": 5}) >>> def cb(key, value): ... print key, value ... >>> config.register_set_function("test", cb, apply_now=False) >>> config.apply_all() test 5
- apply_set_functions(key)¶
Calls set functions for :param:key.
Parameters: key – str, the config key
- config¶
The config dictionary
- config_file¶
- del_item(key)¶
Deletes item with a specific key from the configuration.
Parameters: key – the item which you wish to delete. Raises KeyError: if ‘key’ is not in the config dictionary Usage >>> config = Config(“test.conf”, defaults={“test”: 5}) >>> del config[“test”]
- get(key, default=None)¶
Gets the value of item ‘key’ if key is in the config, else default. If default is not given, it defaults to None, so that this method never raises a KeyError.
Parameters: - key – the item for which you want it’s value
- default – the default value if key is missing
Returns: the value of item ‘key’ or default
Usage
>>> config = Config("test.conf", defaults={"test": 5}) >>> config.get("test", 10) 5 >>> config.get("bad_key", 10) 10
- get_item(key)¶
Gets the value of item ‘key’
Parameters: key – the item for which you want it’s value Returns: the value of item ‘key’ Raises KeyError: if ‘key’ is not in the config dictionary Usage
>>> config = Config("test.conf", defaults={"test": 5}) >>> config["test"] 5
- load(filename=None)¶
Load a config file
Parameters: filename – if None, uses filename set in object initialization
- register_change_callback(callback)¶
Registers a callback function that will be called when a value is changed in the config dictionary
Parameters: callback – the function, callback(key, value) Usage
>>> config = Config("test.conf", defaults={"test": 5}) >>> def cb(key, value): ... print key, value ... >>> config.register_change_callback(cb)
- register_set_function(key, function, apply_now=True)¶
Register a function to be called when a config value changes
Parameters: - key – the item to monitor for change
- function – the function to call when the value changes, f(key, value)
- apply_now – if True, the function will be called after it’s registered
Usage
>>> config = Config("test.conf", defaults={"test": 5}) >>> def cb(key, value): ... print key, value ... >>> config.register_set_function("test", cb, apply_now=True) test 5
- run_converter(input_range, output_version, func)¶
Runs a function that will convert file versions in the :param:input_range to the :param:output_version.
Parameters: - input_range – tuple, (int, int) the range of input versions this function will accept
- output_version – int, the version this function will return
- func – func, the function that will do the conversion, it will take the config dict as an argument and return the augmented dict
Raises ValueError: if the output_version is less than the input_range
- save(filename=None)¶
Save configuration to disk
Parameters: filename – if None, uses filename set in object initiliazation Rtype bool: Returns: whether or not the save succeeded.
- set_item(key, value)¶
Sets item ‘key’ to ‘value’ in the config dictionary, but does not allow changing the item’s type unless it is None. If the types do not match, it will attempt to convert it to the set type before raising a ValueError.
Parameters: - key – string, item to change to change
- value – the value to change item to, must be same type as what is currently in the config
Raises ValueError: raised when the type of value is not the same aswhat is currently in the config and it could not convert the value
Usage
>>> config = Config("test.conf") >>> config["test"] = 5 >>> config["test"] 5
- deluge.config.find_json_objects(s)¶
Find json objects in a string.
Parameters: s (string) – the string to find json objects in Returns: a list of tuples containing start and end locations of json objects in the string s Return type: [(start, end), ...]
- deluge.config.prop(func)¶
Function decorator for defining property attributes
The decorated function is expected to return a dictionary containing one or more of the following pairs:
fget - function for getting attribute value fset - function for setting attribute value fdel - function for deleting attributeThis can be conveniently constructed by the locals() builtin function; see: http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/205183
deluge.configmanager module¶
- deluge.configmanager.ConfigManager(config, defaults=None)¶
- deluge.configmanager.close(config)¶
- deluge.configmanager.get_config_dir(filename=None)¶
- deluge.configmanager.set_config_dir(directory)¶
Sets the config directory, else just uses default
deluge.decorators module¶
- deluge.decorators.proxy(proxy_func)¶
Factory class which returns a decorator that passes the decorated function to a proxy function
Parameters: proxy_func (function) – the proxy function
deluge.error module¶
- exception deluge.error.AuthManagerError(message, username)¶
Bases: deluge.error._UsernameBasedPasstroughError
- exception deluge.error.AuthenticationRequired(message, username)¶
Bases: deluge.error._UsernameBasedPasstroughError
- exception deluge.error.BadLoginError(message, username)¶
Bases: deluge.error._UsernameBasedPasstroughError
- exception deluge.error.DaemonRunningError(message=None)¶
Bases: deluge.error.DelugeError
- exception deluge.error.DelugeError(message=None)¶
Bases: exceptions.Exception
- exception deluge.error.IncompatibleClient(daemon_version)¶
Bases: deluge.error._ClientSideRecreateError
- exception deluge.error.InvalidPathError(message=None)¶
Bases: deluge.error.DelugeError
- exception deluge.error.InvalidTorrentError(message=None)¶
Bases: deluge.error.DelugeError
- exception deluge.error.NotAuthorizedError(current_level, required_level)¶
Bases: deluge.error._ClientSideRecreateError
- exception deluge.error.WrappedException(message, exception_type, traceback)¶
Bases: deluge.error.DelugeError
deluge.event module¶
Event module.
This module describes the types of events that can be generated by the daemon and subsequently emitted to the clients.
- class deluge.event.ConfigValueChangedEvent(key, value)¶
Bases: deluge.event.DelugeEvent
Emitted when a config value changes in the Core.
- class deluge.event.CreateTorrentProgressEvent(piece_count, num_pieces)¶
Bases: deluge.event.DelugeEvent
Emitted when creating a torrent file remotely.
- class deluge.event.DelugeEvent¶
Bases: object
The base class for all events.
Prop name: this is the name of the class which is in-turn the event name Prop args: a list of the attribute values - args¶
- name¶
- class deluge.event.DelugeEventMetaClass(name, bases, dct)¶
Bases: type
This metaclass simply keeps a list of all events classes created.
- class deluge.event.NewVersionAvailableEvent(new_release)¶
Bases: deluge.event.DelugeEvent
Emitted when a more recent version of Deluge is available.
- class deluge.event.PluginDisabledEvent(plugin_name)¶
Bases: deluge.event.DelugeEvent
Emitted when a plugin is disabled in the Core.
- class deluge.event.PluginEnabledEvent(plugin_name)¶
Bases: deluge.event.DelugeEvent
Emitted when a plugin is enabled in the Core.
- class deluge.event.PreTorrentRemovedEvent(torrent_id)¶
Bases: deluge.event.DelugeEvent
Emitted when a torrent is about to be removed from the session.
- class deluge.event.SessionPausedEvent¶
Bases: deluge.event.DelugeEvent
Emitted when the session has been paused.
- class deluge.event.SessionResumedEvent¶
Bases: deluge.event.DelugeEvent
Emitted when the session has been resumed.
- class deluge.event.SessionStartedEvent¶
Bases: deluge.event.DelugeEvent
Emitted when a session has started. This typically only happens once when the daemon is initially started.
- class deluge.event.TorrentAddedEvent(torrent_id, from_state)¶
Bases: deluge.event.DelugeEvent
Emitted when a new torrent is successfully added to the session.
- class deluge.event.TorrentFileCompletedEvent(torrent_id, index)¶
Bases: deluge.event.DelugeEvent
Emitted when a file completes.
- class deluge.event.TorrentFileRenamedEvent(torrent_id, index, name)¶
Bases: deluge.event.DelugeEvent
Emitted when a file within a torrent has been renamed.
- class deluge.event.TorrentFinishedEvent(torrent_id)¶
Bases: deluge.event.DelugeEvent
Emitted when a torrent finishes downloading.
- class deluge.event.TorrentFolderRenamedEvent(torrent_id, old, new)¶
Bases: deluge.event.DelugeEvent
Emitted when a folder within a torrent has been renamed.
- class deluge.event.TorrentQueueChangedEvent¶
Bases: deluge.event.DelugeEvent
Emitted when the queue order has changed.
- class deluge.event.TorrentRemovedEvent(torrent_id)¶
Bases: deluge.event.DelugeEvent
Emitted when a torrent has been removed from the session.
- class deluge.event.TorrentResumedEvent(torrent_id)¶
Bases: deluge.event.DelugeEvent
Emitted when a torrent resumes from a paused state.
- class deluge.event.TorrentStateChangedEvent(torrent_id, state)¶
Bases: deluge.event.DelugeEvent
Emitted when a torrent changes state.
- class deluge.event.TorrentStorageMovedEvent(torrent_id, path)¶
Bases: deluge.event.DelugeEvent
Emitted when the storage location for a torrent has been moved.
deluge.httpdownloader module¶
- class deluge.httpdownloader.HTTPDownloader(url, filename, part_callback=None, headers=None, force_filename=False, allow_compression=True)¶
Bases: HTTPDownloader
Factory class for downloading files and keeping track of progress.
- gotHeaders(headers)¶
- gotStatus(version, status, message)¶
- pageEnd()¶
- pagePart(data)¶
- deluge.httpdownloader.download_file(url, filename, callback=None, headers=None, force_filename=False, allow_compression=True)¶
Downloads a file from a specific URL and returns a Deferred. You can also specify a callback function to be called as parts are received.
Parameters: - url (string) – the url to download from
- filename (string) – the filename to save the file as
- callback (function) – a function to be called when a part of data is received, it’s signature should be: func(data, current_length, total_length)
- headers (dictionary) – any optional headers to send
- force_filename (boolean) – force us to use the filename specified rather than one the server may suggest
- allow_compression (boolean) – allows gzip & deflate decoding
Returns: the filename of the downloaded file
Return type: Deferred
Raises: - t.w.e.PageRedirect – when server responds with a temporary redirect or permanently moved.
- t.w.e.Error – for all other HTTP response errors (besides OK)
- deluge.httpdownloader.sanitise_filename(filename)¶
Sanitises a filename to use as a download destination file. Logs any filenames that could be considered malicious.
Parameters: filename (string) – the filename to sanitise Returns: the sanitised filename Return type: string
deluge.log module¶
Logging functions
- deluge.log.setup_logger(level='error', filename=None, filemode='w')¶
Sets up the basic logger and if :param:filename is set, then it will log to that file instead of stdout.
Parameters: - level – str, the level to log
- filename – str, the file to log to
- deluge.log.set_logger_level(level, logger_name=None)¶
Sets the logger level.
Parameters: - level – str, a string representing the desired level
- logger_name – str, a string representing desired logger name for which the level should change. The default is “None” will will tweak the root logger level.
- deluge.log.get_plugin_logger(logger_name)¶
deluge.main module¶
Main starting point for Deluge. Contains the main() entry point.
- deluge.main.start_daemon()¶
Entry point for daemon script
- deluge.main.start_ui()¶
Entry point for ui script
- deluge.main.version_callback(option, opt_str, value, parser)¶
deluge.maketorrent module¶
- exception deluge.maketorrent.InvalidPath¶
Bases: exceptions.Exception
Raised when an invalid path is supplied
- exception deluge.maketorrent.InvalidPieceSize¶
Bases: exceptions.Exception
Raised when an invalid piece size is set. Piece sizes must be multiples of 16KiB.
- class deluge.maketorrent.TorrentMetadata¶
Bases: object
This class is used to create .torrent files.
** Usage **
>>> t = TorrentMetadata() >>> t.data_path = "/tmp/torrent" >>> t.comment = "My Test Torrent" >>> t.trackers = [["http://tracker.openbittorent.com"]] >>> t.save("/tmp/test.torrent")
- comment¶
Comment is some extra info to be stored in the torrent. This is typically an informational string.
- data_path¶
The path to the files that the torrent will contain. It can be either a file or a folder. This property needs to be set before the torrent file can be created and saved.
- get_comment()¶
Comment is some extra info to be stored in the torrent. This is typically an informational string.
- get_data_path()¶
The path to the files that the torrent will contain. It can be either a file or a folder. This property needs to be set before the torrent file can be created and saved.
- get_pad_files()¶
If this is True, padding files will be added to align files on piece boundaries.
- get_piece_size()¶
The size of pieces in bytes. The size must be a multiple of 16KiB. If you don’t set a piece size, one will be automatically selected to produce a torrent with less than 1024 pieces or the smallest possible with a 8192KiB piece size.
- get_private()¶
Private torrents only announce to the tracker and will not use DHT or Peer Exchange.
- get_trackers()¶
The announce trackers is a list of lists.
- get_webseeds()¶
The web seeds can either be: Hoffman-style: http://bittorrent.org/beps/bep_0017.html or, GetRight-style: http://bittorrent.org/beps/bep_0019.html
If the url ends in ‘.php’ then it will be considered Hoffman-style, if not it will be considered GetRight-style.
- pad_files¶
If this is True, padding files will be added to align files on piece boundaries.
- piece_size¶
The size of pieces in bytes. The size must be a multiple of 16KiB. If you don’t set a piece size, one will be automatically selected to produce a torrent with less than 1024 pieces or the smallest possible with a 8192KiB piece size.
- private¶
Private torrents only announce to the tracker and will not use DHT or Peer Exchange.
- save(torrent_path, progress=None)¶
Creates and saves the torrent file to path.
Parameters: - torrent_path (string) – where to save the torrent file
- progress (function(num_completed, num_pieces)) – a function to be called when a piece is hashed
Raises InvalidPath: if the data_path has not been set
- set_comment(comment)¶
Parameters: comment (string) – an informational string
- set_data_path(path)¶
Parameters: path (string) – the path to the data Raises InvalidPath: if the path is not found
- set_pad_files(pad)¶
Parameters: pad (bool) – set True to align files on piece boundaries
- set_piece_size(size)¶
Parameters: size (int) – the desired piece size in KiBs Raises InvalidPieceSize: if the piece size is not a multiple of 16 KiB
- set_private(private)¶
Parameters: private (bool) – True if the torrent is to be private
- set_trackers(trackers)¶
Parameters: trackers (list of list of strings) – a list of lists of trackers, each list is a tier
- set_webseeds(webseeds)¶
Parameters: webseeds (list of urls) – the webseeds which can be either Hoffman or GetRight style
- trackers¶
The announce trackers is a list of lists.
- webseeds¶
The web seeds can either be: Hoffman-style: http://bittorrent.org/beps/bep_0017.html or, GetRight-style: http://bittorrent.org/beps/bep_0019.html
If the url ends in ‘.php’ then it will be considered Hoffman-style, if not it will be considered GetRight-style.
deluge.metafile module¶
- class deluge.metafile.RemoteFileProgress(session_id)¶
Bases: object
- deluge.metafile.calcsize(path)¶
- deluge.metafile.decode_from_filesystem(path)¶
- deluge.metafile.dummy(*v)¶
- deluge.metafile.get_filesystem_encoding()¶
- deluge.metafile.gmtime()¶
- deluge.metafile.make_meta_file(path, url, piece_length, progress=None, title=None, comment=None, safe=None, content_type=None, target=None, webseeds=None, name=None, private=False, created_by=None, trackers=None)¶
- deluge.metafile.makeinfo(path, piece_length, progress, name=None, content_type=None, private=False)¶
- deluge.metafile.subfiles(d)¶
deluge.path_chooser_common module¶
- deluge.path_chooser_common.get_completion_paths(args)¶
Takes a path value and returns the available completions. If the path_value is a valid path, return all sub-directories. If the path_value is not a valid path, remove the basename from the path and return all sub-directories of path that start with basename.
Parameters: args (dict) – options Returns: the args argument containing the available completions for the completion_text Return type: list
deluge.pluginmanagerbase module¶
PluginManagerBase
- class deluge.pluginmanagerbase.PluginManagerBase(config_file, entry_name)¶
PluginManagerBase is a base class for PluginManagers to inherit
- disable_plugin(name)¶
Disables a plugin
- disable_plugins()¶
- enable_plugin(plugin_name)¶
Enables a plugin
- enable_plugins()¶
- get_available_plugins()¶
Returns a list of the available plugins name
- get_enabled_plugins()¶
Returns a list of enabled plugins
- get_plugin_info(name)¶
Returns a dictionary of plugin info from the metadata
- scan_for_plugins()¶
Scans for available plugins
deluge.rencode module¶
rencode – Web safe object pickling/unpickling.
Public domain, Connelly Barnes 2006-2007.
The rencode module is a modified version of bencode from the BitTorrent project. For complex, heterogeneous data structures with many small elements, r-encodings take up significantly less space than b-encodings:
>>> len(rencode.dumps({'a':0, 'b':[1,2], 'c':99}))
13
>>> len(bencode.bencode({'a':0, 'b':[1,2], 'c':99}))
26
The rencode format is not standardized, and may change with different rencode module versions, so you should check that you are using the same rencode version throughout your project.
- deluge.rencode.dumps(x, float_bits=32)¶
Dump data structure to str.
Here float_bits is either 32 or 64.
- deluge.rencode.loads(x, decode_utf8=False)¶
deluge.transfer module¶
- class deluge.transfer.DelugeTransferProtocol¶
Bases: twisted.internet.protocol.Protocol
Data messages are transfered using very a simple protocol. Data messages are transfered with a header containing the length of the data to be transfered (payload).
- dataReceived(data)¶
This method is called whenever data is received.
Parameters: data – a message as transfered by transfer_message, or a part of such a messsage. - Global variables:
- _buffer - contains the data received _message_length - the length of the payload of the current message.
- get_bytes_recv()¶
Returns the number of bytes received.
Returns: the number of bytes received Return type: int
- get_bytes_sent()¶
Returns the number of bytes sent.
Returns: the number of bytes sent Return type: int
- message_received(message)¶
Override this method to receive the complete message
- transfer_message(data)¶
Transfer the data.
The data will be serialized and compressed before being sent. First a header is sent - containing the length of the compressed payload to come as a signed integer. After the header, the payload is transfered.
Parameters: data – data to be transfered in a data structure serializable by rencode.
Module contents¶
Deluge