]> www.average.org Git - loctrkd.git/blobdiff - gps303/termconfig.py
Update changelog for 0.99 release
[loctrkd.git] / gps303 / termconfig.py
index eb3150b49a17065aed2fc1d8898bc80ffa4e28b7..723e8f62766ef542dbdb337ae015c66203ff1b9c 100644 (file)
@@ -14,7 +14,6 @@ log = getLogger("gps303/termconfig")
 
 
 def runserver(conf: ConfigParser) -> None:
-    termconfig = common.normconf(conf["termconfig"])
     # Is this https://github.com/zeromq/pyzmq/issues/1627 still not fixed?!
     zctx = zmq.Context()  # type: ignore
     zsub = zctx.socket(zmq.SUB)  # type: ignore
@@ -43,6 +42,12 @@ def runserver(conf: ConfigParser) -> None:
                 log.error(
                     "%s does not expect externally provided response", msg
                 )
+            if zmsg.imei is not None and conf.has_section(zmsg.imei):
+                termconfig = common.normconf(conf[zmsg.imei])
+            elif conf.has_section("termconfig"):
+                termconfig = common.normconf(conf["termconfig"])
+            else:
+                termconfig = {}
             kwargs = {}
             if isinstance(msg, STATUS):
                 kwargs = {
@@ -71,7 +76,9 @@ def runserver(conf: ConfigParser) -> None:
             zpush.send(resp.packed)
 
     except KeyboardInterrupt:
-        pass
+        zsub.close()
+        zpush.close()
+        zctx.destroy()  # type: ignore
 
 
 if __name__.endswith("__main__"):