move aprs_symbols_path to new config

This commit is contained in:
Jakob Ketterl 2021-02-07 00:21:57 +01:00
parent ee687d4e27
commit 88020b894e
4 changed files with 19 additions and 13 deletions

View File

@ -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 # beacon uses the receiver_gps setting, so if you enable this, make sure the location is correct there
aprs_igate_beacon = False 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 # 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: # Plese see Dire Wolf's documentation on PBEACON configuration for complete details:
# https://github.com/wb2osz/direwolf/raw/master/doc/User-Guide.pdf # https://github.com/wb2osz/direwolf/raw/master/doc/User-Guide.pdf

View File

@ -4,3 +4,7 @@ temporary_directory = /tmp
[web] [web]
port = 8073 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

View File

@ -63,10 +63,16 @@ class CoreConfig(object):
"web": { "web": {
"port": 8073, "port": 8073,
}, },
"aprs": {
"symbols_path": "/usr/share/aprs-symbols/png"
}
} }
def __init__(self): def __init__(self):
config = ConfigParser() config = ConfigParser()
# set up config defaults
config.read_dict(CoreConfig.defaults)
# check for overrides
overrides_dir = "/etc/openwebrx/openwebrx.conf.d" overrides_dir = "/etc/openwebrx/openwebrx.conf.d"
if os.path.exists(overrides_dir) and os.path.isdir(overrides_dir): if os.path.exists(overrides_dir) and os.path.isdir(overrides_dir):
overrides = glob(overrides_dir + "/*.conf") overrides = glob(overrides_dir + "/*.conf")
@ -74,15 +80,12 @@ class CoreConfig(object):
overrides = [] overrides = []
# sequence things together # sequence things together
config.read(["./openwebrx.conf", "/etc/openwebrx/openwebrx.conf"] + overrides) config.read(["./openwebrx.conf", "/etc/openwebrx/openwebrx.conf"] + overrides)
self.data_directory = config.get( self.data_directory = config.get("core", "data_directory")
"core", "data_directory", fallback=CoreConfig.defaults["core"]["data_directory"]
)
CoreConfig.checkDirectory(self.data_directory, "data_directory") CoreConfig.checkDirectory(self.data_directory, "data_directory")
self.temporary_directory = config.get( self.temporary_directory = config.get("core", "temporary_directory")
"core", "temporary_directory", fallback=CoreConfig.defaults["core"]["temporary_directory"]
)
CoreConfig.checkDirectory(self.temporary_directory, "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 @staticmethod
def checkDirectory(dir, key): def checkDirectory(dir, key):
@ -102,6 +105,9 @@ class CoreConfig(object):
def get_temporary_directory(self): def get_temporary_directory(self):
return self.temporary_directory return self.temporary_directory
def get_aprs_symbols_path(self):
return self.aprs_symbols_path
class Config: class Config:
sharedConfig = None sharedConfig = None

View File

@ -1,5 +1,5 @@
from . import Controller from . import Controller
from owrx.config import Config from owrx.config import CoreConfig
from datetime import datetime, timezone from datetime import datetime, timezone
import mimetypes import mimetypes
import os import os
@ -95,8 +95,7 @@ class OwrxAssetsController(AssetsController):
class AprsSymbolsController(AssetsController): class AprsSymbolsController(AssetsController):
def __init__(self, handler, request, options): def __init__(self, handler, request, options):
pm = Config.get() path = CoreConfig().get_aprs_symbols_path()
path = pm["aprs_symbols_path"]
if not path.endswith("/"): if not path.endswith("/"):
path += "/" path += "/"
self.path = path self.path = path