1313NMSCAN = ['nmcli' ,'device' ,'wifi' ,'rescan' ]
1414HEADER = 'time lat lon accuracy NumBSSIDs'
1515
16-
16+ # %%
1717def logwifiloc (T :float , logfile :Path ):
1818
1919 if logfile :
@@ -30,7 +30,7 @@ def logwifiloc(T:float, logfile:Path):
3030 sleep (T )
3131 continue
3232
33- stat = f'{ loc ["t" ].strftime ( "%xT%X " )} { loc ["lat" ]} { loc ["lng" ]} { loc ["accuracy" ]:.1f} { loc ["N" ]:02d} '
33+ stat = f'{ loc ["t" ].isoformat ( timespec = "seconds " )} { loc ["lat" ]} { loc ["lng" ]} { loc ["accuracy" ]:.1f} { loc ["N" ]:02d} '
3434 print (stat )
3535
3636 if logfile :
@@ -39,14 +39,14 @@ def logwifiloc(T:float, logfile:Path):
3939
4040 sleep (T )
4141
42-
42+ # %%
4343def get_nmcli ():
4444
4545
46- ret = subprocess .check_output (NMLEG , universal_newlines = True )
46+ ret = subprocess .check_output (NMLEG , universal_newlines = True , timeout = 1. )
4747 sleep (0.5 ) # nmcli crashed for less than about 0.2 sec.
4848 try :
49- subprocess .check_call (NMSCAN ) # takes several seconds to update, so do it now.
49+ subprocess .check_call (NMSCAN , timeout = 1. ) # takes several seconds to update, so do it now.
5050 except subprocess .CalledProcessError as e :
5151 logging .error (f'consider slowing scan cadence. { e } ' )
5252
@@ -101,14 +101,12 @@ def csv2kml(csvfn:Path, kmlfn:Path):
101101# %% write KML
102102 """
103103 http://simplekml.readthedocs.io/en/latest/geometries.html#gxtrack
104+ https://simplekml.readthedocs.io/en/latest/kml.html#id1
105+ https://simplekml.readthedocs.io/en/latest/geometries.html#simplekml.GxTrack
104106 """
105- kml = Kml (name = 'My Kml' ,open = 1 )
106-
107-
108- doc = kml .newdocument (name = 'Mozilla Location Services' )
109- fol = doc .newfolder (name = 'Tracks' )
110- trk = fol .newgxtrack (name = 'My Track' )
111- trk .newwhen (t ) # list of times
107+ kml = Kml (name = 'My Kml' )
108+ trk = kml .newgxtrack (name = 'My Track' )
109+ trk .newwhen (t ) # list of times. MUST be format 2010-05-28T02:02:09Z
112110 trk .newgxcoord (lla .tolist ()) #list of lon,lat,alt, NOT ndarray!
113111
114112# just a bunch of points
0 commit comments