Skip to content

Configuration and errors

Settings

cdse.config.Settings

Bases: BaseSettings

Runtime configuration, populated from arguments or the environment.

Transfer

cdse.transfer.download_to_file

download_to_file(
    transport: Transport,
    url: str,
    destination: Path,
    *,
    chunk_size: int = DEFAULT_CHUNK_SIZE,
    resume: bool = False,
) -> Path

Stream the body at url to destination and return the path.

Parameters:

Name Type Description Default
transport Transport

The transport used to send the authenticated request.

required
url str

The URL to download.

required
destination Path

Where to write the file.

required
chunk_size int

Number of bytes to read at a time.

DEFAULT_CHUNK_SIZE
resume bool

When true and a partial file already exists, request only the remaining bytes with a range header and append to it. If the server ignores the range and returns the whole file, it is written afresh.

False

Exceptions

cdse.exceptions

Exception hierarchy for the CDSE client.

Callers should be able to react to failures by catching meaningful types rather than inspecting raw HTTP status codes. Every exception raised by the library derives from :class:CdseError.

CdseError

Bases: Exception

Base class for every error raised by the library.

CdseConfigError

Bases: CdseError

The client was configured incorrectly, for example missing credentials.

AuthError

Bases: CdseError

Authentication or token handling failed.

TokenRefreshError

Bases: AuthError

An access token could not be refreshed.

ReauthRequiredError

Bases: AuthError

The session expired and cannot be renewed without new credentials.

This is raised when the refresh token is no longer valid and the configured auth provider does not hold the credentials needed to authenticate again, which is the case when the client was created from an existing refresh token.

TransportError

Bases: CdseError

A network level failure occurred and could not be recovered by retrying.

CdseHTTPError

CdseHTTPError(
    message: str,
    *,
    status_code: int,
    url: str,
    body: str = "",
)

Bases: CdseError

The server returned an unsuccessful HTTP response.

Attributes:

Name Type Description
status_code

The HTTP status code of the response.

url

The URL that was requested.

body

The response body, truncated for readability.

RateLimitError

RateLimitError(
    message: str,
    *,
    status_code: int,
    url: str,
    body: str = "",
    retry_after: float | None = None,
)

Bases: CdseHTTPError

The request was rejected because a rate limit was exceeded.

Attributes:

Name Type Description
retry_after

Seconds to wait before retrying, when the server provides a Retry-After header.

QuotaExceededError

QuotaExceededError(
    message: str,
    *,
    status_code: int,
    url: str,
    body: str = "",
)

Bases: CdseHTTPError

An account quota, such as the monthly transfer limit, was exceeded.

NotFoundError

NotFoundError(
    message: str,
    *,
    status_code: int,
    url: str,
    body: str = "",
)

Bases: CdseHTTPError

The requested resource does not exist.

ServerError

ServerError(
    message: str,
    *,
    status_code: int,
    url: str,
    body: str = "",
)

Bases: CdseHTTPError

The server reported an internal error.