Retry grype download on failure

This commit is contained in:
Kovid Goyal
2025-09-22 11:36:27 +05:30
parent 4817a4559b
commit 92ee52b68c

View File

@@ -12,6 +12,7 @@ import subprocess
import sys import sys
import tarfile import tarfile
import time import time
from urllib.error import URLError
from urllib.request import Request, urlopen from urllib.request import Request, urlopen
BUNDLE_URL = 'https://download.calibre-ebook.com/ci/kitty/{}-64.tar.xz' BUNDLE_URL = 'https://download.calibre-ebook.com/ci/kitty/{}-64.tar.xz'
@@ -187,8 +188,13 @@ def install_grype() -> str:
rq = Request('https://api.github.com/repos/anchore/grype/releases/latest', headers={ rq = Request('https://api.github.com/repos/anchore/grype/releases/latest', headers={
'Accept': 'application/vnd.github.v3+json', 'Accept': 'application/vnd.github.v3+json',
}) })
with urlopen(rq) as f: try:
m = json.loads(f.read()) with urlopen(rq) as f:
m = json.loads(f.read())
except URLError:
time.sleep(1)
with urlopen(rq) as f:
m = json.loads(f.read())
for asset in m['assets']: for asset in m['assets']:
if asset['name'].endswith('_linux_amd64.tar.gz'): if asset['name'].endswith('_linux_amd64.tar.gz'):
url = asset['browser_download_url'] url = asset['browser_download_url']