X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=loctrkd%2Fwatch.py;h=bda952c259da36299fd5f8859b3c33363983720b;hb=456fcc5a8964c84385d34a6687e83ae05ab2ddc3;hp=006ec06d18ab8505c5b712e891f03eb56184b0a2;hpb=cbb7603aebedf517d7b7c61ff6de02d3e7193409;p=loctrkd.git diff --git a/loctrkd/watch.py b/loctrkd/watch.py index 006ec06..bda952c 100644 --- a/loctrkd/watch.py +++ b/loctrkd/watch.py @@ -14,15 +14,7 @@ from .zmsg import Bcast log = getLogger("loctrkd/watch") -pmods: List[ProtoModule] = [] - - def runserver(conf: ConfigParser) -> None: - global pmods - pmods = [ - cast(ProtoModule, import_module("." + modnm, __package__)) - for modnm in conf.get("collector", "protocols").split(",") - ] # Is this https://github.com/zeromq/pyzmq/issues/1627 still not fixed?! zctx = zmq.Context() # type: ignore zsub = zctx.socket(zmq.SUB) # type: ignore @@ -33,10 +25,12 @@ def runserver(conf: ConfigParser) -> None: while True: zmsg = Bcast(zsub.recv()) print("I" if zmsg.is_incoming else "O", zmsg.proto, zmsg.imei) - for pmod in pmods: - if pmod.proto_handled(zmsg.proto): - msg = pmod.parse_message(zmsg.packet, zmsg.is_incoming) - print(msg) + pmod = common.pmod_for_proto(zmsg.proto) + if pmod is not None: + msg = pmod.parse_message(zmsg.packet, zmsg.is_incoming) + print(msg) + if zmsg.is_incoming and hasattr(msg, "rectified"): + print(msg.rectified()) except KeyboardInterrupt: pass