mirror of
https://git.ianrenton.com/ian/spothole.git
synced 2026-06-24 05:35:10 +00:00
40 lines
1.9 KiB
Python
40 lines
1.9 KiB
Python
import logging
|
|
import os
|
|
|
|
import yaml
|
|
|
|
# Check you have a config file
|
|
if not os.path.isfile("config.yml"):
|
|
logging.error(
|
|
"Your config file is missing. Ensure you have copied config-example.yml to config.yml and updated it according to your needs.")
|
|
exit()
|
|
|
|
# Load config
|
|
with open("config.yml") as f:
|
|
config = yaml.safe_load(f)
|
|
logging.info("Loaded config.")
|
|
|
|
BASE_URL = config.get("base-url", "http://localhost:8080")
|
|
MAX_SPOT_AGE = config.get("max-spot-age-sec", 3600)
|
|
MAX_ALERT_AGE = config.get("max-alert-age-sec", 604800)
|
|
SERVER_OWNER_CALLSIGN = config.get("server-owner-callsign", "N0CALL")
|
|
WEB_SERVER_PORT = config.get("web-server-port", 8080)
|
|
ALLOW_SPOTTING = config.get("allow-spotting", True)
|
|
ALLOW_UPSTREAM_SPOTTING = config.get("allow-upstream-spotting", True)
|
|
WEB_UI_OPTIONS = config.get("web-ui-options", {})
|
|
API_ONLY_MODE = config.get("api-only-mode", False)
|
|
RECAPTCHA_SECRET_KEY = config.get("recaptcha-secret-key", "")
|
|
RECAPTCHA_SITE_KEY = config.get("recaptcha-site-key", "")
|
|
|
|
# For ease of config, each spot provider owns its own config about whether it should be enabled by default in the web UI
|
|
# but for consistency we provide this to the front-end in web-ui-options because it has no impact outside of the web UI.
|
|
WEB_UI_OPTIONS["spot-providers-enabled-by-default"] = [p["name"] for p in config["spot-providers"] if p["enabled"] and (
|
|
"enabled-by-default-in-web-ui" not in p or p["enabled-by-default-in-web-ui"])]
|
|
# If spotting to this server is enabled, "API" is another valid spot source even though it does not come from
|
|
# one of our proviers. We set that to also be enabled by default. We can also include the reCaptcha site key so the UI
|
|
# can access it.
|
|
if ALLOW_SPOTTING:
|
|
WEB_UI_OPTIONS["spot-providers-enabled-by-default"].append("API")
|
|
WEB_UI_OPTIONS["recaptcha-site-key"] = RECAPTCHA_SITE_KEY
|
|
WEB_UI_OPTIONS["allow-upstream-spotting"] = ALLOW_SPOTTING and ALLOW_UPSTREAM_SPOTTING
|