From a0356bd2029b90a2609c8c36adb4df8acead687f Mon Sep 17 00:00:00 2001 From: Alex Aubuchon Date: Tue, 10 Jul 2018 17:35:11 +0200 Subject: [PATCH] Bugfix --- autodqm/dqm.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/autodqm/dqm.py b/autodqm/dqm.py index 7457d74..2e62eaf 100755 --- a/autodqm/dqm.py +++ b/autodqm/dqm.py @@ -147,7 +147,9 @@ def _stream_file(cert, url, dest, chunk_size=4096): Returns a generator of StreamProg tuples to indicate download progress.""" res = requests.get(url, cert=cert, stream=True) - total = res.headers.get('content-length') + if not res: + raise error("Failed to download file: {}".format(url)) + total = int(res.headers.get('content-length')) cur = 0 with open(dest, 'wb') as f: for data in res.iter_content(chunk_size=chunk_size):