""" For when responding to the terminal is not trivial """
+from configparser import ConfigParser
from datetime import datetime, timezone
from logging import getLogger
from struct import pack
log = getLogger("gps303/termconfig")
-def runserver(conf):
+def runserver(conf: ConfigParser) -> None:
termconfig = common.normconf(conf["termconfig"])
- zctx = zmq.Context()
- zsub = zctx.socket(zmq.SUB)
+ # Is this https://github.com/zeromq/pyzmq/issues/1627 still not fixed?!
+ zctx = zmq.Context() # type: ignore
+ zsub = zctx.socket(zmq.SUB) # type: ignore
zsub.connect(conf.get("collector", "publishurl"))
- for protoname in (
- "STATUS",
- "SETUP",
- "POSITION_UPLOAD_INTERVAL",
+ for proto in (
+ STATUS.PROTO,
+ SETUP.PROTO,
+ POSITION_UPLOAD_INTERVAL.PROTO,
):
- tosub = topic(proto_by_name(protoname))
- zsub.setsockopt(zmq.SUBSCRIBE, tosub)
- zpush = zctx.socket(zmq.PUSH)
+ zsub.setsockopt(zmq.SUBSCRIBE, topic(proto))
+ zpush = zctx.socket(zmq.PUSH) # type: ignore
zpush.connect(conf.get("collector", "listenurl"))
try:
):
if key in termconfig:
kwargs[key] = termconfig[key]
- resp = Resp(imei=zmsg.imei, packet=msg.Out(**kwargs).packed)
+ resp = Resp(
+ imei=zmsg.imei, when=zmsg.when, packet=msg.Out(**kwargs).packed
+ )
log.debug("Response: %s", resp)
zpush.send(resp.packed)