Skip to content

Commit

Permalink
Fix download via HTTP/2
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Dec 30, 2023
1 parent 1e3851c commit 9f630cf
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
def download_svd_data():
url = "https://www.st.com/content/st_com/en/products/microcontrollers-microprocessors/"
url += "stm32-32-bit-arm-cortex-mcus.cxst-rs-grid.html/CL1734.cad_models_and_symbols.svd.json"
with urlopen(Request(url, headers=_hdr)) as data:
json_data = data.read().decode(encoding="utf-8", errors="ignore")
cmd = f"curl '{url}' -X 'GET' -s --max-time 60 -o - " + " ".join(f"-H '{k}: {v}'" for k,v in _hdr.items())
data = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE).stdout
json_data = data.decode(encoding="utf-8", errors="ignore")
rows = json.loads(json_data)["rows"]
return [(row["localizedDescriptions"]["en"].split(" ")[0], row["version"],
"https://www.st.com" + row["localizedLinks"]["en"]) for row in rows]

def download_zip(url, path):
if path.exists(): path.unlink()
with tempfile.NamedTemporaryFile() as outfile:
os.system(f'wget -q --user-agent="{_hdr["User-Agent"]}" "{url}" -O {outfile.name}')
shutil.copy(outfile.name, str(path))
cmd = f"curl '{url}' -X 'GET' --max-time 120 -o {path} " + " ".join(f"-H '{k}: {v}'" for k,v in _hdr.items())
assert subprocess.call(cmd, shell=True) == 0


def download_families(download = True):
Expand Down

0 comments on commit 9f630cf

Please sign in to comment.