From 9bf81b19b7b790bc2115ac08dc1f3c112aede976 Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Tue, 26 Jul 2022 17:09:40 +0200 Subject: [PATCH] Adjust config to changing messaging topology --- debian/loctrkd.conf | 13 ++++++++++--- loctrkd/__main__.py | 2 +- loctrkd/collector.py | 2 +- loctrkd/mkgpx.py | 2 +- loctrkd/qry.py | 2 +- loctrkd/rectifier.py | 2 +- loctrkd/watch.py | 2 +- loctrkd/wsgateway.py | 2 +- test/common.py | 6 ++++-- 9 files changed, 21 insertions(+), 12 deletions(-) diff --git a/debian/loctrkd.conf b/debian/loctrkd.conf index 9f45a08..a281043 100644 --- a/debian/loctrkd.conf +++ b/debian/loctrkd.conf @@ -1,11 +1,13 @@ +[common] +# comma-separated list of tracker protocols to accept +protocols = zx303proto,beesure + [collector] # configure your gps terminal with this SMS: # "server##4303#" port = 4303 publishurl = ipc:///var/lib/loctrkd/collected listenurl = ipc:///var/lib/loctrkd/responses -# comma-separated list of tracker protocols to accept -protocols = zx303proto [wsgateway] port = 5049 @@ -18,7 +20,8 @@ dbfn = /var/lib/loctrkd/trkloc.sqlite # "opencellid" and "googlemaps" can be here. Both require an access token, # though googlemaps is only online, while opencellid backend looks up a # local database, that can be updated once a week or once a month. -backend = opencellid +lookaside = opencellid +publishurl = ipc:///var/lib/loctrkd/rectified [opencellid] dbfn = /var/lib/opencellid/opencellid.sqlite @@ -28,6 +31,10 @@ dbfn = /var/lib/opencellid/opencellid.sqlite downloadtoken = /var/lib/opencellid/opencellid.token downloadmcc = 262 +# For googlemaps lookaside backend, specify the token +# [googlemaps] +# accesstoken = google.token + [termconfig] statusIntervalMinutes = 25 uploadIntervalSeconds = 0x0300 diff --git a/loctrkd/__main__.py b/loctrkd/__main__.py index 10a2bf8..bba38ff 100644 --- a/loctrkd/__main__.py +++ b/loctrkd/__main__.py @@ -26,7 +26,7 @@ def main( global pmods pmods = [ cast(ProtoModule, import_module("." + modnm, __package__)) - for modnm in conf.get("collector", "protocols").split(",") + for modnm in conf.get("common", "protocols").split(",") ] # Is this https://github.com/zeromq/pyzmq/issues/1627 still not fixed?! zctx = zmq.Context() # type: ignore diff --git a/loctrkd/collector.py b/loctrkd/collector.py index 75cd33b..17c98d5 100644 --- a/loctrkd/collector.py +++ b/loctrkd/collector.py @@ -184,7 +184,7 @@ def runserver(conf: ConfigParser, handle_hibernate: bool = True) -> None: global pmods pmods = [ cast(ProtoModule, import_module("." + modnm, __package__)) - for modnm in conf.get("collector", "protocols").split(",") + for modnm in conf.get("common", "protocols").split(",") ] # Is this https://github.com/zeromq/pyzmq/issues/1627 still not fixed?! zctx = zmq.Context() # type: ignore diff --git a/loctrkd/mkgpx.py b/loctrkd/mkgpx.py index 6c1ce00..35ff77e 100644 --- a/loctrkd/mkgpx.py +++ b/loctrkd/mkgpx.py @@ -28,7 +28,7 @@ def main( global pmods pmods = [ cast(ProtoModule, import_module("." + modnm, __package__)) - for modnm in conf.get("collector", "protocols").split(",") + for modnm in conf.get("common", "protocols").split(",") ] db = connect(conf.get("storage", "dbfn")) c = db.cursor() diff --git a/loctrkd/qry.py b/loctrkd/qry.py index 6745cf2..fc647c7 100644 --- a/loctrkd/qry.py +++ b/loctrkd/qry.py @@ -24,7 +24,7 @@ def main( global pmods pmods = [ cast(ProtoModule, import_module("." + modnm, __package__)) - for modnm in conf.get("collector", "protocols").split(",") + for modnm in conf.get("common", "protocols").split(",") ] db = connect(conf.get("storage", "dbfn")) c = db.cursor() diff --git a/loctrkd/rectifier.py b/loctrkd/rectifier.py index 5ef6d35..5919cbd 100644 --- a/loctrkd/rectifier.py +++ b/loctrkd/rectifier.py @@ -16,7 +16,7 @@ log = getLogger("loctrkd/rectifier") def runserver(conf: ConfigParser) -> None: - qry = import_module("." + conf.get("rectifier", "backend"), __package__) + qry = import_module("." + conf.get("rectifier", "lookaside"), __package__) qry.init(conf) # Is this https://github.com/zeromq/pyzmq/issues/1627 still not fixed?! zctx = zmq.Context() # type: ignore diff --git a/loctrkd/watch.py b/loctrkd/watch.py index 006ec06..8e962bc 100644 --- a/loctrkd/watch.py +++ b/loctrkd/watch.py @@ -21,7 +21,7 @@ def runserver(conf: ConfigParser) -> None: global pmods pmods = [ cast(ProtoModule, import_module("." + modnm, __package__)) - for modnm in conf.get("collector", "protocols").split(",") + for modnm in conf.get("common", "protocols").split(",") ] # Is this https://github.com/zeromq/pyzmq/issues/1627 still not fixed?! zctx = zmq.Context() # type: ignore diff --git a/loctrkd/wsgateway.py b/loctrkd/wsgateway.py index 01a8042..b6d10e8 100644 --- a/loctrkd/wsgateway.py +++ b/loctrkd/wsgateway.py @@ -261,7 +261,7 @@ def runserver(conf: ConfigParser) -> None: global htmlfile, pmods, selector pmods = [ cast(ProtoModule, import_module("." + modnm, __package__)) - for modnm in conf.get("collector", "protocols").split(",") + for modnm in conf.get("common", "protocols").split(",") ] for pmod in pmods: for proto, is_incoming in pmod.exposed_protos(): diff --git a/test/common.py b/test/common.py index 761ea67..17fde96 100644 --- a/test/common.py +++ b/test/common.py @@ -39,11 +39,13 @@ class TestWithServers(TestCase): freeports.append(sk.getsockname()[1]) _, self.tmpfilebase = mkstemp() self.conf = ConfigParser() + self.conf["common"] = { + "protocols": "zx303proto", + } self.conf["collector"] = { "port": str(freeports[0]), "publishurl": "ipc://" + self.tmpfilebase + ".pub", "listenurl": "ipc://" + self.tmpfilebase + ".pul", - "protocols": "zx303proto", } self.conf["storage"] = { "dbfn": self.tmpfilebase + ".storage.sqlite", @@ -53,7 +55,7 @@ class TestWithServers(TestCase): "downloadurl": f"http://localhost:{freeports[2]}/test/262.csv.gz", } self.conf["rectifier"] = { - "backend": "opencellid", + "lookaside": "opencellid", } self.conf["wsgateway"] = { "port": str(freeports[1]), -- 2.43.0