Package Tribler :: Package Core :: Module DownloadConfig :: Class DownloadConfigInterface

Class DownloadConfigInterface

Known Subclasses:

(key,value) pair config of per-torrent runtime parameters, e.g. destdir, file-allocation policy, etc. Also options to advocate torrent, e.g. register in DHT, advertise via Buddycast. Use DownloadStartupConfig to manipulate download configs before download startup time. This is just a parent class. cf. libtorrent torrent_handle
Instance Methods
 
__init__(self, dlconfig=None)
 
set_dest_dir(self, path)
Sets the directory where to save this Download.
 
get_dest_dir(self)
Gets the directory where to save this Download.
 
set_video_event_callback(self, usercallback)
Download the torrent in Video-On-Demand mode or as live stream.
 
set_video_events(self, events=[])
Sets which events will be supported with the usercallback set by set_video_event_callback.
 
set_video_source(self, videosource, authconfig=None)
Provides the live video source for this torrent from an external source.
 
set_video_ratelimit(self, ratelimit)
Sets a limit on the speed at which the video stream is to be read.
 
set_mode(self, mode)
Sets the mode of this download.
 
set_live_aux_seeders(self, seeders)
Sets a number of live seeders, auxiliary servers that get high priority at the source server to distribute its content to others.
 
get_mode(self)
Returns the mode of this download.
 
get_video_event_callback(self)
Returns the function that was passed to set_video_event_callback().
 
get_video_events(self)
Returns the function that was passed to set_video_events().
 
get_video_source(self)
Returns the object that was passed to set_video_source().
 
get_video_ratelimit(self)
Returns the speed at which the video stream is read (bps).
 
get_live_aux_seeders(self)
Returns the aux.
 
set_selected_files(self, files)
Select which files in the torrent to download.
 
get_selected_files(self)
Returns the list of files selected for download.
 
set_max_speed(self, direct, speed)
Sets the maximum upload or download speed for this Download.
 
get_max_speed(self, direct)
Returns the configured maximum speed.
 
set_max_conns_to_initiate(self, nconns)
Sets the maximum number of connections to initiate for this Download.
 
get_max_conns_to_initiate(self)
Returns the configured maximum number of connections to initiate.
 
set_max_conns(self, nconns)
Sets the maximum number of connections to connections for this Download.
 
get_max_conns(self)
Returns the configured maximum number of connections.
 
get_coopdl_role(self)
Returns the role which the download plays in a cooperative download,
- COOPDL_ROLE_COORDINATOR: other peers help this download
- COOPDL_ROLE_HELPER: this download helps another peer download faster.
 
set_coopdl_coordinator_permid(self, permid)
Calling this method makes this download a helper in a cooperative download, helping the peer identified by the specified permid.
 
get_coopdl_coordinator_permid(self)
Returns the configured coordinator permid.
 
set_max_uploads(self, value)
Set the maximum number of uploads to allow at once.
 
get_max_uploads(self)
Returns the maximum number of uploads.
 
set_keepalive_interval(self, value)
Set the number of seconds to pause between sending keepalives.
 
get_keepalive_interval(self)
Returns the keepalive interval.
 
set_download_slice_size(self, value)
Set how many bytes to query for per request.
 
get_download_slice_size(self)
Returns the number of bytes to query per request.
 
set_upload_unit_size(self, value)
When limiting upload rate, how many bytes to send at a time.
 
get_upload_unit_size(self)
Returns the set upload unit size.
 
set_request_backlog(self, value)
Maximum number of requests to keep in a single pipe at once.
 
get_request_backlog(self)
Returns the request backlog.
 
set_max_message_length(self, value)
Maximum message-length prefix to accept over the wire - larger values get the connection dropped.
 
get_max_message_length(self)
Returns the maximum message length that is accepted.
 
set_max_slice_length(self, value)
Maximum length slice to send to peers, larger requests are ignored.
 
get_max_slice_length(self)
Returns the maximum slice length that is accepted.
 
set_max_rate_period(self, value)
Maximum amount of time to guess the current rate estimate.
 
get_max_rate_period(self)
Returns the maximum rate period.
 
set_upload_rate_fudge(self, value)
Time equivalent of writing to kernel-level TCP buffer, for rate adjustment.
 
get_upload_rate_fudge(self)
Returns the upload rate fudge.
 
set_tcp_ack_fudge(self, value)
How much TCP ACK download overhead to add to upload rate calculations.
 
get_tcp_ack_fudge(self)
Returns the TCP ACK fudge.
 
set_rerequest_interval(self, value)
Time to wait between requesting more peers from tracker.
 
get_rerequest_interval(self)
Returns the tracker re-request interval.
 
set_min_peers(self, value)
Minimum number of peers to not do rerequesting.
 
get_min_peers(self)
Returns the minimum number of peers.
 
set_http_timeout(self, value)
Number of seconds to wait before assuming that a HTTP connection has timed out.
 
get_http_timeout(self)
Returns the HTTP timeout.
 
set_check_hashes(self, value)
Whether to check the integrit of the data on disk using the hashes from the torrent definition.
 
get_check_hashes(self)
Returns whether to check hashes.
 
set_alloc_type(self, value)
Set disk-allocation type:...
 
get_alloc_type(self)
Returns the disk-allocation policy.
 
set_alloc_rate(self, value)
Set the rate to allocate space at using background allocation (DISKALLOC_BACKGROUND).
 
get_alloc_rate(self)
Returns the background disk-allocation rate.
 
set_buffer_reads(self, value)
Whether to buffer disk reads.
 
get_buffer_reads(self)
Returns whether to buffer reads.
 
set_write_buffer_size(self, value)
The maximum amount of space to use for buffering disk writes (0 = disabled).
 
get_write_buffer_size(self)
Returns the write buffer size.
 
set_breakup_seed_bitfield(self, value)
Whether to send an incomplete BITFIELD and then fills with HAVE messages, in order to get around intellectually-challenged Internet Service Provider manipulation.
 
get_breakup_seed_bitfield(self)
Returns whether to send an incomplete BITFIELD message.
 
set_snub_time(self, value)
Seconds to wait for data to come in over a connection before assuming it's semi-permanently choked.
 
get_snub_time(self)
Returns the snub time.
 
set_rarest_first_cutoff(self, value)
Number of downloads at which to switch from random to rarest first.
 
get_rarest_first_cutoff(self)
Returns the rarest first cutoff.
 
set_rarest_first_priority_cutoff(self, value)
The number of peers which need to have a piece before other partials take priority over rarest first policy.
 
get_rarest_first_priority_cutoff(self)
Returns the rarest-first priority cutoff.
 
set_min_uploads(self, value)
The number of uploads to fill out to with extra optimistic unchokes.
 
get_min_uploads(self)
Returns the minimum number of uploads.
 
set_max_files_open(self, value)
The maximum number of files to keep open at a time, 0 means no limit.
 
get_max_files_open(self)
Returns the maximum number of open files.
 
set_round_robin_period(self, value)
The number of seconds between the client's switching upload targets.
 
get_round_robin_period(self)
Returns the round-robin period.
 
set_super_seeder(self, value)
whether to use special upload-efficiency-maximizing routines (only for dedicated seeds).
 
get_super_seeder(self)
Returns hether super seeding is enabled.
 
set_security(self, value)
Whether to enable extra security features intended to prevent abuse, such as checking for multiple connections from the same IP address.
 
get_security(self)
Returns the security setting.
 
set_auto_kick(self, value)
Whether to automatically kick/ban peers that send bad data.
 
get_auto_kick(self)
Returns whether autokick is enabled.
 
set_double_check_writes(self, value)
Whether to double-check data being written to the disk for errors (may increase CPU load).
 
get_double_check_writes(self)
Returns whether double-checking on writes is enabled.
 
set_triple_check_writes(self, value)
Whether to thoroughly check data being written to the disk (may slow disk access).
 
get_triple_check_writes(self)
Returns whether triple-checking on writes is enabled.
 
set_lock_files(self, value)
Whether to lock files the Download is working with.
 
get_lock_files(self)
Returns whether locking of files is enabled.
 
set_lock_while_reading(self, value)
Whether to lock access to files being read.
 
get_lock_while_reading(self)
Returns whether locking of files for reading is enabled.
 
set_auto_flush(self, value)
Minutes between automatic flushes to disk (0 = disabled).
 
get_auto_flush(self)
Returns the auto flush interval.
 
set_exclude_ips(self, value)
Set a list of IP addresses to be excluded.
 
get_exclude_ips(self)
Returns the list of excluded IP addresses.
 
set_ut_pex_max_addrs_from_peer(self, value)
Maximum number of addresses to accept from peer via the uTorrent ...
 
get_ut_pex_max_addrs_from_peer(self)
Returns the maximum number of IP addresses to accept from a peer via ut_pex.
Method Details

set_dest_dir(self, path)

 
Sets the directory where to save this Download.
Parameters:
  • path - A path of a directory.

set_video_event_callback(self, usercallback)

 
Download the torrent in Video-On-Demand mode or as live stream. When a playback event occurs, the usercallback function will be called, with the following list of arguments:
    Download,event,params
In which event is a string, and params a dictionary. The following events are supported:
VODEVENT_START:
    The params dictionary will contain the fields

        mimetype,stream,filename,length

    If the filename is set, the video can be read from there. If not,
    the video can be read from the stream, which is a file-like object 
    supporting the read(),seek(), and close() operations. The MIME type
    of the video is given by "mimetype", the length of the stream in
    bytes by "length" which may be None if the length is unknown (e.g.
    when live streaming).

    To fetch a specific file from a multi-file torrent, use the 
    set_selected_files() method. This method sets the mode to DLMODE_VOD 

VODEVENT_PAUSE:
    The download engine would like video playback to be paused as the
    data is not coming in fast enough / the data due is not available
    yet.
    
    The params dictionary contains the fields
    
        autoresume
        
    "autoresume" indicates whether or not the Core will generate
    a VODEVENT_RESUME when it is ready again, or that this is left
    to the core user.
            
VODEVENT_RESUME:
    The download engine would like video playback to resume.
The usercallback should ignore events it does not support. The usercallback will be called by a popup thread which can be used indefinitely (within reason) by the higher level code.
Parameters:
  • usercallback - A function with the above signature.

set_video_events(self, events=[])

 
Sets which events will be supported with the usercallback set by set_video_event_callback. Supporting the VODEVENT_START event is mandatory, and can therefore be omitted from the list.
Parameters:
  • events - A list of supported VODEVENT_* events.

set_video_source(self, videosource, authconfig=None)

 
Provides the live video source for this torrent from an external source.
Parameters:
  • videosource - A file-like object providing the live video stream (i.e., supports read() and close())
  • authconfig - The key information for source authentication of packets. See LiveSourceAuthConfig and TorrentDef.create_live_torrent()

set_video_ratelimit(self, ratelimit)

 
Sets a limit on the speed at which the video stream is to be read. Useful when creating a live stream from file or any other faster-than-live data stream.
Parameters:
  • ratelimit - The maximum speed at which to read from the stream (bps)

set_mode(self, mode)

 
Sets the mode of this download.
Parameters:
  • mode - DLMODE_NORMAL/DLMODE_VOD

set_live_aux_seeders(self, seeders)

 
Sets a number of live seeders, auxiliary servers that get high priority at the source server to distribute its content to others.
Parameters:
  • seeders - A list of [IP address,port] lists.

get_mode(self)

 
Returns the mode of this download.
Returns:
DLMODE_NORMAL/DLMODE_VOD

get_video_event_callback(self)

 
Returns the function that was passed to set_video_event_callback().
Returns:
A function.

get_video_events(self)

 
Returns the function that was passed to set_video_events().
Returns:
A list of events.

get_video_source(self)

 
Returns the object that was passed to set_video_source().
Returns:
A file-like object.

get_video_ratelimit(self)

 
Returns the speed at which the video stream is read (bps).
Returns:
An integer.

get_live_aux_seeders(self)

 
Returns the aux. live seeders set.
Returns:
A list of [IP address,port] lists.

set_selected_files(self, files)

 
Select which files in the torrent to download. The filenames must be the names as they appear in the torrent def. Trivially, when the torrent contains a file 'sjaak.avi' the files parameter must be 'sjaak.avi'. When the torrent contains multiple files and is named 'filecollection', the files parameter must be os.path.join('filecollection','sjaak.avi')
Parameters:
  • files - Can be a single filename or a list of filenames (e.g. ['harry.avi','sjaak.avi']).

get_selected_files(self)

 
Returns the list of files selected for download.
Returns:
A list of strings.

set_max_speed(self, direct, speed)

 
Sets the maximum upload or download speed for this Download.
Parameters:
  • direct - The direction (UPLOAD/DOWNLOAD)
  • speed - The speed in KB/s.

get_max_speed(self, direct)

 
Returns the configured maximum speed. Returns the speed in KB/s.

set_max_conns_to_initiate(self, nconns)

 
Sets the maximum number of connections to initiate for this Download.
Parameters:
  • nconns - A number of connections.

get_max_conns_to_initiate(self)

 
Returns the configured maximum number of connections to initiate.
Returns:
A number of connections.

set_max_conns(self, nconns)

 
Sets the maximum number of connections to connections for this Download.
Parameters:
  • nconns - A number of connections.

get_max_conns(self)

 
Returns the configured maximum number of connections.
Returns:
A number of connections.

get_coopdl_role(self)

 
Returns the role which the download plays in a cooperative download,
- COOPDL_ROLE_COORDINATOR: other peers help this download
- COOPDL_ROLE_HELPER: this download helps another peer download faster.
The default is coordinator, and it is set to helper by the set_coopdl_coordinator_permid() method.

set_coopdl_coordinator_permid(self, permid)

 
Calling this method makes this download a helper in a cooperative download, helping the peer identified by the specified permid. This peer acts as coordinator, telling this download which parts of the content to download.
Parameters:
  • permid - A PermID.

get_coopdl_coordinator_permid(self)

 
Returns the configured coordinator permid.
Returns:
A PermID

set_max_uploads(self, value)

 
Set the maximum number of uploads to allow at once.
Parameters:
  • value - A number.

get_max_uploads(self)

 
Returns the maximum number of uploads.
Returns:
A number.

set_keepalive_interval(self, value)

 
Set the number of seconds to pause between sending keepalives.
Parameters:
  • value - An interval

get_keepalive_interval(self)

 
Returns the keepalive interval.
Returns:
A number of seconds.

set_download_slice_size(self, value)

 
Set how many bytes to query for per request.
Parameters:
  • value - A number of bytes.

get_download_slice_size(self)

 
Returns the number of bytes to query per request.
Returns:
A number of bytes.

set_upload_unit_size(self, value)

 
When limiting upload rate, how many bytes to send at a time.
Parameters:
  • value - A number of bytes.

get_upload_unit_size(self)

 
Returns the set upload unit size.
Returns:
A number of bytes.

set_request_backlog(self, value)

 
Maximum number of requests to keep in a single pipe at once.
Parameters:
  • value - A number of requests.

get_request_backlog(self)

 
Returns the request backlog.
Returns:
A number of requests.

set_max_message_length(self, value)

 
Maximum message-length prefix to accept over the wire - larger values get the connection dropped.
Parameters:
  • value - A number of bytes.

get_max_message_length(self)

 
Returns the maximum message length that is accepted.
Returns:
A number of bytes.

set_max_slice_length(self, value)

 
Maximum length slice to send to peers, larger requests are ignored.
Parameters:
  • value - A number of bytes.

get_max_slice_length(self)

 
Returns the maximum slice length that is accepted.
Returns:
A number of bytes.

set_max_rate_period(self, value)

 
Maximum amount of time to guess the current rate estimate.
Parameters:
  • value - A number of seconds.

get_max_rate_period(self)

 
Returns the maximum rate period.
Returns:
A number of seconds.

set_upload_rate_fudge(self, value)

 
Time equivalent of writing to kernel-level TCP buffer, for rate adjustment.
Parameters:
  • value - A number of seconds.

get_upload_rate_fudge(self)

 
Returns the upload rate fudge.
Returns:
A number of seconds.

set_tcp_ack_fudge(self, value)

 
How much TCP ACK download overhead to add to upload rate calculations. I.e. when a message is received we add X percent of this message to our upload rate to account for TCP ACKs that were sent during the reception process. (0 = disabled)
Parameters:
  • value - A percentage

get_tcp_ack_fudge(self)

 
Returns the TCP ACK fudge.
Returns:
A percentage.

set_rerequest_interval(self, value)

 
Time to wait between requesting more peers from tracker.
Parameters:
  • value - An interval in seconds.

get_rerequest_interval(self)

 
Returns the tracker re-request interval.
Returns:
A number of seconds.

set_min_peers(self, value)

 
Minimum number of peers to not do rerequesting.
Parameters:
  • value - A number of peers.

get_min_peers(self)

 
Returns the minimum number of peers.
Returns:
A number of peers.

set_http_timeout(self, value)

 
Number of seconds to wait before assuming that a HTTP connection has timed out.
Parameters:
  • value - A number of seconds.

get_http_timeout(self)

 
Returns the HTTP timeout.
Returns:
A number of seconds.

set_check_hashes(self, value)

 
Whether to check the integrit of the data on disk using the hashes from the torrent definition.
Parameters:
  • value - Boolean

get_check_hashes(self)

 
Returns whether to check hashes.
Returns:
Boolean.

set_alloc_type(self, value)

 
Set disk-allocation type:
* DISKALLOC_NORMAL:  Allocates space as data is received
* DISKALLOC_BACKGROUND: Also adds space in the background
* DISKALLOC_PREALLOCATE: Reserves space up front (slow)
* DISKALLOC_SPARSE: Is only for filesystems that support it by default 
  (UNIX)
Parameters:
  • value - A DISKALLOC_* policy.

get_alloc_type(self)

 
Returns the disk-allocation policy.
Returns:
DISKALLOC_*

set_alloc_rate(self, value)

 
Set the rate to allocate space at using background allocation (DISKALLOC_BACKGROUND).
Parameters:
  • value - A rate in MB/s.

get_alloc_rate(self)

 
Returns the background disk-allocation rate.
Returns:
A number of megabytes per second.

set_buffer_reads(self, value)

 
Whether to buffer disk reads.
Parameters:
  • value - Boolean

get_buffer_reads(self)

 
Returns whether to buffer reads.
Returns:
Boolean.

set_write_buffer_size(self, value)

 
The maximum amount of space to use for buffering disk writes (0 = disabled).
Parameters:
  • value - A buffer size in megabytes.

get_write_buffer_size(self)

 
Returns the write buffer size.
Returns:
A number of megabytes.

set_breakup_seed_bitfield(self, value)

 
Whether to send an incomplete BITFIELD and then fills with HAVE messages, in order to get around intellectually-challenged Internet Service Provider manipulation.
Parameters:
  • value - Boolean

get_breakup_seed_bitfield(self)

 
Returns whether to send an incomplete BITFIELD message.
Returns:
Boolean.

set_snub_time(self, value)

 
Seconds to wait for data to come in over a connection before assuming it's semi-permanently choked.
Parameters:
  • value - A number of seconds.

get_snub_time(self)

 
Returns the snub time.
Returns:
A number of seconds.

set_rarest_first_cutoff(self, value)

 
Number of downloads at which to switch from random to rarest first.
Parameters:
  • value - A number of downloads.

get_rarest_first_cutoff(self)

 
Returns the rarest first cutoff.
Returns:
A number of downloads.

set_rarest_first_priority_cutoff(self, value)

 
The number of peers which need to have a piece before other partials take priority over rarest first policy.
Parameters:
  • value - A number of peers.

get_rarest_first_priority_cutoff(self)

 
Returns the rarest-first priority cutoff.
Returns:
A number of peers.

set_min_uploads(self, value)

 
The number of uploads to fill out to with extra optimistic unchokes.
Parameters:
  • value - A number of uploads.

get_min_uploads(self)

 
Returns the minimum number of uploads.
Returns:
A number of uploads.

set_max_files_open(self, value)

 
The maximum number of files to keep open at a time, 0 means no limit.
Parameters:
  • value - A number of files.

get_max_files_open(self)

 
Returns the maximum number of open files.
Returns:
A number of files.

set_round_robin_period(self, value)

 
The number of seconds between the client's switching upload targets.
Parameters:
  • value - A number of seconds.

get_round_robin_period(self)

 
Returns the round-robin period.
Returns:
A number of seconds.

set_super_seeder(self, value)

 
whether to use special upload-efficiency-maximizing routines (only for dedicated seeds).
Parameters:
  • value - Boolean

get_super_seeder(self)

 
Returns hether super seeding is enabled.
Returns:
Boolean.

set_security(self, value)

 
Whether to enable extra security features intended to prevent abuse, such as checking for multiple connections from the same IP address.
Parameters:
  • value - Boolean

get_security(self)

 
Returns the security setting.
Returns:
Boolean.

set_auto_kick(self, value)

 
Whether to automatically kick/ban peers that send bad data.
Parameters:
  • value - Boolean

get_auto_kick(self)

 
Returns whether autokick is enabled.
Returns:
Boolean.

set_double_check_writes(self, value)

 
Whether to double-check data being written to the disk for errors (may increase CPU load).
Parameters:
  • value - Boolean

set_triple_check_writes(self, value)

 
Whether to thoroughly check data being written to the disk (may slow disk access).
Parameters:
  • value - Boolean

set_lock_files(self, value)

 
Whether to lock files the Download is working with.
Parameters:
  • value - Boolean

set_lock_while_reading(self, value)

 
Whether to lock access to files being read.
Parameters:
  • value - Boolean

get_lock_while_reading(self)

 
Returns whether locking of files for reading is enabled.
Returns:
Boolean.

set_auto_flush(self, value)

 
Minutes between automatic flushes to disk (0 = disabled).
Parameters:
  • value - A number of minutes.

get_auto_flush(self)

 
Returns the auto flush interval.
Returns:
A number of minutes.

set_exclude_ips(self, value)

 
Set a list of IP addresses to be excluded.
Parameters:
  • value - A list of IP addresses in dotted notation.

get_exclude_ips(self)

 
Returns the list of excluded IP addresses.
Returns:
A list of strings.

set_ut_pex_max_addrs_from_peer(self, value)

 
Maximum number of addresses to accept from peer via the uTorrent Peer Exchange extension (0 = disable PEX)
Parameters:
  • value - A number of IP addresses.

get_ut_pex_max_addrs_from_peer(self)

 
Returns the maximum number of IP addresses to accept from a peer via ut_pex.
Returns:
A number of addresses.