This commit is contained in:
Casper da Costa-Luis
2019-08-10 14:19:38 +01:00
parent ca68eb4a4b
commit aed3451df9
2 changed files with 5 additions and 6 deletions
+2 -5
View File
@@ -2,7 +2,6 @@
from __future__ import print_function
import logging
from tqdm import tqdm
from threading import Lock
class Tqdm(tqdm):
@@ -14,8 +13,7 @@ class Tqdm(tqdm):
iterable=None,
disable=logging.getLogger(
__name__).getEffectiveLevel() >= logging.CRITICAL,
ascii=None, # TODO: True?
bytes=False,
bytes=False, # pylint: disable=W0622
desc_truncate=None,
**kwargs):
"""
@@ -34,7 +32,6 @@ class Tqdm(tqdm):
super(Tqdm, self).__init__(
iterable=iterable,
disable=disable,
ascii=ascii,
**kwargs)
# self.set_lock(Lock())
@@ -49,7 +46,7 @@ class Tqdm(tqdm):
def update_to(self, current, total=None):
if total:
self.total = total
self.total = total # pylint: disable=W0613
self.update(current - self.n)
@classmethod
+3 -1
View File
@@ -29,13 +29,15 @@ class RemoteHTTP(RemoteBASE):
def _download(self, from_info, to_file, name=None, no_progress_bar=False):
request = self._request("GET", from_info.url, stream=True)
total = self._content_length(from_info.url)
if name is None:
name = from_info.url
leave = False
# TODO: persistent progress only for "large" files?
# if total:
# leave = total > self.CHUNK_SIZE * 100
with Tqdm(total=total, leave=leave, bytes=True,
desc_truncate=to_file,
desc_truncate=name,
disable=no_progress_bar) as pbar:
with open(to_file, "wb") as fd:
for chunk in request.iter_content(chunk_size=self.CHUNK_SIZE):