Improvement and code reorganization of GPSObject
[wifihood] / wifimap / scanner.py
index 2707e94..728695b 100644 (file)
@@ -38,8 +38,8 @@ class Scanner ( gps.GPSObject , wifiscan.WifiScanner ) :
     def scan ( self ) :
         wifiscan.WifiScanner.scan( self )
         latlon = None
-        if self.gps_state == "FIX" :
-            latlon = self.gps_info[4] , self.gps_info[5] , self.gps_info[6]
+        if self.info :
+            latlon = self.info[4:]
         for mac,max_rss in self.scanlist.iteritems() :
             stored = self.db.get( mac )
             if stored :
@@ -53,18 +53,19 @@ class Scanner ( gps.GPSObject , wifiscan.WifiScanner ) :
 
     def write_logs ( self ) :
             fd = open( os.path.join( conf.homedir , "wiscan_gui.info" ) , 'a' )
-            fd.write( "%s %s %s\n" % ( self.tstamp , self.gps_info , self.scanlist ) )
+            fd.write( "%s %s %s\n" % ( self.tstamp , self.info , self.scanlist ) )
             fd.close()
             if self.satellites :
                 loclist = open( os.path.join( conf.homedir , "location.info" ) , 'a' )
                 loclist.write ( "%s\n" % ( self.satellites ,) )
                 loclist.close()
-            if self.cell_info :
+            if self.cells :
                 celllist = open( os.path.join( conf.homedir , "cell.info" ) , 'a' )
-                celllist.write ( "%s\n" % ( self.cell_info ,) )
+                celllist.write ( "%s\n" % ( self.cells ,) )
                 celllist.close()
 
     def report ( self ) :
+        # BUG : if report is called after close, db.nrows() will produce an exception
         return "%s\t%s\t%d ap\t%d total ap" % ( gps.GPSObject.report(self) , wifiscan.WifiScanner.report(self) , self.newap , self.db.nrows() )