8 conf = config.Configuration()
10 class ReplayScanner ( gobject.GObject ) :
12 def __init__ ( self ) :
13 gobject.GObject.__init__( self )
16 # Values specific to replaying
17 self._file = os.path.join( conf.homedir , "wiscan_gui.info" )
21 # Values to be set by GPSDevice changed events
22 self.info = None, 0, 0, None, None, None, None
23 self.satellites = None
27 # Values to be set by wireless scans
33 # Values from the Scanner object
36 def start ( self , timeout=5000 ) :
37 self.scan_timeout = timeout
38 self._fd = open( self._file )
39 self._current = self._fd.readline().split()
47 if not self.scan_timeout :
50 next = self._fd.readline().split()
51 delta = float(next[0]) - float(self._current[0])
52 gobject.timeout_add( int(1000 * delta) , self.scan )
54 self.info = self._current[1:8]
55 if self.info[0] == "FIX" :
60 self.tstamp = float(self._current[0])
61 for n in range(11, len(self._current), 2) :
63 self.scanlist[ self._current[n] ] = int(self._current[n+1])
68 return "%d gps\t%d scan\t%d fp\t%d ap\t%d total ap" % ( self.ngps , self.nscan , self.nfp , self.newap , -1 )
71 gobject.type_register(ReplayScanner)
73 if __name__ == "__main__" :
74 loop = gobject.MainLoop()
75 sample = ReplayScanner()
76 def show_scan(wifiscanner):
77 gobject.timeout_add( 5000 , show_scan , sample )
78 print "scan results %s" % wifiscanner.report()
79 print " tstamp %s" % wifiscanner.tstamp
81 for k,v in wifiscanner.scanlist.iteritems() :
83 print " %s %s" % ( k , v )
90 gobject.timeout_add( 5100 , show_scan , sample )