import time
-import gps
+import gps , db
import gobject
self.nfp = 0
self.scanlist = None
self.aplist = {}
+ self.db = db.database( os.path.join( home_dir , "wifiscanner.db" ) )
def start ( self ) :
osso_rpc = osso.Rpc(self.osso_context)
scan_out = osso_rpc.rpc_run("org.javiplx.wifiscan", "/org/javiplx/wifiscan", "org.javiplx.wifiscan", "start")
+ self.db.open()
def stop ( self ) :
osso_rpc = osso.Rpc(self.osso_context)
scan_out = osso_rpc.rpc_run("org.javiplx.wifiscan", "/org/javiplx/wifiscan", "org.javiplx.wifiscan", "stop")
+ self.db.close()
def scan ( self ) :
+ timestamp = time.time()
osso_rpc = osso.Rpc(self.osso_context)
try :
scan_out = osso_rpc.rpc_run("org.javiplx.wifiscan", "/org/javiplx/wifiscan", "org.javiplx.wifiscan", "scan", wait_reply = True)
out_str += " %s %s" % ( items[0] , items[1] )
if self.scanlist :
self.scanlist.insert_at_cursor( "%s %5d\n" % ( items[0] , int(items[1]) ) )
+ stored = self.db.get( items[0] )
+ if stored :
+ max_rss = int(items[1])
+ if stored[0] > max_rss :
+ max_rss = stored[0]
+ self.db.update( items[0] , max_rss , timestamp )
+ else :
+ self.db.add( items[0] , int(items[1]) , timestamp )
self.aplist[ items[0] ] = 1
self.refresh_infowin()
if self._debug :
# 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.write( "%s %s%s\n" % ( timestamp , self.gps_info , out_str ) )
fd.close()
if self.satellites :
loclist = open( os.path.join( home_dir , "location.info" ) , 'a' )
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()) ) )
+ self.status.set_text( "%d gps\t%d scan\t%d fp\t%d ap\t%d total ap" % ( self.ngps , self.nscan , self.nfp , len(self.aplist.keys()) , self.db.nrows() ) )
gobject.type_register(Scanner)