From a1076dc01abc82e71f2509a6ca41783fa445c406 Mon Sep 17 00:00:00 2001 From: "Andrew Speciale (@liquidz00)" Date: Sun, 19 May 2024 16:06:25 -0400 Subject: [PATCH] Updated with globals refactor --- bin/utils.py | 13 +++---------- tests/test_patcher.py | 2 +- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/bin/utils.py b/bin/utils.py index 2283384..8336652 100644 --- a/bin/utils.py +++ b/bin/utils.py @@ -16,14 +16,8 @@ FONT_BOLD_PATH, ) -# Define paths -BASE_DIR = globals.BIN_DIR -ROOT_DIR = globals.ROOT_DIR -FONTS_DIR = globals.FONT_DIR -ENV_PATH = globals.ENV_PATH - # Load .env -load_dotenv(dotenv_path=ENV_PATH) +load_dotenv(dotenv_path=globals.ENV_PATH) # Set environment variables jamf_url = os.getenv("URL") @@ -116,16 +110,15 @@ def update_env(token: AnyStr, expires_in: int) -> None: :type expires_in: int """ try: - dotenv_path = os.path.join(ROOT_DIR, ".env") expiration_time = datetime.utcnow() + timedelta(seconds=expires_in) # Small buffer to account for time sync issues buffer = 5 * 60 expiration_timestamp = (expiration_time - timedelta(seconds=buffer)).timestamp() - set_key(dotenv_path=dotenv_path, key_to_set="TOKEN", value_to_set=token) + set_key(dotenv_path=globals.ENV_PATH, key_to_set="TOKEN", value_to_set=token) set_key( - dotenv_path=dotenv_path, + dotenv_path=globals.ENV_PATH, key_to_set="TOKEN_EXPIRATION", value_to_set=str(expiration_timestamp), ) diff --git a/tests/test_patcher.py b/tests/test_patcher.py index 9c04bfc..6c398c9 100644 --- a/tests/test_patcher.py +++ b/tests/test_patcher.py @@ -130,7 +130,7 @@ def test_update_env(mock_set_key): expires_in = 3600 utils.update_env(token=token, expires_in=expires_in) - dotenv_path = os.path.join(utils.ROOT_DIR, ".env") + dotenv_path = globals.ENV_PATH expected_calls = [ call(