X-Git-Url: http://www.average.org/gitweb/?a=blobdiff_plain;f=gps303%2Fgooglemaps.py;h=dac607959b6e102579dc66030275aec8e8e4f0f9;hb=c3bc6d5bbdc0d0bf10e338c6e3bad1a519d5afa0;hp=bb19a64578a071958bc0fe577a7a4fcec48d0236;hpb=1888de5a5dd4bdb85f3fb745341920a9996b278e;p=loctrkd.git diff --git a/gps303/googlemaps.py b/gps303/googlemaps.py index bb19a64..dac6079 100644 --- a/gps303/googlemaps.py +++ b/gps303/googlemaps.py @@ -1,17 +1,27 @@ import googlemaps as gmaps -from sqlite3 import connect +from typing import Any, Dict, List, Tuple gclient = None -def init(conf): +def init(conf: Dict[str, Any]) -> None: global gclient with open(conf["googlemaps"]["accesstoken"], encoding="ascii") as fl: token = fl.read().rstrip() gclient = gmaps.Client(key=token) -def lookup(mcc, mnc, gsm_cells, wifi_aps): +def shut() -> None: + return + + +def lookup( + mcc: int, + mnc: int, + gsm_cells: List[Tuple[int, int, int]], + wifi_aps: List[Tuple[str, int]], +) -> Tuple[float, float]: + assert gclient is not None kwargs = { "home_mobile_country_code": mcc, "home_mobile_network_code": mnc, @@ -39,6 +49,7 @@ def lookup(mcc, mnc, gsm_cells, wifi_aps): if __name__.endswith("__main__"): from datetime import datetime, timezone + from sqlite3 import connect import sys from .gps303proto import * @@ -47,7 +58,7 @@ if __name__.endswith("__main__"): c.execute( """select tstamp, packet from events where proto in (?, ?)""", - (WIFI_POSITIONING.PROTO, WIFI_OFFLINE_POSITIONING.PROTO), + (proto_name(WIFI_POSITIONING), proto_name(WIFI_OFFLINE_POSITIONING)), ) init({"googlemaps": {"accesstoken": sys.argv[2]}}) count = 0