projects
/
wifihood
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Implement honouring the logwritting configuration flag
[wifihood]
/
wifiscanner
/
wifimap
/
replay.py
diff --git
a/wifiscanner/wifimap/replay.py
b/wifiscanner/wifimap/replay.py
index
1e8b594
..
2db65cf
100644
(file)
--- a/
wifiscanner/wifimap/replay.py
+++ b/
wifiscanner/wifimap/replay.py
@@
-6,13
+6,12
@@
import gobject
import os
import os
-conf = config.Configuration()
-
class ReplayScanner ( gobject.GObject ) :
class ReplayScanner ( gobject.GObject ) :
- def __init__ ( self ) :
+ def __init__ ( self , ifname="wlan0" ) :
gobject.GObject.__init__( self )
self.scan_timeout = 0
gobject.GObject.__init__( self )
self.scan_timeout = 0
+ conf = config.Configuration( 'scanner' )
self.db = db.database( os.path.join( conf.homedir , "wifireplay.db" ) )
# Values specific to replaying
self.db = db.database( os.path.join( conf.homedir , "wifireplay.db" ) )
# Values specific to replaying
@@
-35,8
+34,10
@@
class ReplayScanner ( gobject.GObject ) :
# Values from the Scanner object
self.newap = 0
# Values from the Scanner object
self.newap = 0
+ self.newaps = False
+ self.aps = {}
- def start ( self , timeout=5000 ) :
+ def start ( self , timeout=5000 , writelog=False ) :
self.scan_timeout = timeout
self.db.open()
self._fd = open( self._file )
self.scan_timeout = timeout
self.db.open()
self._fd = open( self._file )
@@
-53,6
+54,8
@@
class ReplayScanner ( gobject.GObject ) :
return
next = self._fd.readline().split()
return
next = self._fd.readline().split()
+ if not next :
+ return
delta = float(next[0]) - float(self._current[0])
gobject.timeout_add( int(1000 / self._speed * delta) , self.scan )
delta = float(next[0]) - float(self._current[0])
gobject.timeout_add( int(1000 / self._speed * delta) , self.scan )
@@
-64,24
+67,36
@@
class ReplayScanner ( gobject.GObject ) :
self.nscan +=1
self.scanlist.clear()
self.tstamp = float(self._current[0])
self.nscan +=1
self.scanlist.clear()
self.tstamp = float(self._current[0])
- for n in range(11, len(self._current), 2) :
+ for n in range(10, len(self._current), 2) :
self.nfp += 1
self.scanlist[ self._current[n] ] = int(self._current[n+1])
self.nfp += 1
self.scanlist[ self._current[n] ] = int(self._current[n+1])
+ newap = 0
+ self.newaps = False
for mac,max_rss in self.scanlist.iteritems() :
for mac,max_rss in self.scanlist.iteritems() :
- stored = self.db.get( mac )
+ stored = self.db.db.execute( "SELECT rss, n, lat, lon FROM ap WHERE mac='%s'" % mac ).fetchone()
if stored :
if stored :
+ if not self.aps.has_key( mac ) :
+ self.aps[ mac ] = stored[1:]
if stored[0] > max_rss :
max_rss = stored[0]
self.db.update( mac , max_rss , self.tstamp , self.info[4:] )
else :
if stored[0] > max_rss :
max_rss = stored[0]
self.db.update( mac , max_rss , self.tstamp , self.info[4:] )
else :
- self.newap += 1
+ newap += 1
+ if not self.aps.has_key( mac ) :
+ self.aps[ mac ] = [ 0 , 0 , 0 ]
self.db.add( mac , max_rss , self.tstamp , self.info[4:] )
self.db.add( mac , max_rss , self.tstamp , self.info[4:] )
+ self.aps[0] += 1
+ self.aps[1] += self.info[4]
+ self.aps[2] += self.info[5]
+ if newap :
+ self.newap += newap
+ self.newaps = True
self._current = next
def report ( self ) :
self._current = next
def report ( self ) :
- 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 )
+ return "%d gps\t%d scan\t%d fp\t%d ap\t%d total ap" % ( self.ngps , self.nscan , self.nfp , self.newap , self.db.nrows() )
gobject.type_register(ReplayScanner)
gobject.type_register(ReplayScanner)