move bands and bookmarks to the config, too

This commit is contained in:
Jakob Ketterl 2019-12-08 21:00:01 +01:00
parent 3b32dc37c8
commit 5c8da76d9a
4 changed files with 29 additions and 10 deletions

View File

@ -1,2 +1,4 @@
config_webrx.py etc/
config_webrx.py etc/openwebrx/
bands.json etc/openwebrx/
bookmarks.json etc/openwebrx/
systemd/openwebrx.service lib/systemd/system/

View File

@ -46,10 +46,18 @@ class Bandplan(object):
return Bandplan.sharedInstance
def __init__(self):
f = open("bands.json", "r")
self.bands = self.loadBands()
def loadBands(self):
for file in ["/etc/openwebrx/bands.json", "bands.json"]:
try:
f = open(file, "r")
bands_json = json.load(f)
f.close()
self.bands = [Band(d) for d in bands_json]
return [Band(d) for d in bands_json]
except FileNotFoundError:
pass
return []
def findBands(self, freq):
return [band for band in self.bands if band.inBand(freq)]

View File

@ -34,10 +34,19 @@ class Bookmarks(object):
return Bookmarks.sharedInstance
def __init__(self):
f = open("bookmarks.json", "r")
self.bookmarks = self.loadBookmarks()
def loadBookmarks(self):
for file in ["/etc/openwebrx/bookmarks.json", "bookmarks.json"]:
try:
f = open(file, "r")
bookmarks_json = json.load(f)
f.close()
self.bookmarks = [Bookmark(d) for d in bookmarks_json]
return [Bookmark(d) for d in bookmarks_json]
except FileNotFoundError:
pass
return []
def getBookmarks(self, range):
(lo, hi) = range

View File

@ -134,7 +134,7 @@ class PropertyManager(object):
return self
def loadConfig(self):
for file in ["/etc/config_webrx.py", "./config_webrx.py"]:
for file in ["/etc/openwebrx/config_webrx.py", "./config_webrx.py"]:
try:
spec = importlib.util.spec_from_file_location("config_webrx", file)
cfg = importlib.util.module_from_spec(spec)