Package zeroinstall :: Package injector :: Module download :: Class Download
[frames] | no frames]

Class Download

source code

object --+
         |
        Download

A download of a single resource to a temporary file.

Instance Methods
 
__init__(self, url, hint=None, modification_time=None, expected_size=None, auto_delete=True)
Create a new download object.
source code
 
abort(self)
Signal the current download to stop.
source code
int | None
get_current_fraction(self)
Returns the current fraction of this download that has been fetched (from 0 to 1), or None if the total size isn't known.
source code
int
get_bytes_downloaded_so_far(self)
Get the download progress.
source code
str
get_next_mirror_url(self)
Return an alternative download URL to try, or None if we're out of options.
source code
 
__str__(self)
str(x)
source code

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __subclasshook__

Instance Variables
bool aborted_by_user
whether anyone has called abort
tasks.Blocker downloaded
triggered when the download ends (on success or failure)
int | None expected_size
the expected final size of the file
object hint
hint passed by and for caller
str | None mirror
an alternative URL to try if this download fails
(download_fetching | download_failed | download_complete) status
the status of the download
file tempfile
the file storing the downloaded data
bool unmodified
whether the resource was not modified since the modification_time given at construction
str url
the URL of the resource being fetched
Properties

Inherited from object: __class__

Method Details

__init__(self, url, hint=None, modification_time=None, expected_size=None, auto_delete=True)
(Constructor)

source code 

Create a new download object.

Parameters:
  • url (str) - the resource to download
  • hint - object with which this download is associated (an optional hint for the GUI)
  • modification_time (str | None) - string with HTTP date that indicates last modification time. The resource will not be downloaded if it was not modified since that date.
  • auto_delete (bool)
Overrides: object.__init__

Postcondition: status == download_fetching.

abort(self)

source code 

Signal the current download to stop.

Postcondition: aborted_by_user

get_current_fraction(self)

source code 

Returns the current fraction of this download that has been fetched (from 0 to 1), or None if the total size isn't known.

Returns: int | None
fraction downloaded

get_bytes_downloaded_so_far(self)

source code 

Get the download progress. Will be zero if the download has not yet started.

Returns: int

__str__(self)
(Informal representation operator)

source code 

str(x)

Overrides: object.__str__
(inherited documentation)