MCPcopy Create free account
hub / github.com/AnswerDotAI/gpu.cpp / download_file

Function download_file

setup.py:23–44  ·  view source on GitHub ↗
(url, output_filename)

Source from the content-addressed store, hash-verified

21 return "Other"
22
23def download_file(url, output_filename):
24 total_downloaded = 0
25 total_truncated = 0 # only print download progress every 2MB to avoid spamming logs
26
27 def report_progress(block_num, block_size, total_size):
28 nonlocal total_downloaded
29 nonlocal total_truncated
30 total_downloaded += block_size
31 if total_downloaded // (1024 * 1024) > total_truncated:
32 total_truncated = total_downloaded // (1024 * 1024)
33 if total_truncated % 2 == 0:
34 print(f"\rDownloaded {total_downloaded // (1024 * 1024)} MB", end="")
35
36 try:
37 ssl._create_default_https_context = ssl._create_stdlib_context
38 urllib.request.urlretrieve(url, output_filename, reporthook=report_progress)
39 print(f"\nDownloaded {output_filename}")
40 return True
41 except Exception as e:
42 print(f"\nFailed to download {output_filename}")
43 print(f"Error: {str(e)}")
44 sys.exit(1)
45
46def check_os(os_name):
47 print("\nChecking System")

Callers 1

download_dawnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected