From 0e0145defd3cc4bc4ae7f6fd9edd21f16fb6d444 Mon Sep 17 00:00:00 2001 From: Tomas Kopecek Date: Aug 01 2018 12:00:33 +0000 Subject: Raise error for non-200 codes in download_file Fixes: https://pagure.io/koji/issue/1020 --- diff --git a/cli/koji_cli/lib.py b/cli/koji_cli/lib.py index 02c6fd2..33b4a09 100644 --- a/cli/koji_cli/lib.py +++ b/cli/koji_cli/lib.py @@ -498,6 +498,8 @@ def download_file(url, relpath, quiet=False, noprogress=False, size=None, num=No with closing(requests.get(url, stream=True)) as response: + # raise error if occured + response.raise_for_status() length = response.headers.get('content-length') f = open(relpath, 'wb') if length is None: