spinifex.download ================= .. py:module:: spinifex.download .. autoapi-nested-parse:: Generic download utils Functions --------- .. autoapisummary:: spinifex.download._ftp_download_and_quit spinifex.download.download_file_ftp spinifex.download.download_file_http spinifex.download.download_or_copy_url Module Contents --------------- .. py:function:: _ftp_download_and_quit(ftp: ftplib.FTP, file_name: str, output_file: pathlib.Path) -> None Download a file from an FTP server and quit the connection. Parameters ---------- ftp : FTP FTP connection. file_name : str File name to download. output_file : Path Output file path. Raises ------ e If the download fails. .. py:function:: download_file_ftp(url: str, output_file: pathlib.Path) -> None :async: Download a file from a given URL using asyncio. Parameters ---------- url : str URL to download. output_file : Path Output file path. .. py:function:: download_file_http(url: str, output_file: pathlib.Path, timeout_seconds: int = 30, chunk_size: int = 1000) -> None :async: Download a file from a given URL using asyncio. Parameters ---------- url : str URL to download. output_file : Path Output file path. timeout_seconds : int, optional Seconds to wait for request timeout, by default 30 chunk_size : int, optional Chunks of data to download, by default 1000 Raises ------ IonexError If the download times out. .. py:function:: download_or_copy_url(url: str, output_directory: pathlib.Path | None = None, chunk_size: int = 1000, timeout_seconds: int = 30) -> pathlib.Path :async: Download a file from a given URL. If the URL is a file URL (i.e. starting with `file://`), it will be copied to the output directory. Parameters ---------- url : str URL to download. output_directory : Path | None, optional Output directory, by default None. If None, will default to `ionex_files` in the current working directory. chunk_size : int, optional Download chunks, by default 1000 timeout_seconds : int, optional Request timeout in seconds, by default 30 Returns ------- Path Output file path Raises ------ FileNotFoundError If the .netrc file is not found when downloading from CDDIS.