X-Git-Url: http://www.average.org/gitweb/?a=blobdiff_plain;f=loctrkd%2Fcollector.py;h=788cb11ca1ee8b186838ea1ef882a5b6faf4ea83;hb=042f003133249fb38d87d92faa9c730833d14904;hp=17c98d5d98326af76dad80c2dc760bb3fb19c4ce;hpb=9bf81b19b7b790bc2115ac08dc1f3c112aede976;p=loctrkd.git diff --git a/loctrkd/collector.py b/loctrkd/collector.py index 17c98d5..788cb11 100644 --- a/loctrkd/collector.py +++ b/loctrkd/collector.py @@ -14,7 +14,7 @@ from socket import ( ) from struct import pack from time import time -from typing import Any, cast, Dict, List, Optional, Set, Tuple, Union +from typing import Any, Dict, List, Optional, Set, Tuple, Union import zmq from . import common @@ -26,9 +26,6 @@ log = getLogger("loctrkd/collector") MAXBUFFER: int = 4096 -pmods: List[ProtoModule] = [] - - class Client: """Connected socket to the terminal plus buffer and metadata""" @@ -71,11 +68,9 @@ class Client: ) return None if self.stream is None: - for pmod in pmods: - if pmod.probe_buffer(segment): - self.pmod = pmod - self.stream = pmod.Stream() - break + self.pmod = common.probe_pmod(segment) + if self.pmod is not None: + self.stream = self.pmod.Stream() if self.stream is None: log.info( "unrecognizable %d bytes of data %s from fd %d", @@ -181,11 +176,6 @@ class Clients: def runserver(conf: ConfigParser, handle_hibernate: bool = True) -> 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 zpub = zctx.socket(zmq.PUB) # type: ignore