fix config
This commit is contained in:
parent
7484c50e66
commit
59780af3a3
|
@ -5,6 +5,9 @@ DEFAULT_URL = 'https://cds-beta.climate.copernicus.eu/api'
|
|||
ENV_CDSAPI_URL = 'CDSAPI_URL'
|
||||
ENV_CDSAPI_KEY = 'CDSAPI_KEY'
|
||||
|
||||
CONFIG_FILE = ".cdsapirc"
|
||||
|
||||
|
||||
CONFIG_URL = 'url'
|
||||
CONFIG_KEY = 'key'
|
||||
|
||||
|
@ -13,13 +16,12 @@ class AuthCDS:
|
|||
def __init__(self, verbose=False):
|
||||
"""Initialize AuthCDS with optional verbose logging."""
|
||||
self.verbose = verbose
|
||||
self.CONFIG_FILE = ".cdsapirc"
|
||||
self.CURRENT_CDSAPIRC = "./" + self.CONFIG_FILE
|
||||
self.CURRENT_CDSAPIRC = "./" + CONFIG_FILE
|
||||
# Expands `~` to the home directory path
|
||||
self.HOME_CDSAPIRC = os.path.expanduser("~/" + self.CONFIG_FILE)
|
||||
self.HOME_CDSAPIRC = os.path.expanduser("~/" + CONFIG_FILE)
|
||||
self.DEFAULT_URL = DEFAULT_URL
|
||||
# self.ENV_CDSAPI_URL = ENV_CDSAPI_URL
|
||||
# self.ENV_CDSAPI_KEY = ENV_CDSAPI_KEY
|
||||
# ENV_CDSAPI_URL = ENV_CDSAPI_URL
|
||||
# ENV_CDSAPI_KEY = ENV_CDSAPI_KEY
|
||||
# self.CONFIG_URL = CONFIG_URL
|
||||
# self.CONFIG_KEY = CONFIG_KEY
|
||||
|
||||
|
@ -30,7 +32,7 @@ class AuthCDS:
|
|||
|
||||
def create_config(self, url, key):
|
||||
"""Create a configuration dictionary."""
|
||||
return {self.CONFIG_URL: url, self.CONFIG_KEY: key}
|
||||
return {CONFIG_URL: url, CONFIG_KEY: key}
|
||||
|
||||
def config_from_env(self):
|
||||
"""Retrieve configuration from environment variables."""
|
||||
|
@ -142,13 +144,13 @@ class AuthCDS:
|
|||
def remove_env_configuration(self):
|
||||
"""Remove authentication credentials from environment variables."""
|
||||
removed_envs = []
|
||||
if self.ENV_CDSAPI_URL in os.environ:
|
||||
del os.environ[self.ENV_CDSAPI_URL]
|
||||
self.log(f"Removed environment variable {self.ENV_CDSAPI_URL}")
|
||||
if ENV_CDSAPI_URL in os.environ:
|
||||
del os.environ[ENV_CDSAPI_URL]
|
||||
self.log(f"Removed environment variable {ENV_CDSAPI_URL}")
|
||||
|
||||
if self.ENV_CDSAPI_KEY in os.environ:
|
||||
del os.environ[self.ENV_CDSAPI_KEY]
|
||||
self.log(f"Removed environment variable {self.ENV_CDSAPI_KEY}")
|
||||
if ENV_CDSAPI_KEY in os.environ:
|
||||
del os.environ[ENV_CDSAPI_KEY]
|
||||
self.log(f"Removed environment variable {ENV_CDSAPI_KEY}")
|
||||
|
||||
return removed_envs
|
||||
|
||||
|
|
Loading…
Reference in New Issue