diff options
Diffstat (limited to 'scripts/common/__init__.py')
-rw-r--r-- | scripts/common/__init__.py | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/scripts/common/__init__.py b/scripts/common/__init__.py index e349610..e3ea442 100644 --- a/scripts/common/__init__.py +++ b/scripts/common/__init__.py @@ -6,7 +6,22 @@ import os import sys from datetime import datetime -QUEUE = bool(os.environ.get("el_QUEUE", False)) + +# Get env var +def env(var_name, default=None): + value = os.getenv(var_name) + if value is not None: + return value + + if default is not None: + return default + + print(f"Error: Could not find environment variable '{var_name}'") + print("That variable is required for running this program.") + sys.exit(1) + + +QUEUE = bool(env("el_QUEUE", False)) name = os.path.splitext(os.path.split(sys.argv[0])[-1])[0] |