mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-06 01:05:48 +02:00
Nicer 403 error andling when downloading grype
This commit is contained in:
7
.github/workflows/ci.py
vendored
7
.github/workflows/ci.py
vendored
@@ -12,7 +12,7 @@ import subprocess
|
||||
import sys
|
||||
import tarfile
|
||||
import time
|
||||
from urllib.request import Request
|
||||
from urllib.request import Request, urlopen
|
||||
|
||||
BUNDLE_URL = 'https://download.calibre-ebook.com/ci/kitty/{}-64.tar.xz'
|
||||
FONTS_URL = 'https://download.calibre-ebook.com/ci/fonts.tar.xz'
|
||||
@@ -64,14 +64,15 @@ def run(*a: str, print_crash_reports: bool = False) -> None:
|
||||
|
||||
|
||||
def download_with_retry(url: str | Request, count: int = 5) -> bytes:
|
||||
from urllib.request import urlopen
|
||||
for i in range(count):
|
||||
try:
|
||||
print('Downloading', url, flush=True)
|
||||
print('Downloading', getattr(url, 'full_url', url), flush=True)
|
||||
with urlopen(url) as f:
|
||||
ans: bytes = f.read()
|
||||
return ans
|
||||
except Exception as err:
|
||||
if getattr(err, 'code', -1) == 403:
|
||||
raise
|
||||
if i >= count - 1:
|
||||
raise
|
||||
print(f'Download failed with error {err} retrying...', file=sys.stderr)
|
||||
|
||||
Reference in New Issue
Block a user