From aeb222a7f05e8b81b2350fb6c082d0ffa5f53a05 Mon Sep 17 00:00:00 2001 From: javiplx Date: Sat, 14 May 2011 18:06:31 +0000 Subject: [PATCH] Use a single Configuration instance alog all the code git-svn-id: file:///svnroot/wifihood/trunk@170 c51dfc6a-5949-4919-9c8e-f207a149c383 --- wifiscanner/wifimap/replay.py | 4 +--- wifiscanner/wifimap/scanner.py | 7 +++---- wifiscanner/wifiscanner | 15 ++++++++------- 3 files changed, 12 insertions(+), 14 deletions(-) diff --git a/wifiscanner/wifimap/replay.py b/wifiscanner/wifimap/replay.py index 6a1b1fd..0d2c712 100644 --- a/wifiscanner/wifimap/replay.py +++ b/wifiscanner/wifimap/replay.py @@ -1,5 +1,4 @@ -import config import db import gobject @@ -8,10 +7,9 @@ import os class ReplayScanner ( gobject.GObject ) : - def __init__ ( self , ifname="wlan0" ) : + def __init__ ( self , conf , ifname="wlan0" ) : 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 diff --git a/wifiscanner/wifimap/scanner.py b/wifiscanner/wifimap/scanner.py index 984e667..423f203 100644 --- a/wifiscanner/wifimap/scanner.py +++ b/wifiscanner/wifimap/scanner.py @@ -6,7 +6,7 @@ except : import time -import config , db +import db import gps , wifiscan import gobject @@ -15,12 +15,11 @@ import os class Scanner ( gps.GPSObject , wifiscan.WifiScanner ) : - def __init__ ( self , ifname="wlan0" ) : + def __init__ ( self , conf , ifname="wlan0" ) : gps.GPSObject.__init__( self ) wifiscan.WifiScanner.__init__( self , ifname ) - conf = config.Configuration( 'scanner' ) + self.db = db.database( os.path.join( conf.homedir , conf.dbname ) ) self.homedir = conf.homedir - self.db = db.database( os.path.join( self.homedir , conf.dbname ) ) self.write = False diff --git a/wifiscanner/wifiscanner b/wifiscanner/wifiscanner index 1f39e3d..ed0adc2 100755 --- a/wifiscanner/wifiscanner +++ b/wifiscanner/wifiscanner @@ -75,7 +75,8 @@ class AbstractWifiscanner : def __init__ ( self ) : - _scanner = scanner( "wlan0" ) + config = wifimap.config.Configuration( 'scanner' ) + _scanner = scanner( config , "wlan0" ) self.connect("delete_event", gtk.main_quit, None) @@ -102,7 +103,7 @@ class AbstractWifiscanner : scrollview = gtk.ScrolledWindow() notebook.append_page( scrollview , gtk.Label("Scanning") ) - self.map = MapWindow() + self.map = MapWindow( config ) notebook.append_page( self.map , gtk.Label("Map") ) buttons = gtk.VBox(homogeneous=False, spacing=0) @@ -114,7 +115,7 @@ class AbstractWifiscanner : # Buttons creation button = self.Button( "Switch GPS On") - button._id = button.connect("clicked", global_start, _scanner, self.map.config) + button._id = button.connect("clicked", global_start, _scanner, config) buttons.pack_start(button, expand=False) button_scan = self.Button( "Start scanning") @@ -144,9 +145,9 @@ if hildon : class MapWindow ( gtk.Frame ) : def __init__(self): - gtk.Frame.__init__( self ) + gtk.Frame.__init__( self , config ) - self.config = wifimap.config.Configuration( 'scanner' ) + self.config = config self.add( wifimap.simpleMapWidget( self.config ) ) class Wifiscanner ( AbstractWifiscanner , hildon.StackableWindow ) : @@ -202,9 +203,9 @@ else : class MapWindow ( gtk.Frame ) : def __init__(self): - gtk.Frame.__init__( self ) + gtk.Frame.__init__( self , config ) - self.config = wifimap.config.Configuration( 'scanner' ) + self.config = config self.add( wifimap.simpleMapWidget( self.config , (640,400) ) ) class Wifiscanner ( AbstractWifiscanner , gtk.Window ) : -- 1.7.9.5