diff options
author | Guido Günther <agx@sigxcpu.org> | 2016-12-26 20:15:17 +0100 |
---|---|---|
committer | Guido Günther <agx@sigxcpu.org> | 2016-12-26 20:15:17 +0100 |
commit | bad1f2370ba311bbe5981b204d4fa244b1d9a514 (patch) | |
tree | 9cb5d38aad2eb177d04a59e51a6c54aef07f69ab /gbp/scripts/common | |
parent | ce644b02862726e0d75a98d60703227de75012a7 (diff) |
import-orig: Handle download errors properly
This introduces tests that reach out to the network. These are disabled
by default.
Diffstat (limited to 'gbp/scripts/common')
-rw-r--r-- | gbp/scripts/common/import_orig.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/gbp/scripts/common/import_orig.py b/gbp/scripts/common/import_orig.py index eaa38b77..66144e5b 100644 --- a/gbp/scripts/common/import_orig.py +++ b/gbp/scripts/common/import_orig.py @@ -167,7 +167,8 @@ def download_orig(url): try: with contextlib.closing(requests.get(url, verify=True, stream=True)) as r: - with contextlib.closing(open(target, 'w', CHUNK_SIZE)) as target_fd: + r.raise_for_status() + with open(target, 'w', CHUNK_SIZE) as target_fd: for d in r.iter_content(CHUNK_SIZE): target_fd.write(d) except Exception as e: |