scopesim.server.download_utils.handle_download

scopesim.server.download_utils.handle_download#

scopesim.server.download_utils.handle_download(client: Client, sub_url: str, save_path: Path, name: str = '', padlen: int = 0, chunk_size: int = 128, disable_bar: bool = False, params: dict | None = None) None#

Perform a streamed download and write the content to disk.

Parameters:
  • client (httpx.Client) – Client instance.

  • sub_url (str) – URL of file to be downloaded, relative to the client’s base URL.

  • save_path (Path) – Path including file name to save the downloaded file to.

  • name (str, optional) – Optional display name for progress bar. Has no influence on saved filename. The default is “”.

  • padlen (int, optional) – Optional padding for name in progress bar. Useful to get a nicer output when doenloading multiple files. The default is 0.

  • chunk_size (int, optional) – Chunk size for download stream. The default is 128.

  • disable_bar (bool, optional) – If True, no progress bar is printed. The default is False.

  • params (dict | None, optional) – Any query parameters to include in the URL, will be forwarded to the send_get() call. The default is None.

Raises:

ServerError – Raised if any error occurs during the process.

Return type:

None