efl.ecore.FileDownload Class

class efl.ecore.FileDownload(url, dst, completion_cb, progress_cb, *args, **kargs)

Bases: object

Download the given url to destination.

You must provide the full url, including ‘http://’, ‘ftp://’ or ‘file://’. If dst already exist it will not be overwritten and the function will fail. Ecore must be compiled with CURL to download using http and ftp protocols. The status param in the completion_cb will be 0 if the download end successfully or 1 in case of failure. The progress_cb must return 0 to continue normally or 1 to abort the download, note that no completion_cb will be called if you abort in this way. The constructor will raise a SystemError exception if the download don’t start, this can happen if you don’t have CURL compiled, if the destination exists or if the destination path don’t exist or isn’t writable.

The callback signatures are:

completion_cb(file, status, *args, **kargs)
progress_cb(file, dltotal, dlnow, uptotal, upnow, *args, **kargs): int

You can use the download feature as a class instance or you can use the legacy API.

Instance example:

from efl.ecore import FileDownload
dl = FileDownload("http://your_url", "/path/to/destination", None, None)
dl.abort()

Legacy example:

from efl import ecore
dl = ecore.file_download("http://your_url",
                         "/path/to/destination", None, None)
ecore.file_download_abort(dl)
Parameters
  • url – The complete url to download

  • dst – Where to download the file

  • completion_cb – A callback called on download complete

  • progress_cb – A callback called during the download operation

abort()

Abort the download and free internal resources.