Commit 8729ec9c authored by Cresson Remi's avatar Cresson Remi
Browse files

WIP: S2 download

1 merge request!12ENH: S2A and S3A support
Showing with 20 additions and 0 deletions
+20 -0
......@@ -56,6 +56,26 @@ def curl_url(url, postdata, verbose=False, fp=None, header=['Accept:application/
if verbose:
c.setopt(pycurl.VERBOSE, 1)
if fp is not None:
progress_bar = None
last_download_d = 0
def _status(download_t, download_d, upload_t, upload_d):
"""
callback function for c.XFERINFOFUNCTION
https://stackoverflow.com/questions/19724222/pycurl-attachments-and-progress-functions
:param download_t:
:param download_d:
:param upload_t:
:param upload_d:
:return:
"""
nonlocal progress_bar, last_download_d
if not progress_bar:
progress_bar = tqdm.tqdm(total=download_t)
progress_bar.update(download_d - last_download_d)
last_download_d = download_d
c.setopt(c.NOPROGRESS, False)
c.setopt(c.XFERINFOFUNCTION, _status)
c.setopt(pycurl.WRITEDATA, fp)
else:
c.setopt(pycurl.WRITEFUNCTION, storage.write)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment