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
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

View File

@ -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

View File

@ -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

View File

@ -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