X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=loctrkd%2Fwatch.py;h=b2b5c063f25ccc6e8eebf0e6c2044afd0f18ed40;hb=5ac485743c88a3814821bea386df01b9aaa1d4a1;hp=ab041edc832c7ae78198ea5deb3375d9e32dff29;hpb=63a086cf3956b93f760b1a0344afd757e0d0392f;p=loctrkd.git diff --git a/loctrkd/watch.py b/loctrkd/watch.py index ab041ed..b2b5c06 100644 --- a/loctrkd/watch.py +++ b/loctrkd/watch.py @@ -14,7 +14,9 @@ log = getLogger("loctrkd/watch") class ProtoModule: - PROTO_PREFIX: str + @staticmethod + def proto_handled(proto: str) -> bool: + ... @staticmethod def parse_message(packet: bytes, is_incoming: bool = True) -> Any: @@ -39,11 +41,11 @@ def runserver(conf: ConfigParser) -> None: try: while True: zmsg = Bcast(zsub.recv()) - print("Bcast:", zmsg) + print("I" if zmsg.is_incoming else "O", zmsg.proto, zmsg.imei) for pmod in pmods: - if zmsg.proto.startswith(pmod.PROTO_PREFIX): + if pmod.proto_handled(zmsg.proto): msg = pmod.parse_message(zmsg.packet, zmsg.is_incoming) - print("I" if zmsg.is_incoming else "O", zmsg.imei, msg) + print(msg) except KeyboardInterrupt: pass