REFACTORING : Use the 'string operator' to write logfile
authorjaviplx <javiplx@gmail.com>
Mon, 16 May 2011 11:58:39 +0000 (11:58 +0000)
committerjaviplx <javiplx@gmail.com>
Mon, 16 May 2011 11:58:39 +0000 (11:58 +0000)
git-svn-id: file:///svnroot/wifihood/trunk@197 c51dfc6a-5949-4919-9c8e-f207a149c383

wifiscanner/wifimap/gps.py
wifiscanner/wifimap/scanner.py
wifiscanner/wifimap/wifiscan.py

index 33f8643..b435bf2 100644 (file)
@@ -83,6 +83,10 @@ class GPSObject ( gobject.GObject ) :
         else :
             self.info = None, 0, 0, None, None, None, None
 
+    def __str__ ( self ) :
+        output = map( str , self.info )
+        return " ".join( output )
+
     def report ( self ) :
         return "%d gps" % self.ngps
 
index 574a99a..0f3ce51 100644 (file)
@@ -71,7 +71,7 @@ class Scanner ( gps.GPSObject , wifiscan.WifiScanner ) :
 
     def write_logs ( self ) :
             fd = open( os.path.join( self.homedir , "wiscan_gui.info" ) , 'a' )
-            fd.write( "%s %s %s\n" % ( self.tstamp , " ".join(self.info) , " ".join(self.scanlist) ) )
+            fd.write( "%s %s\n" % ( self.tstamp , self ) )
             fd.close()
             if self.satellites :
                 loclist = open( os.path.join( self.homedir , "location.info" ) , 'a' )
@@ -82,6 +82,9 @@ class Scanner ( gps.GPSObject , wifiscan.WifiScanner ) :
                 celllist.write ( "%s\n" % ( self.cells ,) )
                 celllist.close()
 
+    def __str__ ( self ) :
+        return "%s %s" % ( gps.GPSObject.__str__(self) , wifiscan.WifiScanner.__str__(self) )
+
     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() )
index 7edc380..934e4ab 100644 (file)
@@ -52,6 +52,10 @@ class WifiScanner ( gobject.GObject ) :
         except Exception , ex :
             osso.SystemNote(self.osso_context).system_note_infoprint("Exception scanning %s" % ex )
 
+    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 )