Package DebTorrent :: Package BT1 :: Module AptListener :: Class AptListener
[hide private]
[frames] | no frames]

Class AptListener

source code

Listen for Apt requests to download files.

Instance Methods [hide private]
 
__init__(self, handler, config, rawserver)
Initialize the instance.
source code
 
enqueue_request(self, connection, file, downloader, file_num, httpreq, pieces_needed)
Add a new download request to the queue of those waiting for pieces.
source code
 
process_queue(self)
Process the queue of waiting requests.
source code
(int, string, dictionary, string)
get_infopage(self)
Format the info page to display for normal browsers.
source code
 
get_meow(self) source code
(int, string, dictionary, string)
get_cached(self, connection, path, headers, httpreq)
Proxy the (possibly cached) download of a file from a mirror.
source code
 
get_cached_callback(self, path, r)
Return the newly cached file to the waiting connection.
source code
(int, string, dictionary, string)
get_package(self, connection, path, httpreq)
Download a package file from a torrent.
source code
 
answer_package(self, connection, file, d, f, httpreq)
Send the newly downloaded package file to the requester.
source code
 
start_torrent(self, response, name, path)
Start the torrent running.
source code
(int, string, dictionary, string)
get_file(self, hash)
Get the metainfo file for a torrent.
source code
(int, string, dictionary, string)
get(self, connection, path, headers, httpreq)
Respond to a GET request.
source code
 
read_ip_lists(self)
Periodically parse the allowed and banned IPs lists.
source code
Instance Variables [hide private]
DebTorrent.HTTPCache.HTTPCache Cache
the cache of downloaded files
Filter.Filter Filter
not used
boolean allow_get
whether downloading of torrent files is allowed
DebTorrent.subnetparse.IP_List allowed_IPs
the IPs that are allowed to connect, or None if all are
int allowed_ip_mtime
the last modification time of the allowed IPs file
DebTorrent.iprangeparse.IP_List banned_IPs
the IPs that are not allowed to connect
int banned_ip_mtime
the last modification time of the banned IPs file
dictionary cache_waiting
the pending HTTP get requests that are waiting for download from the cache.
dictionary config
the configuration parameters
string favicon
file containing x-icon data
DebTorrent.launchmanycore.LaunchMany handler
the download handler to use
int parse_ip_files
seconds between reloading of the lists of allowed and banned IPs
DebTorrent.RawServer rawserver
the server to use for scheduling
dictionary request_queue
the pending HTTP package requests that are waiting for download.
dictionary state
the current state information for the tracking
boolean uq_broken
whether URL quoting of '+' is broken
Method Details [hide private]

__init__(self, handler, config, rawserver)
(Constructor)

source code 
Initialize the instance.
Parameters:

enqueue_request(self, connection, file, downloader, file_num, httpreq, pieces_needed)

source code 
Add a new download request to the queue of those waiting for pieces.
Parameters:

get_infopage(self)

source code 

Format the info page to display for normal browsers.

Formats the currently downloading torrents into a table in human-readable format to display in a browser window.
Returns: (int, string, dictionary, string)
the HTTP status code, status message, headers, and message body

get_cached(self, connection, path, headers, httpreq)

source code 
Proxy the (possibly cached) download of a file from a mirror.
Parameters:
Returns: (int, string, dictionary, string)
the HTTP status code, status message, headers, and downloaded file (or None if the file is being downloaded)

get_cached_callback(self, path, r)

source code 
Return the newly cached file to the waiting connection.
Parameters:
  • path (list of string) - the path of the file to download, starting with the mirror name
  • r ((int, string, dictionary, string)) - the HTTP status code, status message, headers, and cached data

get_package(self, connection, path, httpreq)

source code 
Download a package file from a torrent.
Parameters:
Returns: (int, string, dictionary, string)
the HTTP status code, status message, headers, and package data (or None if the package is to be downloaded)

answer_package(self, connection, file, d, f, httpreq)

source code 
Send the newly downloaded package file to the requester.
Parameters:

start_torrent(self, response, name, path)

source code 
Start the torrent running.
Parameters:
  • response (dictionary) - the metainfo dictionary to use for the torrent
  • name (string) - the name to use for the torrent
  • path (list of string) - the path of the Packages file, starting with the mirror name

get_file(self, hash)

source code 
Get the metainfo file for a torrent.
Parameters:
  • hash (string) - the infohash of the torrent to get the metainfo of
Returns: (int, string, dictionary, string)
the HTTP status code, status message, headers, and bencoded metainfo file

get(self, connection, path, headers, httpreq)

source code 

Respond to a GET request.

Process a GET request from APT/browser/other. Process the request, calling the helper functions above if needed. Return the response to be returned to the requester.
Parameters:
Returns: (int, string, dictionary, string)
the HTTP status code, status message, headers, and message body

Instance Variable Details [hide private]

cache_waiting

the pending HTTP get requests that are waiting for download from the cache. Keys are strings that are the path being requested, values are lists of DebTorrent.HTTPHandler.HTTPConnection objects which are the requests that are pending for that path.
Type:
dictionary

request_queue

the pending HTTP package requests that are waiting for download. Keys are the file names (including mirror) requested, values are dictionaries with keys of DebTorrent.HTTPHandler.HTTPConnection objects and values of (DebTorrent.download_bt1.BT1Download, int, DebTorrent.HTTPHandler.HTTPRequest, list of int, float) which are the torrent downloader, file index, HTTP request object to answer, list of pieces needed, and the time of the original request.
Type:
dictionary