From 0c1d454c42c966a2ffec85486ceeda08bcf4cef3 Mon Sep 17 00:00:00 2001 From: Jon Michael Aanes Date: Mon, 22 Jul 2024 23:38:05 +0200 Subject: [PATCH] Updated secrets handle to `load_or_fail` --- crypto_seller/__main__.py | 9 +++++---- crypto_seller/config.py | 7 ------- crypto_seller/secrets_config.py | 12 ++++++++++++ 3 files changed, 17 insertions(+), 11 deletions(-) delete mode 100644 crypto_seller/config.py create mode 100644 crypto_seller/secrets_config.py diff --git a/crypto_seller/__main__.py b/crypto_seller/__main__.py index 4c5c32f..662c245 100644 --- a/crypto_seller/__main__.py +++ b/crypto_seller/__main__.py @@ -12,7 +12,6 @@ import fin_depo from . import ( AutoSellConfig, - config, log_results, order_csv, run_auto_sell, @@ -65,10 +64,12 @@ Sells financial assets from an online account. def load_config(config_path: Path) -> AutoSellConfig: logger.info('Loading configuration') + from . import secrets_config + seller_backend = fin_depo.defi_kucoin.KucoinDepoFetcher( - kucoin_secret=config.KUCOIN_SECRET, - kucoin_key=config.KUCOIN_KEY, - kucoin_pass=config.KUCOIN_PASS, + kucoin_secret=secrets_config.KUCOIN_SECRET, + kucoin_key=secrets_config.KUCOIN_KEY, + kucoin_pass=secrets_config.KUCOIN_PASS, allow_trades=True, ) diff --git a/crypto_seller/config.py b/crypto_seller/config.py deleted file mode 100644 index 77a4cb6..0000000 --- a/crypto_seller/config.py +++ /dev/null @@ -1,7 +0,0 @@ -import secret_loader - -load_secret = secret_loader.SecretLoader().load - -KUCOIN_KEY = load_secret('KUCOIN_KEY') -KUCOIN_SECRET = load_secret('KUCOIN_SECRET') -KUCOIN_PASS = load_secret('KUCOIN_PASS') diff --git a/crypto_seller/secrets_config.py b/crypto_seller/secrets_config.py new file mode 100644 index 0000000..fcb968d --- /dev/null +++ b/crypto_seller/secrets_config.py @@ -0,0 +1,12 @@ +"""Handles secrets for the `crypto_seller` system.""" +from secret_loader import SecretLoader + +__all__ = ['KUCOIN_KEY', 'KUCOIN_SECRET', 'KUCOIN_PASS'] + +secret_loader = SecretLoader() + +KUCOIN_KEY = secret_loader.load_or_fail('KUCOIN_KEY') +KUCOIN_SECRET = secret_loader.load_or_fail('KUCOIN_SECRET') +KUCOIN_PASS = secret_loader.load_or_fail('KUCOIN_PASS') + +del secret_loader