From d68f8969886e5929242e2c31aa2fabbd42c3f2cd Mon Sep 17 00:00:00 2001 From: Filip Rysavy <29089732+firyx@users.noreply.github.com> Date: Wed, 10 Nov 2021 13:46:43 +0100 Subject: [PATCH] Add check if Airtable vars are defined --- setup-scripts/blocklist-airtable.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/setup-scripts/blocklist-airtable.py b/setup-scripts/blocklist-airtable.py index e6563901..1173a90f 100755 --- a/setup-scripts/blocklist-airtable.py +++ b/setup-scripts/blocklist-airtable.py @@ -6,6 +6,7 @@ from time import sleep import traceback import os +import sys import re import asyncio import requests @@ -13,10 +14,17 @@ import json setup() -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") + +# Check and load Airtable environment variables +airtable_env_vars = ["AIRTABLE_API_KEY", "AIRTABLE_BASE", "AIRTABLE_TABLE", "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 + "\"") async def run_checks():