mirror of
https://github.com/qmk/qmk_firmware.git
synced 2026-08-03 16:00:34 -04:00
Download relevant toolchain.
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user