Download relevant toolchain.

This commit is contained in:
Nick Brassel
2024-07-01 21:49:21 +10:00
parent 3ffe8d917a
commit 33f5e67408
7 changed files with 109 additions and 1 deletions
+19
View File
@@ -3,6 +3,7 @@
import contextlib
import multiprocessing
import sys
from pathlib import Path
from milc import cli
@@ -27,6 +28,24 @@ def maybe_exit_config(should_exit: bool = True, should_reraise: bool = False):
maybe_exit_reraise = should_reraise
def cached_get(*args, **kwargs):
import requests_cache
session = requests_cache.CachedSession(Path('~/.local/qmk/qmk_requests.sqlite').expanduser(), expire_after=300, cache_control=True)
return session.get(*args, **kwargs)
def download_with_progress(url, filename):
import requests
import tqdm
response = requests.get(url, stream=True)
total_size = int(response.headers.get('content-length', 0))
with tqdm.tqdm(desc=filename, total=total_size, unit='B', unit_scale=True) as pbar:
with open(filename, 'wb') as file:
for data in response.iter_content(1024):
file.write(data)
pbar.update(len(data))
@contextlib.contextmanager
def parallelize():
"""Returns a function that can be used in place of a map() call.