Package DebTorrent :: Module launchmanycore :: Class LaunchMany
[hide private]
[frames] | no frames]

Class LaunchMany

source code

Manage the collection of all single torrent downloads.

Instance Methods [hide private]
 
__init__(self, config, configdir)
Initialize the instance.
source code
boolean
run(self)
Run the mutliple downloads.
source code
list
gather_stats(self)
Gather the statistics for the currently running torrents.
source code
 
remove(self, hash)
Stop and remove a running torrent.
source code
 
add(self, hash, data, save_cache=True)
Start a new torrent running, or add the data to the current one.
source code
 
start(self, hash)
Start a cached torrent.
source code
string
saveAs(self, hash, name, saveas, isdir)
Determine the location to save the torrent in.
source code
download_bt1.BT1Download, int
find_file(self, mirror, path)
Find which running torrent has the file.
source code
 
hashchecksched(self, hash=None)
Schedule a new torrent for hash checking.
source code
 
_hashcheck_start(self)
Start hash checking the next torrent in the queue.
source code
 
hashcheck_callback(self)
Start another torrent's hash check now that the current one is complete.
source code
 
died(self, hash)
Inform the Output that the torrent has died.
source code
boolean
has_torrent(self, hash)
Determine whether there is a downloader for the torrent.
source code
 
was_stopped(self, hash)
Remove the torrent from the hash check queue, even if it's already happening.
source code
dictionary
pickle(self)
Save the current state of the downloads to a writable state.
source code
list of string
unpickle(self, data)
Restore the current state of the downloads.
source code
Instance Variables [hide private]
BT1.AptListener.AptListener aptlistener
the AptListener instance used to listen for incoming connections from Apt
dictionary blocked_files
the torrents in the torrent directory that will not be run
dictionary config
the configuration parameters
ConfigDir.ConfigDir configdir
the configuration and cache directory manager
int counter
the number of torrents that have been started so far
threading.Event doneflag
flag to indicate all is to be stopped
dictionary downloads
the currently running downloaders, keys are info hashes
dictionary file_cache
the files found in the parsing of the torrent directory
ServerPortHandler.MultiHandler handler
the multi torrent port listener used to handle connections
string hashcheck_current
the info hash of the torrent currently being hash checked
list of string hashcheck_queue
the list of torrent info hashes waiting to be hash checked
int listen_port
the port to listen on for incoming torrent connections
RateLimiter.RateLimiter ratelimiter
the limiter used to cap the maximum upload rate
RawServer.RawServer rawserver
the Server instance to use for the downloads
dictionary torrent_cache
the cache of known torrents, keys are info hashes
list of string torrent_list
the list of running torrents' info hashes
Method Details [hide private]

__init__(self, config, configdir)
(Constructor)

source code 
Initialize the instance.
Parameters:
  • config (dictionary) - the configuration parameters
  • configdir (ConfigDir.ConfigDir) - the configuration and cache directory manager

run(self)

source code 
Run the mutliple downloads.
Returns: boolean
whether the server ended normally

gather_stats(self)

source code 

Gather the statistics for the currently running torrents.

Returns a list, one per running torrent, of tuples:

(string, string, string, string, int, int, string, float, float, float, long, long, long, float, string)

Which are the name, info hash, current status, progress report, number of peers, number of seeds, seed message, number of distributed copies, upload rate, download rate, amount uploaded, amount downloaded, total length, time remaining, and latest error message.
Returns: list
various statistics for the running torrents

remove(self, hash)

source code 
Stop and remove a running torrent.
Parameters:
  • hash (string) - the info hash of the torrent

add(self, hash, data, save_cache=True)

source code 
Start a new torrent running, or add the data to the current one.
Parameters:
  • hash (string) - the info hash of the torrent
  • data (dictionary) - various info about the torrent, including the metainfo
  • save_cache (boolean) - whether to save the torrent metainfo to the cache

start(self, hash)

source code 
Start a cached torrent.
Parameters:
  • hash (string) - the info hash of the torrent to start

saveAs(self, hash, name, saveas, isdir)

source code 
Determine the location to save the torrent in.
Parameters:
  • hash (string) - the info hash of the torrent
  • name (string) - the name from the torrent's metainfo
  • saveas (string) - the user specified location to save to
  • isdir (boolean) - whether the torrent needs a directory
Returns: string
the location to save the torrent in

find_file(self, mirror, path)

source code 

Find which running torrent has the file.

Checks the metainfo of each torrent in the cache to find one that has a file whose 'path' matches the given file's path.
Parameters:
  • mirror (string) - mirror name to find the download in
  • path (list of string) - the path of the file to find
Returns: download_bt1.BT1Download, int
the running torrent that contains the file and the file's number (or None if no running torrents contain the file)

hashchecksched(self, hash=None)

source code 
Schedule a new torrent for hash checking.
Parameters:
  • hash (string) - the info hash of the torrent to schedule (optional, default is to start the next torrent in the queue)

died(self, hash)

source code 
Inform the Output that the torrent has died.
Parameters:
  • hash (string) - the info hash of the torrent

has_torrent(self, hash)

source code 
Determine whether there is a downloader for the torrent.
Parameters:
  • hash (string) - the info hash of the torrent
Returns: boolean
whether the torrent is in the cache of known torrents

was_stopped(self, hash)

source code 
Remove the torrent from the hash check queue, even if it's already happening.
Parameters:
  • hash (string) - the info hash of the torrent

pickle(self)

source code 

Save the current state of the downloads to a writable state.

Pickled data format:
   d['torrent cache'] = {info hash: C{dictionary}, ...}
               Contains the cached data for all running torrents, keys are 
               the torrent's info hash, and the data is all the data
               saved in L{torrent_cache}. There is also a new key added
               "paused" for torrent's that were running but paused.
Returns: dictionary
the saved state of the current downloads

unpickle(self, data)

source code 

Restore the current state of the downloads.

Reads the list of previosuly running torrents, loads their metainfo from the cache and starts the downloads running. Also pauses the download if it was previously paused.
Parameters:
  • data (dictionary) - the saved state of the previously running downloads downloads
Returns: list of string
the list of torrent hashes that are still running