13
13
NMSCAN = ['nmcli' ,'device' ,'wifi' ,'rescan' ]
14
14
HEADER = 'time lat lon accuracy NumBSSIDs'
15
15
16
-
16
+ # %%
17
17
def logwifiloc (T :float , logfile :Path ):
18
18
19
19
if logfile :
@@ -30,7 +30,7 @@ def logwifiloc(T:float, logfile:Path):
30
30
sleep (T )
31
31
continue
32
32
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} '
34
34
print (stat )
35
35
36
36
if logfile :
@@ -39,14 +39,14 @@ def logwifiloc(T:float, logfile:Path):
39
39
40
40
sleep (T )
41
41
42
-
42
+ # %%
43
43
def get_nmcli ():
44
44
45
45
46
- ret = subprocess .check_output (NMLEG , universal_newlines = True )
46
+ ret = subprocess .check_output (NMLEG , universal_newlines = True , timeout = 1. )
47
47
sleep (0.5 ) # nmcli crashed for less than about 0.2 sec.
48
48
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.
50
50
except subprocess .CalledProcessError as e :
51
51
logging .error (f'consider slowing scan cadence. { e } ' )
52
52
@@ -101,14 +101,12 @@ def csv2kml(csvfn:Path, kmlfn:Path):
101
101
# %% write KML
102
102
"""
103
103
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
104
106
"""
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
112
110
trk .newgxcoord (lla .tolist ()) #list of lon,lat,alt, NOT ndarray!
113
111
114
112
# just a bunch of points
0 commit comments