MCPcopy
hub / github.com/emscripten-core/emsdk / download_file

Function download_file

emsdk.py:695–722  ·  view source on GitHub ↗
(url, dstpath, download_even_if_exists=False,
                  filename_prefix='')

Source from the content-addressed store, hash-verified

693# On success, returns the filename on the disk pointing to the destination file that was produced
694# On failure, returns None.
695def download_file(url, dstpath, download_even_if_exists=False,
696 filename_prefix=''):
697 debug_print(f'download_file(url={url}, dstpath={dstpath})')
698 file_name = get_download_target(url, dstpath, filename_prefix)
699
700 if os.path.exists(file_name) and not download_even_if_exists:
701 print(f"File '{file_name}' already downloaded, skipping.")
702 return file_name
703
704 mkdir_p(os.path.dirname(file_name))
705
706 try:
707 # Use curl on macOS or when EMSDK_USE_CURL is set to avoid
708 # CERTIFICATE_VERIFY_FAILED issue with python's urllib:
709 # https://stackoverflow.com/questions/40684543/how-to-make-python-use-ca-certificates-from-mac-os-truststore
710 # Unlike on linux or windows, curl is always available on macOS systems.
711 if MACOS or 'EMSDK_USE_CURL' in os.environ:
712 download_with_curl(url, file_name)
713 else:
714 download_with_urllib(url, file_name)
715 except Exception as e:
716 errlog(f"Error: Downloading URL '{url}': {e}")
717 return None
718 except KeyboardInterrupt:
719 rmfile(file_name)
720 raise
721
722 return file_name
723
724
725def run_get_output(cmd, cwd=None):

Callers 1

try_downloadFunction · 0.85

Calls 7

debug_printFunction · 0.85
get_download_targetFunction · 0.85
mkdir_pFunction · 0.85
download_with_curlFunction · 0.85
download_with_urllibFunction · 0.85
errlogFunction · 0.85
rmfileFunction · 0.85

Tested by

no test coverage detected