X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=gps303%2Fwatch.py;h=e66689ec33ebfd703c98eda5e5fc3c1a9f68302e;hb=b84a40a485b0563d572d14e748ad324185584344;hp=ed51ad19ebea040062d3e3cca1ead844bfb9e5af;hpb=9d43b364c397f1f50bd8620e487cbc8fc7189f20;p=loctrkd.git diff --git a/gps303/watch.py b/gps303/watch.py index ed51ad1..e66689e 100644 --- a/gps303/watch.py +++ b/gps303/watch.py @@ -1,26 +1,29 @@ """ Watch for locevt and print them """ +from configparser import ConfigParser from datetime import datetime, timezone from logging import getLogger import zmq from . import common +from .gps303proto import parse_message from .zmsg import Bcast log = getLogger("gps303/watch") -def runserver(conf): - zctx = zmq.Context() - zsub = zctx.socket(zmq.SUB) +def runserver(conf: ConfigParser) -> None: + # 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")) zsub.setsockopt(zmq.SUBSCRIBE, b"") try: while True: zmsg = Bcast(zsub.recv()) - msg = parse_message(zmsg.packet) - print(zmsg.imei, msg) + msg = parse_message(zmsg.packet, zmsg.is_incoming) + print("I" if zmsg.is_incoming else "O", zmsg.imei, msg) except KeyboardInterrupt: pass