diff --git a/debian/openwebrx.install b/debian/openwebrx.install index ab6fb3a..caa2fff 100644 --- a/debian/openwebrx.install +++ b/debian/openwebrx.install @@ -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/ \ No newline at end of file diff --git a/owrx/bands.py b/owrx/bands.py index bd74474..3ee5a5f 100644 --- a/owrx/bands.py +++ b/owrx/bands.py @@ -46,10 +46,18 @@ class Bandplan(object): return Bandplan.sharedInstance def __init__(self): - f = open("bands.json", "r") - bands_json = json.load(f) - f.close() - self.bands = [Band(d) for d in bands_json] + 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() + 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)] diff --git a/owrx/bookmarks.py b/owrx/bookmarks.py index f35d539..2b4925e 100644 --- a/owrx/bookmarks.py +++ b/owrx/bookmarks.py @@ -34,10 +34,19 @@ class Bookmarks(object): return Bookmarks.sharedInstance def __init__(self): - f = open("bookmarks.json", "r") - bookmarks_json = json.load(f) - f.close() - self.bookmarks = [Bookmark(d) for d in bookmarks_json] + 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() + return [Bookmark(d) for d in bookmarks_json] + except FileNotFoundError: + pass + return [] + def getBookmarks(self, range): (lo, hi) = range diff --git a/owrx/config.py b/owrx/config.py index ac287cc..820fee8 100644 --- a/owrx/config.py +++ b/owrx/config.py @@ -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)