This commit is contained in:
parent
2ec0f9ae17
commit
ae3081381a
|
@ -62,6 +62,10 @@ class NordnetDepoFetcher:
|
||||||
self.password = password
|
self.password = password
|
||||||
self.is_logged_in = False
|
self.is_logged_in = False
|
||||||
|
|
||||||
|
assert self.username is not None, 'Username is missing'
|
||||||
|
assert self.password is not None, 'Password is missing'
|
||||||
|
|
||||||
|
|
||||||
def get_json(self, url: str, params: dict[str, str | int] = {}) -> dict:
|
def get_json(self, url: str, params: dict[str, str | int] = {}) -> dict:
|
||||||
if not url.startswith(API_ROOT):
|
if not url.startswith(API_ROOT):
|
||||||
msg = f'Given url must be located below API ROOT: {url}'
|
msg = f'Given url must be located below API ROOT: {url}'
|
||||||
|
|
|
@ -1,18 +1,6 @@
|
||||||
import logging
|
from secret_loader import SecretLoader
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
|
||||||
|
|
||||||
|
|
||||||
def load_secret(env_key: str) -> str:
|
|
||||||
filepath = f'./secrets/{env_key.lower()}'
|
|
||||||
try:
|
|
||||||
with open(filepath) as f:
|
|
||||||
return f.read().strip()
|
|
||||||
logger.info('Loaded secret: %s', env_key)
|
|
||||||
except Exception:
|
|
||||||
logger.exception("Could not load %s file '%s'", env_key, filepath)
|
|
||||||
return None
|
|
||||||
|
|
||||||
|
load_secret = SecretLoader().load
|
||||||
|
|
||||||
NORDNET_USERNAME = load_secret('NORDNET_USERNAME')
|
NORDNET_USERNAME = load_secret('NORDNET_USERNAME')
|
||||||
NORDNET_PASSWORD = load_secret('NORDNET_PASSWORD')
|
NORDNET_PASSWORD = load_secret('NORDNET_PASSWORD')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user