bitween.components.models package

Submodules

bitween.components.models.addresses module

class bitween.components.models.addresses.Addresses(ports=None, ip_v4=None, ip_v6=None)[source]
fetch_addresses()[source]

fetch IPv4 and IPv6 Addresses

IPv4 will be fetched from a random server vis ipgetter, so this could take time. IPv6 will be read from system.

Returns:
has_ip_v4()[source]
has_ip_v6()[source]

bitween.components.models.config module

global configuration of the application.

loading is triggered by bitweend at startup

bitween.components.models.contact_shares module

class bitween.components.models.contact_shares.ContactShares[source]

this class holds all the discovered UserShares

add_address(jid, resource, address, port)[source]

add Address and Port to Resource resource of jid

Parameters:
  • jid
  • resource
  • address
  • port
Returns:

add_share(jid, resource, hash, name='', size=0, files=None)[source]

Add a Share to a JIDs Resource

Parameters:
  • jid
  • resource
  • hash (str) – SHA1 Hash
  • name (str) – name of the share
  • size (int) – size of the share in bytes
  • files (list of str) – list of files in the Share
Returns:

add_share_by_info(jid, resource, info)[source]

add a share by torrent info

Parameters:
  • jid
  • resource
  • info – dict from torrent_handles.get_shares()
Returns:

clear(jid, resource=None)[source]

clear whole User with JID jid. If resource != None, clear resource of the JID

Parameters:
  • jid
  • resource
Returns:

clear_addresses(jid, resource)[source]

clear Addresses of JIDs Resource

Parameters:
  • jid
  • resource
Returns:

clear_shares(jid, resource)[source]

clear Shares of JIDs Resource

Parameters:
  • jid
  • resource
Returns:

get_ipv4_addresses(jid, resource)[source]

return all IPv4 Addresses of JIDs Resource resource

Parameters:
  • jid
  • resource
Returns:

list of IPv4 Addresses

get_ipv6_addresses(jid, resource)[source]

return all IPv6 Addresses of JIDs Resource resource

Parameters:
  • jid
  • resource
Returns:

get_resource(jid, resource)[source]

get resource dict of user with JID jid

Parameters:
  • jid
  • resource
Returns:

get_user(jid)[source]

get user dict

Parameters:jid
Returns:dictionary with all data for user with jid
hashes

returns a dict with all hashes and a list of ip_port tuples for each hash

Returns:

bitween.components.models.torrent_handles module

class bitween.components.models.torrent_handles.Handles[source]

holds a reference to the handles and some values for other threads

this is managed by the bt thread

append(item)[source]

append a handle to the handle list

Parameters:item
Returns:
get_shares()[source]

get a list of own shares

[{
    "files": [], # list of files
    "total_size": 0, # total size in bytes
    "name": "", # name of the torrent
    "hash": "", # sha hash
    "done": 0 # bytes done
}]
Returns:
remove(item)[source]

remove a handle from the handle list

Parameters:item
Returns:

Module contents