From 755b70475a5ab8f49dadd5218e357a38461e1db3 Mon Sep 17 00:00:00 2001 From: agp8x Date: Sat, 4 Aug 2018 10:33:27 +0200 Subject: [PATCH] fail early on invalid http --- snapshotter/src/snapshot.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/snapshotter/src/snapshot.py b/snapshotter/src/snapshot.py index 77de810..2a92214 100644 --- a/snapshotter/src/snapshot.py +++ b/snapshotter/src/snapshot.py @@ -29,6 +29,8 @@ def today(today=dt.today()): def download(url, target, **kwargs): response = requests.get(url, stream=True, **kwargs) + if not response.ok: + raise ValueError("HTTP not OK", response.status_code, response.text) response.raw.decode_content = True with open(target, "wb") as out: shutil.copyfileobj(response.raw, out)