- return True
- out_str = ""
- if self.scanlist :
- start, end = self.scanlist.get_bounds()
- self.scanlist.delete( start , end )
- for net in scan_out.split() :
- self.nfp += 1
- items = net.rsplit(":", 1)
- out_str += " %s %s" % ( items[0] , items[1] )
- if self.scanlist :
- self.scanlist.insert_at_cursor( "%s %5d\n" % ( items[0] , int(items[1]) ) )
- self.aplist[ items[0] ] = 1
- self.refresh_infowin()
- if self._debug :
- # Use osso or hildon for notes ???
- osso.SystemNote(self.osso_context).system_note_infoprint("Found %d APs" % len(scan_out) )
- # hildon.hildon_banner_show_information( self._parent , "icon_path" , "Found %d APs" % len(scan_out) )
- else :
- fd = open( os.path.join( home_dir , "wiscan_gui.info" ) , 'a' )
- fd.write( "%s %s%s\n" % ( time.time() , self.gps_info , out_str ) )
- fd.close()
- if self.satellites :
- loclist = open( os.path.join( home_dir , "location.info" ) , 'a' )
- loclist.write ( "%s\n" % ( self.satellites ,) )
- loclist.close()
- if self.cell_info :
- celllist = open( os.path.join( home_dir , "cell.info" ) , 'a' )
- celllist.write ( "%s\n" % ( self.cell_info ,) )
- celllist.close()
-
- return True
-
- def set_infowin ( self , statuswin , listwin ) :
- gps.GPSObject.set_infowin( self , statuswin )
- self.scanlist = listwin
-
- def refresh_infowin ( self ) :
- if self.status :
- self.status.set_text( "%d gps\t%d scan\t%d fp\t%d ap" % ( self.ngps , self.nscan , self.nfp , len(self.aplist.keys()) ) )
-
-
-gobject.type_register(Scanner)
+
+ def __str__ ( self ) :
+ output = map( lambda x : "%s %s" % x , self.scanlist.iteritems() )
+ return " ".join( output )
+
+ def report ( self ) :
+ return "%d scan\t%d fp" % ( self.nscan , self.nfp )
+
+
+gobject.type_register(WifiScanner)
+
+if __name__ == "__main__" :
+ loop = gobject.MainLoop()
+ sample = WifiScanner()
+ sample.start()
+ def show_scan(sample):
+ gobject.timeout_add( 5000 , show_scan , sample )
+ print "scan results : %s" % sample.report()
+ c = 0
+ for k,v in sample.scanlist.iteritems() :
+ c += 1
+ print " %s %s" % ( k , v )
+ if c > 5 :
+ print " ..."
+ break
+ print
+ sample.scan()
+ gobject.timeout_add( 5100 , show_scan , sample )
+ loop.run()
+ sample.stop()