aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorPetr Svenda2021-01-08 22:29:48 +0100
committerPetr Svenda2021-01-08 22:29:48 +0100
commit3886b8e81f3bc32095a148777444bb6723837481 (patch)
tree732e4bf0635e144f3d6a6ff4d7b497957c800777
parent5db13db977ea29ec8c1f4bd76bd69f7abb74b29a (diff)
downloadsec-certs-3886b8e81f3bc32095a148777444bb6723837481.tar.gz
sec-certs-3886b8e81f3bc32095a148777444bb6723837481.tar.zst
sec-certs-3886b8e81f3bc32095a148777444bb6723837481.zip
add catch dowload exceptions
-rw-r--r--sec_certs/download.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/sec_certs/download.py b/sec_certs/download.py
index fc225150..57e332e8 100644
--- a/sec_certs/download.py
+++ b/sec_certs/download.py
@@ -13,8 +13,11 @@ CC_WEB_URL = 'https://www.commoncriteriaportal.org'
def download_file(url: str, output: Path) -> int:
r = requests.get(url, allow_redirects=True)
- with output.open("wb") as f:
- f.write(r.content)
+ try:
+ with open(output, "wb") as f:
+ f.write(r.content)
+ except (OSError, ConnectionError) as e:
+ print('ERROR: Failed to download {} with {}'.format(url, e))
return r.status_code