]> www.average.org Git - loctrkd.git/commitdiff
misc black reformatting
authorEugene Crosser <crosser@average.org>
Mon, 9 May 2022 15:44:45 +0000 (17:44 +0200)
committerEugene Crosser <crosser@average.org>
Mon, 9 May 2022 15:44:45 +0000 (17:44 +0200)
gps303/evstore.py
gps303/mkgpx.py
gps303/qry.py

index 76173624bed9069359f202f46d07e0eba3cc8491..bb47f3fb21c9c34c178955dbfad7e84e09828dbe 100644 (file)
@@ -20,8 +20,10 @@ def initdb(dbname):
     global DB
     DB = connect(dbname)
     try:
-        DB.execute("""alter table events add column
-                is_incoming int not null default TRUE""")
+        DB.execute(
+            """alter table events add column
+                is_incoming int not null default TRUE"""
+        )
     except OperationalError:
         DB.execute(SCHEMA)
 
@@ -50,14 +52,17 @@ def stow(**kwargs):
     )
     DB.commit()
 
+
 def fetch(imei, protos, backlog):
     assert DB is not None
     protosel = ", ".join(["?" for _ in range(len(protos))])
     cur = DB.cursor()
-    cur.execute(f"""select packet from events
+    cur.execute(
+        f"""select packet from events
                     where proto in ({protosel}) and imei = ?
                     order by tstamp desc limit ?""",
-                protos + (imei, backlog))
+        protos + (imei, backlog),
+    )
     result = [row[0] for row in cur]
     cur.close()
     return result
index 40588a0885791b347d5f3fc2ddb0f43a1b560cb6..f694b7ee80cd5c69de49805be79d1e18f2cf061b 100644 (file)
@@ -7,10 +7,24 @@ from .opencellid import qry_cell
 
 db = connect(sys.argv[1])
 c = db.cursor()
-c.execute("select tstamp, packet from events where proto in ({})"
-        .format(", ".join([str(n) for n in (WIFI_POSITIONING.PROTO, WIFI_OFFLINE_POSITIONING.PROTO, GPS_POSITIONING.PROTO, GPS_OFFLINE_POSITIONING.PROTO)])))
+c.execute(
+    "select tstamp, packet from events where proto in ({})".format(
+        ", ".join(
+            [
+                str(n)
+                for n in (
+                    WIFI_POSITIONING.PROTO,
+                    WIFI_OFFLINE_POSITIONING.PROTO,
+                    GPS_POSITIONING.PROTO,
+                    GPS_OFFLINE_POSITIONING.PROTO,
+                )
+            ]
+        )
+    )
+)
 
-print("""<?xml version="1.0"?>
+print(
+    """<?xml version="1.0"?>
 <gpx version="1.1"
 creator="gps303"
 xmlns="http://www.topografix.com/GPX/1/1">
@@ -18,7 +32,8 @@ xmlns="http://www.topografix.com/GPX/1/1">
   <trk>
     <name>Location Data</name>
     <trkseg>
-""")
+"""
+)
 
 for tstamp, packet in c:
     msg = parse_message(packet)
@@ -30,11 +45,15 @@ for tstamp, packet in c:
         lat, lon = msg.latitude, msg.longitude
     else:
         continue
-    isotime = datetime.fromtimestamp(tstamp).astimezone(tz=timezone.utc).isoformat()
-    isotime = isotime[:isotime.rfind(".")] + "Z"
+    isotime = (
+        datetime.fromtimestamp(tstamp).astimezone(tz=timezone.utc).isoformat()
+    )
+    isotime = isotime[: isotime.rfind(".")] + "Z"
     trkpt = """      <trkpt lat="{}" lon="{}">
           <time>{}</time>
-      </trkpt>""".format(lat, lon, isotime)
+      </trkpt>""".format(
+        lat, lon, isotime
+    )
     print(trkpt)
     if False:
         print(
@@ -43,6 +62,8 @@ for tstamp, packet in c:
             .isoformat(),
             msg,
         )
-print("""    </trkseg>
+print(
+    """    </trkseg>
   </trk>
-</gpx>""")
+</gpx>"""
+)
index 4aeb33c4a14ea3f9c8425ea2312e1d25775e3d43..25f55aab75f1470d13ff0c59ba575c2eb6e5c0ad 100644 (file)
@@ -16,19 +16,24 @@ else:
     selector = ""
 
 c.execute(
-    "select tstamp, imei, peeraddr, proto, packet from events" +
-    selector, {"proto": proto}
+    "select tstamp, imei, peeraddr, proto, packet from events" + selector,
+    {"proto": proto},
 )
 
 for tstamp, imei, peeraddr, proto, packet in c:
-    if len(packet) >  packet[0] + 1:
-        print("proto", packet[1] , "datalen", len(packet),
-                "msg.length", packet[0], file=sys.stderr)
+    if len(packet) > packet[0] + 1:
+        print(
+            "proto",
+            packet[1],
+            "datalen",
+            len(packet),
+            "msg.length",
+            packet[0],
+            file=sys.stderr,
+        )
     msg = parse_message(packet)
     print(
-        datetime.fromtimestamp(tstamp)
-        .astimezone(tz=timezone.utc)
-        .isoformat(),
+        datetime.fromtimestamp(tstamp).astimezone(tz=timezone.utc).isoformat(),
         imei,
         peeraddr,
         msg,