Skip to content

Commit

Permalink
Merge pull request #514 from Deltares/513-add-required-uid-to-cds-api…
Browse files Browse the repository at this point in the history
…-key-for-era5-download

check for colon in cds apikey
  • Loading branch information
JulienGroenenboom authored Sep 15, 2023
2 parents 5160e7e + c30bcb2 commit 52e00f6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions dfm_tools/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,10 @@ def cds_credentials():
if os.path.exists(file_credentials):
print('found CDS apikey')
else:
print("Downloading CDS/ERA5 data requires a CDS apikey, copy the key from https://cds.climate.copernicus.eu/api-how-to (first register and sign in) ")
apikey = getpass.getpass("Enter your CDS apikey: ")
print("Downloading CDS/ERA5 data requires a CDS API key, copy the key from https://cds.climate.copernicus.eu/api-how-to (first register and sign in) ")
apikey = getpass.getpass("\nEnter your CDS API Key: ")
if ":" not in apikey:
raise ValueError('A ":"-symbol is missing in the provided key (format should be "UID:apikey"). Please check the instructions above again.')
with open(file_credentials,'w') as fc:
fc.write('url: https://cds.climate.copernicus.eu/api/v2\n')
fc.write(f'key: {apikey}')
Expand Down

0 comments on commit 52e00f6

Please sign in to comment.