Skip to content

Commit

Permalink
Retry downloading Winbindex json.gz files
Browse files Browse the repository at this point in the history
m417z committed Sep 25, 2024
1 parent e2b94e6 commit ccf8f16
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions scripts/02_download_binaries.py
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import shutil
import subprocess
import tempfile
import time
from argparse import ArgumentParser
from datetime import datetime
from pathlib import Path
@@ -80,8 +81,20 @@ def download_binaries_from_symbol_server(name: str, target_folder: Path, previou
else:
url = f'https://winbindex.m417z.com/data/by_filename_compressed/{name}.json.gz'

r = requests.get(url)
r.raise_for_status()
while True:
try:
r = requests.get(url)
if 500 <= r.status_code < 600:
raise Exception(f'Server Error: {r.status_code} for url: {url}')
break
except Exception as e:
print(f'ERROR: failed to get {url}, retrying in 10 seconds')
print(f' {e}')
time.sleep(10)

if 400 <= r.status_code < 500:
raise Exception(f'Client Error: {r.status_code} for url: {url}')

data_compressed = r.content
data_json_str = gzip.decompress(data_compressed).decode()
data = json.loads(data_json_str)

0 comments on commit ccf8f16

Please sign in to comment.