From bd16ad1e0c7c3756ab888312897e015bb8f0b9e3 Mon Sep 17 00:00:00 2001 From: Roland Date: Tue, 7 May 2024 10:50:26 -0600 Subject: [PATCH] Using truthy_arg for DOCKERIZED and CIRCLECI vars. --- wrolpi/vars.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/wrolpi/vars.py b/wrolpi/vars.py index ec1ac9fb..261a3cf7 100644 --- a/wrolpi/vars.py +++ b/wrolpi/vars.py @@ -12,13 +12,6 @@ PROJECT_DIR: Path = Path(__file__).parents[1].absolute() # Load any .env file. This may contain our MEDIA_DIRECTORY. load_dotenv(PROJECT_DIR / '.env') -# Special environment variable set in the docker/api/Dockerfile. -DOCKERIZED = True if os.environ.get('DOCKER', '').lower().startswith('t') else False -# tests are running -PYTEST = 'pytest' in sys.modules -# running on circlci -CIRCLECI = os.environ.get('CIRCLECI', '').strip().lower() == 'true' - def truthy_arg(value: str) -> bool: """Attempts to convert `value` from console arguments to a boolean value. @@ -46,6 +39,14 @@ def truthy_arg(value: str) -> bool: return v == 'true' or v == 't' or v == '1' or v == 'yes' or v == 'y' +# Special environment variable set in the docker/api/Dockerfile. +DOCKERIZED = truthy_arg(os.environ.get('DOCKER', '')) +# tests are running +PYTEST = 'pytest' in sys.modules + +# running on circlci +CIRCLECI = truthy_arg(os.environ.get('CIRCLECI', '')) + # Get the media directory from the environment. DEFAULT_MEDIA_DIRECTORY = Path('/media/wrolpi') MEDIA_DIRECTORY = Path(os.environ.get('MEDIA_DIRECTORY', DEFAULT_MEDIA_DIRECTORY))