Skip to content

Commit

Permalink
Update download.py
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienGroenenboom authored Sep 14, 2023
1 parent ffb5383 commit 2dfa52a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions dfm_tools/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,13 @@ 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 user ID (UID) and API key from https://cds.climate.copernicus.eu/api-how-to (first register and sign in) ")
UID = getpass.getpass("\nEnter your UID: ")
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.')

Check warning on line 157 in dfm_tools/download.py

View check run for this annotation

Codecov / codecov/patch

dfm_tools/download.py#L154-L157

Added lines #L154 - L157 were not covered by tests
with open(file_credentials,'w') as fc:
fc.write('url: https://cds.climate.copernicus.eu/api/v2\n')
fc.write(f'key: {UID}:{apikey}')
fc.write(f'key: {apikey}')


def copernicusmarine_credentials():
Expand Down

0 comments on commit 2dfa52a

Please sign in to comment.