From efeddd6c70e9de9d0b4204fd2d70d70f778829f2 Mon Sep 17 00:00:00 2001 From: Filip Rysavy <29089732+firyx@users.noreply.github.com> Date: Wed, 10 Nov 2021 14:22:00 +0100 Subject: [PATCH] Add check if Airtable vars are defined --- setup-scripts/blocklist-airtable.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/setup-scripts/blocklist-airtable.py b/setup-scripts/blocklist-airtable.py index d5bd360e..d0279e5f 100755 --- a/setup-scripts/blocklist-airtable.py +++ b/setup-scripts/blocklist-airtable.py @@ -15,16 +15,15 @@ import json setup() -# Check and load Airtable environment variables -airtable_env_vars = ["AIRTABLE_API_KEY", "AIRTABLE_BASE", "AIRTABLE_TABLE", "AIRTABLE_FIELD"] +AIRTABLE_API_KEY = os.getenv("AIRTABLE_API_KEY") +AIRTABLE_BASE = os.getenv("AIRTABLE_BASE") +AIRTABLE_TABLE = os.getenv("AIRTABLE_TABLE") +AIRTABLE_FIELD = os.getenv("AIRTABLE_FIELD") -for e in airtable_env_vars: - # Check environment variable is defined - gete = os.getenv(e) - if not gete: - sys.exit("Configuration error: Environment variable " + e + " is not defined") - # Set variable - exec(e + " = \"" + gete + "\"") +# Check environment variables are defined +for e in [AIRTABLE_API_KEY, AIRTABLE_BASE, AIRTABLE_TABLE, AIRTABLE_FIELD] + if not e: + sys.exit("Configuration error: Missing AirTable environment variable.") async def run_checks():