spinifex.download

Generic download utils

Functions

_ftp_download_and_quit(→ None)

Download a file from an FTP server and quit the connection.

download_file_ftp(→ None)

Download a file from a given URL using asyncio.

download_file_http(→ None)

Download a file from a given URL using asyncio.

download_or_copy_url(→ pathlib.Path)

Download a file from a given URL.

Module Contents

spinifex.download._ftp_download_and_quit(ftp: ftplib.FTP, file_name: str, output_file: pathlib.Path) None[source]

Download a file from an FTP server and quit the connection.

Parameters

ftpFTP

FTP connection.

file_namestr

File name to download.

output_filePath

Output file path.

Raises

e

If the download fails.

async spinifex.download.download_file_ftp(url: str, output_file: pathlib.Path) None[source]

Download a file from a given URL using asyncio.

Parameters

urlstr

URL to download.

output_filePath

Output file path.

async spinifex.download.download_file_http(url: str, output_file: pathlib.Path, timeout_seconds: int = 30, chunk_size: int = 1000) None[source]

Download a file from a given URL using asyncio.

Parameters

urlstr

URL to download.

output_filePath

Output file path.

timeout_secondsint, optional

Seconds to wait for request timeout, by default 30

chunk_sizeint, optional

Chunks of data to download, by default 1000

Raises

IonexError

If the download times out.

async spinifex.download.download_or_copy_url(url: str, output_directory: pathlib.Path | None = None, chunk_size: int = 1000, timeout_seconds: int = 30) pathlib.Path[source]

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

urlstr

URL to download.

output_directoryPath | None, optional

Output directory, by default None. If None, will default to ionex_files in the current working directory.

chunk_sizeint, optional

Download chunks, by default 1000

timeout_secondsint, 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.