]> www.average.org Git - loctrkd.git/blobdiff - loctrkd/rectifier.py
Update man pages to use correct name
[loctrkd.git] / loctrkd / rectifier.py
index 1da57528d733a52df0be0955f18d7d29ce86d49b..161e2a9246ba449e023e9127648077b7dfeaf044 100644 (file)
@@ -31,7 +31,7 @@ class QryModule:
         mnc: int,
         gsm_cells: List[Tuple[int, int, int]],
         wifi_aps: List[Tuple[str, int]],
-    ) -> Tuple[float, float]:
+    ) -> Tuple[float, float, float]:
         ...
 
 
@@ -51,7 +51,9 @@ def runserver(conf: ConfigParser) -> None:
     zpush = zctx.socket(zmq.PUSH)  # type: ignore
     zpush.connect(conf.get("collector", "listenurl"))
     zpub = zctx.socket(zmq.PUB)  # type: ignore
+    oldmask = umask(0o117)
     zpub.bind(conf.get("rectifier", "publishurl"))
+    umask(oldmask)
 
     try:
         while True:
@@ -66,20 +68,24 @@ def runserver(conf: ConfigParser) -> None:
                 datetime.fromtimestamp(zmsg.when).astimezone(tz=timezone.utc),
                 msg,
             )
-            rect: Report = msg.rectified()
+            rect = msg.rectified()
             log.debug("rectified: %s", rect)
             if isinstance(rect, (CoordReport, StatusReport)):
                 zpub.send(Rept(imei=zmsg.imei, payload=rect.json).packed)
             elif isinstance(rect, HintReport):
                 try:
-                    lat, lon = qry.lookup(
+                    lat, lon, acc = qry.lookup(
                         rect.mcc,
                         rect.mnc,
                         rect.gsm_cells,
                         list((mac, strng) for _, mac, strng in rect.wifi_aps),
                     )
                     log.debug(
-                        "Approximated lat=%s, lon=%s for %s", lat, lon, rect
+                        "Approximated lat=%s, lon=%s, acc=%s for %s",
+                        lat,
+                        lon,
+                        acc,
+                        rect,
                     )
                     if proto_needanswer.get(zmsg.proto, False):
                         resp = Resp(
@@ -92,10 +98,10 @@ def runserver(conf: ConfigParser) -> None:
                     rept = CoordReport(
                         devtime=rect.devtime,
                         battery_percentage=rect.battery_percentage,
-                        accuracy=-1,
-                        altitude=-1,
-                        speed=-1,
-                        direction=-1,
+                        accuracy=acc,
+                        altitude=None,
+                        speed=None,
+                        direction=None,
                         latitude=lat,
                         longitude=lon,
                     )
@@ -107,7 +113,7 @@ def runserver(conf: ConfigParser) -> None:
                         ).packed
                     )
                 except Exception as e:
-                    log.warning(
+                    log.exception(
                         "Lookup for %s rectified as %s resulted in %s",
                         msg,
                         rect,