]> www.average.org Git - loctrkd.git/blobdiff - loctrkd/__main__.py
abstract protocol selection in `common`
[loctrkd.git] / loctrkd / __main__.py
index c3dcb4b35e379be6db682b200df163a7ee3105b3..8808c8a31c092fdc78dc2a674f5932740622a865 100644 (file)
@@ -3,14 +3,15 @@
 from configparser import ConfigParser
 from datetime import datetime, timezone
 from getopt import getopt
+from importlib import import_module
 from logging import getLogger
 from sys import argv
 from time import time
-from typing import List, Tuple
+from typing import Any, cast, List, Tuple, Type, Union
 import zmq
 
 from . import common
-from .zx303proto import *
+from .protomodule import ProtoModule
 from .zmsg import Bcast, Resp
 
 log = getLogger("loctrkd")
@@ -31,7 +32,10 @@ def main(
     imei = args[0]
     cmd = args[1]
     args = args[2:]
-    cls = class_by_prefix(cmd)
+    pmod = common.pmod_for_proto(cmd)
+    if pmod is None:
+        raise NotImplementedError(f"No protocol can handle {cmd}")
+    cls = pmod.class_by_prefix(cmd)
     if isinstance(cls, list):
         raise ValueError("Prefix does not select a single class: " + str(cls))
     kwargs = dict([arg.split("=") for arg in args])