cli: using PROGRESSFUNCTION before libcurl 7.32.0 in download_file
This commit is contained in:
parent
5df1e3e6e6
commit
ba087236dd
2 changed files with 36 additions and 2 deletions
|
|
@ -487,8 +487,15 @@ def download_file(url, relpath, quiet=False, noprogress=False, size=None, num=No
|
|||
c.setopt(pycurl.FOLLOWLOCATION, 1)
|
||||
c.setopt(c.WRITEDATA, open(relpath, 'wb'))
|
||||
if not (quiet or noprogress):
|
||||
c.setopt(c.NOPROGRESS, False)
|
||||
c.setopt(c.XFERINFOFUNCTION, _download_progress)
|
||||
proc_func_param = getattr(c, 'XFERINFOFUNCTION', None)
|
||||
if proc_func_param is None:
|
||||
proc_func_param = getattr(c, 'PROGRESSFUNCTION', None)
|
||||
if proc_func_param is not None:
|
||||
c.setopt(c.NOPROGRESS, False)
|
||||
c.setopt(proc_func_param, _download_progress)
|
||||
else:
|
||||
c.close()
|
||||
error(_('Error: XFERINFOFUNCTION and PROGRESSFUNCTION are not supported by pyCurl. Quit download progress'))
|
||||
c.perform()
|
||||
c.close()
|
||||
if not (quiet or noprogress):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue