bitween.components.bt package

Submodules

bitween.components.bt.client module

class bitween.components.bt.client.BitTorrentClient[source]

Bases: threading.Thread, bitween.components.pubsub.pubsub.Subscriber

BitTorrent Client Class

erase_all_torrents_from_db()[source]

removes all torrents from the session. called before the current torrents are going to be saved

Returns:
handle_alert(alert)[source]

Handle the libtorrent Alerts

Parameters:alert
Returns:
handle_queue()[source]

handle the IPC Message queue

Returns:
handles = None

—–alert categories—– error_notification peer_notification port_mapping_notification storage_notification tracker_notification debug_notification status_notification progress_notification ip_block_notification performance_warning stats_notification dht_notification rss_notification all_categories

on_add_hash(sha_hash, save_path)[source]

add a hash to the torrent session used to download new stuff.

after creation of the torrent all addresses that we have collected for the hash will be added

Parameters:
  • sha_hash (str) – hash of the torrent
  • save_path (str) – path to save
Returns:

on_del_torrent(hash)[source]

delete a torrent from the current session.

Parameters:handle
Returns:True, or False if not found
on_exit()[source]

trigger a safe shutdown of the thread :return:

on_generate_torrent(path)[source]

generates a handle for a file or folder

Parameters:path (str) – path to generate a handle for
Returns:
on_recheck_handles()[source]

recheck all handles, in case we could have new endpoints

should be triggered by the xmpp client if we got new shares

Returns:
resume()[source]

reads the sessionsettings from db file and sets them, reads handles from db file and adds them to the session.

Returns:
run()[source]

the run method of the thread.

this will process all the handles and messages in the input_queue. when safe_shutdown is called, it will trigger save_resume_data for every handle and wait for the alert with the resume_data. when every handle is deleted (after saving each resume_data), the session will be saved; were done and the thread will exit.

safe_shutdown()[source]

sets the end variable which tells the run method to jump out of the handling loop and trigger the save_handle for each handle.

Returns:
save(handle, resume_data)[source]

called when the “save_resume_data_alert” is recieved while shutdown. saves handle with resume_data to database

Parameters:
  • handle
  • resume_data
Returns:

setup_db()[source]

called by the init method. sets up the sqlite database if there is none.

Returns:
setup_settings()[source]

called by the init method. sets up some sane settings.

Returns:

bitween.components.bt.helpers module

bitween.components.bt.helpers.decode_string(s, encoding='utf8')[source]

from deluges core/torrentmanager.py

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

bitween.components.bt.helpers.utf8_encoded(s, encoding='utf8')[source]

from deluges core/torrentmanager.py

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

Module contents