From fc6f096b05f10bd92a62bce9f18ba8f7b245b166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20K=C3=BCmmerer?= Date: Wed, 14 Aug 2024 16:48:48 +0200 Subject: [PATCH] fail with better error message on broken downloads MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Matthias Kümmerer --- pysaliency/external_models/matlab_models.py | 4 +++- pysaliency/utils/__init__.py | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pysaliency/external_models/matlab_models.py b/pysaliency/external_models/matlab_models.py index 74ddcfb..e9da44a 100644 --- a/pysaliency/external_models/matlab_models.py +++ b/pysaliency/external_models/matlab_models.py @@ -270,7 +270,9 @@ def __init__(self, location=None, **kwargs): def _setup(self): source_location = os.path.join(self.location, 'gbvs') - download_extract_patch('http://www.vision.caltech.edu/~harel/share/gbvs.zip', + url = "http://www.vision.caltech.edu/~harel/share/gbvs.zip" + + download_extract_patch(url, 'c5a86b9549c2c0bbd1b7f7e5b663b031', source_location, location_in_archive=True, diff --git a/pysaliency/utils/__init__.py b/pysaliency/utils/__init__.py index 2046b22..2003705 100644 --- a/pysaliency/utils/__init__.py +++ b/pysaliency/utils/__init__.py @@ -364,6 +364,8 @@ def download_file(url, target, verify_ssl=True): for data in r.iter_content(32*1024): f.write(data) progress_bar.update(32*1024) + if r.status_code in [403, 404, 500, 503]: + raise ValueError("Error downloading file from {}. Status code: {}".format(url, r.status_code)) def download_and_check(url, target, md5_hash, verify_ssl=True):