Skip to content

Commit bac7b4c

Browse files
committed
bump version, fix get_file content-length
1 parent 194e7cb commit bac7b4c

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

brainweb/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
from .utils import __all__ # NOQA
33
__author__ = "Casper O. da Costa-Luis <casper.dcl@physics.org>"
44
__licence__ = __license__ = "[MPLv2.0](https://www.mozilla.org/MPL/2.0)"
5-
__version__ = "1.6.1"
5+
__version__ = "1.6.2"

brainweb/utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ class Shape(object):
140140
brainweb = mMR * Res.mMR / Res.brainweb
141141

142142

143-
def get_file(fname, origin, cache_dir=None):
143+
def get_file(fname, origin, cache_dir=None, chunk_size=None):
144144
"""
145145
Downloads a file from a URL if it not already in the cache.
146146
By default the file at the url `origin` is downloaded to the
@@ -177,11 +177,12 @@ def get_file(fname, origin, cache_dir=None):
177177
log.debug("Downloading %s from %s" % (fpath, origin))
178178
try:
179179
d = requests.get(origin, stream=True)
180-
with tqdm(total=d.headers.get('Content-length', None), desc=fname,
180+
with tqdm(total=float(d.headers.get('Content-length') or 0),
181+
desc=fname,
181182
unit="B", unit_scale=True, unit_divisor=1024,
182183
leave=False) as fprog:
183184
with open(fpath, 'wb') as fo:
184-
for chunk in d.iter_content(chunk_size=None):
185+
for chunk in d.iter_content(chunk_size=chunk_size):
185186
fo.write(chunk)
186187
fprog.update(len(chunk))
187188
fprog.total = fprog.n

0 commit comments

Comments
 (0)