(url, dstpath, download_even_if_exists=False,
filename_prefix='')
| 693 | # On success, returns the filename on the disk pointing to the destination file that was produced |
| 694 | # On failure, returns None. |
| 695 | def 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 | |
| 725 | def run_get_output(cmd, cwd=None): |
no test coverage detected