seagrid.download.credentials#
Which data providers need an account, and whether its credentials are set up.
Three providers need a (free) account; every other source downloads without
one. status() checks, without contacting any server, whether
credentials for each provider can be found in the places seagrid and the
provider’s own tools look. It does not check that they are correct: use
seagrid check SOURCE (or glorys.check_auth()) for that.
See Credentials for how to set up each account.
Examples
>>> from seagrid.download import credentials
>>> sorted(credentials.PROVIDERS)
['copernicus', 'earthdata', 'mercator']
>>> sorted(credentials.status())
['copernicus', 'earthdata', 'mercator']
Module Attributes
Functions
|
Return True if a netrc file has a login and password for machine. |
|
Return a readable summary of |
|
Return where each provider's credentials were found. |
Classes
|
A data provider that needs an account. |
- seagrid.download.credentials.PROVIDERS: dict[str, Provider] = {'copernicus': Provider(title='Copernicus Marine', sources=('cmems_globgc', 'glorys_carb', 'ostia', 'smoc'), register='https://data.marine.copernicus.eu/register'), 'earthdata': Provider(title='NASA Earthdata', sources=('avhrr', 'modis_a', 'mur25', 'olci', 'seawifs', 'viirs'), register='https://urs.earthdata.nasa.gov/users/new'), 'mercator': Provider(title='Mercator Ocean', sources=('glorys',), register='https://www.mercator-ocean.eu')}#
Provider key ->
Provider.
- class seagrid.download.credentials.Provider(title, sources, register)[source]#
Bases:
objectA data provider that needs an account.
- seagrid.download.credentials.netrc_login(machine, path=None)[source]#
Return True if a netrc file has a login and password for machine.
- Parameters:
machine (
str) – Host name, e.g."urs.earthdata.nasa.gov".path (
stroros.PathLike, optional) – netrc file. Default$NETRC, else~/.netrc.
- Returns:
bool– False if the file is missing, cannot be parsed, or has no complete entry for machine.- Return type:
Examples
>>> netrc_login("example.org", "/nonexistent/.netrc") False
- seagrid.download.credentials.report(found=None)[source]#
Return a readable summary of
status().- Parameters:
found (
dict, optional) – The result ofstatus(). Default: call it.- Returns:
str– One line per provider, then where to read how to set up the missing ones.- Return type:
Examples
>>> print(report({"copernicus": None, "earthdata": "~/.netrc", ... "mercator": None})) Credentials (needed only for these sources; all others are open): Copernicus Marine missing cmems_globgc, glorys_carb, ostia, smoc NASA Earthdata found avhrr, modis_a, ... (~/.netrc) Mercator Ocean missing glorys How to set them up: https://brorfred.github.io/seagrid/...
- seagrid.download.credentials.status()[source]#
Return where each provider’s credentials were found.
Nothing is sent to any server, so a credential that is found may still be wrong.
- Returns:
dictofstrtostrorNone– Provider key (seePROVIDERS) -> where the credentials were found (a file, environment variables or settings sections), or None.- Return type:
Notes
The places checked, in order:
copernicus:COPERNICUSMARINE_SERVICE_USERNAMEand_PASSWORD; the file written bycopernicusmarine login(~/.copernicusmarine/.copernicusmarine-credentials, or in$COPERNICUSMARINE_CREDENTIALS_DIRECTORY);usernameandpasswordin a Copernicus source’s settings (.secrets.toml).earthdata:EARTHDATA_TOKEN;EARTHDATA_USERNAMEandEARTHDATA_PASSWORD;machine urs.earthdata.nasa.govin~/.netrc(or$NETRC).mercator:machine tds.mercator-ocean.frin~/.netrc.