(t)
| 47 | logger.warn("File {} exists. Will overwrite with a new download!".format(filename)) |
| 48 | |
| 49 | def hook(t): |
| 50 | last_b = [0] |
| 51 | |
| 52 | def inner(b, bsize, tsize=None): |
| 53 | if tsize is not None: |
| 54 | t.total = tsize |
| 55 | t.update((b - last_b[0]) * bsize) |
| 56 | last_b[0] = b |
| 57 | return inner |
| 58 | try: |
| 59 | with tqdm.tqdm(unit='B', unit_scale=True, miniters=1, desc=filename) as t: |
| 60 | fpath, _ = urllib.request.urlretrieve(url, fpath, reporthook=hook(t)) |