This changed a bunch of code but no Reviewed-on: #17 Co-authored-by: ahtlon <git@ahtlon.de> Co-committed-by: ahtlon <git@ahtlon.de>
30 lines
983 B
Python
30 lines
983 B
Python
import logging
|
|
import os
|
|
|
|
logger = logging.getLogger(__name__)
|
|
|
|
|
|
def verify_settings():
|
|
card_envs = [
|
|
"MIFARE_APP_MASTER_KEY",
|
|
"MIFARE_ACL_READ_BASE_KEY",
|
|
"MIFARE_ACL_WRITE_BASE_KEY",
|
|
]
|
|
important_envs = ["SECRET_KEY"]
|
|
other_envs = ["SQLALCHEMY_DATABASE_URL"]
|
|
for setting in card_envs:
|
|
if (setting not in os.environ or setting == "") and not os.getenv(
|
|
"DISABLE_CARDS"
|
|
):
|
|
raise ValueError(
|
|
f"Missing environment variable for scanner start: {setting} \n Run with DISABLE_CARDS env var to disable cards"
|
|
)
|
|
for setting in important_envs:
|
|
if setting not in os.environ or setting == "":
|
|
raise ValueError(
|
|
f"Missing critical environment variable {setting}. Stopping..."
|
|
)
|
|
for setting in other_envs:
|
|
if setting not in os.environ:
|
|
logger.critical(f"Env var {setting} not set. Continuing with defaults.")
|