X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=loctrkd%2Fwatch.py;fp=loctrkd%2Fwatch.py;h=bda952c259da36299fd5f8859b3c33363983720b;hb=023da3cd78841eb34d8286cf289995be658f0fa2;hp=6d3dcd9fa8ed7eb1f4eba1cdacd266549e9b2519;hpb=84861997657f7a8daab41aa13790981bd77749f8;p=loctrkd.git diff --git a/loctrkd/watch.py b/loctrkd/watch.py index 6d3dcd9..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("common", "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,12 +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) - if zmsg.is_incoming and hasattr(msg, "rectified"): - print(msg.rectified()) + 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