Skip to content

Commit 6857754

Browse files
authored
Merge pull request #63 from HippocampusGirl/progress-bar-units
FIX: Make download progress bar display correct units
2 parents 9172e6a + 0ad0ec4 commit 6857754

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

templateflow/api.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ def _datalad_get(filepath):
209209

210210
def _s3_get(filepath):
211211
from sys import stderr
212-
from math import ceil
213212
from tqdm import tqdm
214213
import requests
215214

@@ -228,14 +227,12 @@ def _s3_get(filepath):
228227
filepath.unlink()
229228

230229
with filepath.open("wb") as f:
231-
for data in tqdm(
232-
r.iter_content(block_size),
233-
total=ceil(total_size // block_size),
234-
unit="B",
235-
unit_scale=True,
236-
):
237-
wrote = wrote + len(data)
238-
f.write(data)
230+
with tqdm(total=total_size, unit="B", unit_scale=True) as t:
231+
for data in r.iter_content(block_size):
232+
wrote = wrote + len(data)
233+
f.write(data)
234+
t.update(len(data))
235+
239236
if total_size != 0 and wrote != total_size:
240237
raise RuntimeError("ERROR, something went wrong")
241238

0 commit comments

Comments
 (0)