From 91761ba7f57c7a43933f7851ed90cbceb2c32b86 Mon Sep 17 00:00:00 2001 From: javiplx Date: Mon, 2 May 2011 11:26:56 +0000 Subject: [PATCH] Added database to replay scanner git-svn-id: file:///svnroot/wifihood/trunk@110 c51dfc6a-5949-4919-9c8e-f207a149c383 --- wifiscanner/wifimap/replay.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/wifiscanner/wifimap/replay.py b/wifiscanner/wifimap/replay.py index d40bfb6..88a7e56 100644 --- a/wifiscanner/wifimap/replay.py +++ b/wifiscanner/wifimap/replay.py @@ -1,5 +1,6 @@ import config +import db import gobject @@ -12,6 +13,7 @@ class ReplayScanner ( gobject.GObject ) : def __init__ ( self ) : gobject.GObject.__init__( self ) self.scan_timeout = 0 + self.db = db.database( os.path.join( conf.homedir , "wifireplay.db" ) # Values specific to replaying self._file = os.path.join( conf.homedir , "wiscan_gui.info" ) @@ -36,11 +38,13 @@ class ReplayScanner ( gobject.GObject ) : def start ( self , timeout=5000 ) : self.scan_timeout = timeout + self.db.open() self._fd = open( self._file ) self._current = self._fd.readline().split() def stop ( self ) : self.scan_timeout = 0 + self.db.close() self._fd.close() def scan ( self ) : @@ -52,7 +56,8 @@ class ReplayScanner ( gobject.GObject ) : delta = float(next[0]) - float(self._current[0]) gobject.timeout_add( int(1000 / self._speed * delta) , self.scan ) - self.info = self._current[1:8] + self.info = [ self._current[1] ] + self.info.extend( map( lambda x : float(x) , self._current[2:8] ) ) if self.info[0] == "FIX" : self.ngps += 1 @@ -63,6 +68,16 @@ class ReplayScanner ( gobject.GObject ) : self.nfp += 1 self.scanlist[ self._current[n] ] = int(self._current[n+1]) + for mac,max_rss in self.scanlist.iteritems() : + stored = self.db.get( mac ) + if stored : + if stored[0] > max_rss : + max_rss = stored[0] + self.db.update( mac , max_rss , self.tstamp , self.info[4:] ) + else : + self.newap += 1 + self.db.add( mac , max_rss , self.tstamp , self.info[4:] ) + self._current = next def report ( self ) : -- 1.7.9.5