Common functions for various parts of Deluge to use.
Creates a magnet uri
| Parameters: |
|
|---|---|
| Returns: | a magnet uri string |
| Return type: | string |
Formats a date string in the locale’s date representation based on the systems timezone
| Parameter: | seconds – float, time in seconds since the Epoch |
|---|---|
| Returns: | a string in the locale’s date representation or “” if seconds < 0 |
| Return type: | string |
Downloads a torrent file from a given URL and checks the file’s validity
| Parameter: | url – string, the url of the .torrent file to fetch |
|---|---|
| Returns: | the filepath to the downloaded file |
| Return type: | string |
Formats a string to display a percentage with two decimal places
| Parameter: | 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%'
Formats a string to show ‘num_peers’ (‘total_peers’)
| Parameters: |
|
|---|---|
| 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'
Gets the free space available at ‘path’
| Parameter: | path – string, the path to check |
|---|---|
| Returns: | the free space at path in bytes |
| Return type: | int |
Formats the bytes value into a string with KiB, MiB or GiB units
| Parameter: | 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'
Formats a string to display a transfer speed utilizing fsize()
| Parameter: | bps – int, bytes per second |
|---|---|
| Returns: | a formatted string representing transfer speed |
| Return type: | string |
Usage
>>> fspeed(43134)
'42.1 KiB/s'
Formats a string to show time in a human readable form
| Parameter: | seconds – int, the number of seconds |
|---|---|
| Returns: | a formatted time string, will return ‘’ if seconds == 0 |
| Return type: | string |
Usage
>>> ftime(23011)
'6h 23m'
| Parameter: | filename – 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 |
| Returns: | the default download directory |
|---|---|
| Return type: | string |
Gets the size in bytes of ‘path’
| Parameter: | 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 |
Provides easy access to files in the deluge/data/pixmaps folder within the Deluge egg
| Parameter: | fname – the filename to look for |
|---|---|
| Returns: | a path to a pixmap file included with Deluge |
| Return type: | string |
The svn revision of the build if available
| Returns: | the svn revision, or “” |
|---|---|
| Return type: | string |
Returns the program version from the egg metadata
| Returns: | the version of Deluge |
|---|---|
| Return type: | string |
A simple test to see if ‘ip’ is valid
| Parameter: | ip – string, the ip to check |
|---|---|
| Returns: | True or False |
| Return type: | bool |
** Usage **
>>> is_ip("127.0.0.1")
True
A check to determine if a uri is a valid bittorrent magnet uri
| Parameter: | uri – string, the uri to check |
|---|---|
| Returns: | True or False |
| Return type: | bool |
Usage
>>> is_magnet("magnet:?xt=urn:btih:SU5225URMTUEQLDXQWRB2EQWN6KLTYKN")
True
A simple regex test to check if the URL is valid
| Parameter: | url – string, the url to test |
|---|---|
| Returns: | True or False |
| Return type: | bool |
Usage
>>> is_url("http://deluge-torrent.org")
True
Opens a file or folder using the system configured program
| Parameter: | path – the path to the file or folder to open |
|---|
Opens a url in the desktop’s default browser
| Parameter: | url – the url to open |
|---|
Checks if the current platform is Mac OS X
| Returns: | True or False |
|---|---|
| Return type: | bool |
Checks if the current platform is Windows Vista
| Returns: | True or False |
|---|---|
| Return type: | bool |
Checks if the current platform is Windows
| Returns: | True or False |
|---|---|
| Return type: | bool |