eodal.downloader.utils.creodias module

Utility functions for downloading data from CREODIAS

Copyright (C) 2022 Lukas Valentin Graf

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.

eodal.downloader.utils.creodias.download_datasets(datasets: DataFrame, download_dir: Path | str, overwrite_existing_zips: bool | None = False) None[source]

Function for actual dataset download from CREODIAS. Requires valid CREODIAS username and password (to be specified in the BaseSettings)

Parameters:
  • datasets – dataframe with results of CREODIAS Finder API request made by query_creodias function

  • download_dir – directory where to store the downloaded files

  • overwrite_existing_zips – if set to False (default), existing zip files in the download_dir are not overwritten. This feature can be useful to restart the downloader after a network connection timeout or similar. NOTE: Thhe function does not check if the existing zips are complete!

eodal.downloader.utils.creodias.get_keycloak() str[source]

Gets the keycloak token required by CREODIAS to sign requests. It uses the CREODIAS username, password and one-time access code (2FA) to authenticate at the Cloudferro Openid connector.

Note

A one-time access code is valid for 30 seconds. It can be only used once. This means, if one makes multiple requests for a keycloak token within <= 30 seconds, there will be a server error as the one-time access code has been consumed already. To make this behavior more stable, the application waits 31 seconds on error to request a new one-time access code (recursive call).

Returns:

keycloak access token

eodal.downloader.utils.creodias.get_totp() str[source]

Get one-time access code using the TOTP algorithm to login into CREODIAS. The TOTP secret must have been set in the EOdal configurations using the CREODIAS_TOTP_SECRET variable.

Returns:

one-time access key valid for a maximum of 30 seconds.