diff options
| author | Petr Svenda | 2021-01-08 22:29:48 +0100 |
|---|---|---|
| committer | Petr Svenda | 2021-01-08 22:29:48 +0100 |
| commit | 3886b8e81f3bc32095a148777444bb6723837481 (patch) | |
| tree | 732e4bf0635e144f3d6a6ff4d7b497957c800777 | |
| parent | 5db13db977ea29ec8c1f4bd76bd69f7abb74b29a (diff) | |
| download | sec-certs-3886b8e81f3bc32095a148777444bb6723837481.tar.gz sec-certs-3886b8e81f3bc32095a148777444bb6723837481.tar.zst sec-certs-3886b8e81f3bc32095a148777444bb6723837481.zip | |
add catch dowload exceptions
| -rw-r--r-- | sec_certs/download.py | 7 |
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 |
