From 88020b894ee2074e7a9e2833d3d0df65ffafbea9 Mon Sep 17 00:00:00 2001 From: Jakob Ketterl Date: Sun, 7 Feb 2021 00:21:57 +0100 Subject: [PATCH] move aprs_symbols_path to new config --- config_webrx.py | 3 --- openwebrx.conf | 4 ++++ owrx/config.py | 20 +++++++++++++------- owrx/controllers/assets.py | 5 ++--- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/config_webrx.py b/config_webrx.py index 7ec053b..46efb19 100644 --- a/config_webrx.py +++ b/config_webrx.py @@ -341,9 +341,6 @@ aprs_igate_password = "" # beacon uses the receiver_gps setting, so if you enable this, make sure the location is correct there aprs_igate_beacon = False -# path to the aprs symbols repository (get it here: https://github.com/hessu/aprs-symbols) -aprs_symbols_path = "/usr/share/aprs-symbols/png" - # Uncomment the following to customize gateway beacon details reported to the aprs network # Plese see Dire Wolf's documentation on PBEACON configuration for complete details: # https://github.com/wb2osz/direwolf/raw/master/doc/User-Guide.pdf diff --git a/openwebrx.conf b/openwebrx.conf index b0d8500..32a0f77 100644 --- a/openwebrx.conf +++ b/openwebrx.conf @@ -4,3 +4,7 @@ temporary_directory = /tmp [web] port = 8073 + +[aprs] +# path to the aprs symbols repository (get it here: https://github.com/hessu/aprs-symbols) +symbols_path = /usr/share/aprs-symbols/png diff --git a/owrx/config.py b/owrx/config.py index 89efd2a..b634477 100644 --- a/owrx/config.py +++ b/owrx/config.py @@ -63,10 +63,16 @@ class CoreConfig(object): "web": { "port": 8073, }, + "aprs": { + "symbols_path": "/usr/share/aprs-symbols/png" + } } def __init__(self): config = ConfigParser() + # set up config defaults + config.read_dict(CoreConfig.defaults) + # check for overrides overrides_dir = "/etc/openwebrx/openwebrx.conf.d" if os.path.exists(overrides_dir) and os.path.isdir(overrides_dir): overrides = glob(overrides_dir + "/*.conf") @@ -74,15 +80,12 @@ class CoreConfig(object): overrides = [] # sequence things together config.read(["./openwebrx.conf", "/etc/openwebrx/openwebrx.conf"] + overrides) - self.data_directory = config.get( - "core", "data_directory", fallback=CoreConfig.defaults["core"]["data_directory"] - ) + self.data_directory = config.get("core", "data_directory") CoreConfig.checkDirectory(self.data_directory, "data_directory") - self.temporary_directory = config.get( - "core", "temporary_directory", fallback=CoreConfig.defaults["core"]["temporary_directory"] - ) + self.temporary_directory = config.get("core", "temporary_directory") CoreConfig.checkDirectory(self.temporary_directory, "temporary_directory") - self.web_port = config.getint("web", "port", fallback=CoreConfig.defaults["web"]["port"]) + self.web_port = config.getint("web", "port") + self.aprs_symbols_path = config.get("aprs", "symbols_path") @staticmethod def checkDirectory(dir, key): @@ -102,6 +105,9 @@ class CoreConfig(object): def get_temporary_directory(self): return self.temporary_directory + def get_aprs_symbols_path(self): + return self.aprs_symbols_path + class Config: sharedConfig = None diff --git a/owrx/controllers/assets.py b/owrx/controllers/assets.py index 803dec9..88338b5 100644 --- a/owrx/controllers/assets.py +++ b/owrx/controllers/assets.py @@ -1,5 +1,5 @@ from . import Controller -from owrx.config import Config +from owrx.config import CoreConfig from datetime import datetime, timezone import mimetypes import os @@ -95,8 +95,7 @@ class OwrxAssetsController(AssetsController): class AprsSymbolsController(AssetsController): def __init__(self, handler, request, options): - pm = Config.get() - path = pm["aprs_symbols_path"] + path = CoreConfig().get_aprs_symbols_path() if not path.endswith("/"): path += "/" self.path = path