X-Git-Url: http://average.org/gitweb/?a=blobdiff_plain;f=loctrkd%2Frectifier.py;h=161e2a9246ba449e023e9127648077b7dfeaf044;hb=f83cb02ad5c21b956ad739e18fb112f9f1cf46f4;hp=667651758ce996986da2a83521f6be55e4f4fb8a;hpb=f864ae02fafc77fa7ddda90dc11e81e5270bcb5c;p=loctrkd.git diff --git a/loctrkd/rectifier.py b/loctrkd/rectifier.py index 6676517..161e2a9 100644 --- a/loctrkd/rectifier.py +++ b/loctrkd/rectifier.py @@ -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,7 +98,7 @@ def runserver(conf: ConfigParser) -> None: rept = CoordReport( devtime=rect.devtime, battery_percentage=rect.battery_percentage, - accuracy=None, + accuracy=acc, altitude=None, speed=None, direction=None,