From 65c72ba3a22219f7751a34ed908f9573101060da Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Sun, 22 Mar 2009 17:36:55 -0400 Subject: [PATCH 1/4] Update copyrights and some docstrings. Make trayicon network menu scan-triggering behave better. --- wicd/autoconnect.py | 6 ++++-- wicd/backend.py | 4 ++-- wicd/backends/be-external.py | 4 ++-- wicd/backends/be-ioctl.py | 4 ++-- wicd/configmanager.py | 6 +++--- wicd/configscript.py | 6 +++--- wicd/dbusmanager.py | 4 ++-- wicd/gui.py | 9 ++++----- wicd/guiutil.py | 4 ++-- wicd/logfile.py | 2 +- wicd/misc.py | 11 ++++++++--- wicd/monitor.py | 4 ++-- wicd/netentry.py | 11 +++++++++-- wicd/networking.py | 6 +++--- wicd/prefs.py | 6 +++--- wicd/suspend.py | 4 ++-- wicd/translations.py | 1 + wicd/wicd-client.py | 21 +++++++++++---------- wicd/wicd-daemon.py | 15 ++++++--------- wicd/wnettools.py | 14 ++++++-------- 20 files changed, 76 insertions(+), 66 deletions(-) diff --git a/wicd/autoconnect.py b/wicd/autoconnect.py index be830dc..b591076 100755 --- a/wicd/autoconnect.py +++ b/wicd/autoconnect.py @@ -1,8 +1,10 @@ #!/usr/bin/python +""" autoconnect -- Triggers an automatic connection attempt. """ + # -# Copyright (C) 2007 - 2008 Adam Blackburn -# Copyright (C) 2007 - 2008 Dan O'Reilly +# Copyright (C) 2007 - 2009 Adam Blackburn +# Copyright (C) 2007 - 2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/backend.py b/wicd/backend.py index bdd2b8b..15b4a7a 100644 --- a/wicd/backend.py +++ b/wicd/backend.py @@ -7,8 +7,8 @@ Manages and loads the pluggable backends for wicd. """ # -# Copyright (C) 2008 Adam Blackburn -# Copyright (C) 2008 Dan O'Reilly +# Copyright (C) 2008-2009 Adam Blackburn +# Copyright (C) 2008-2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/backends/be-external.py b/wicd/backends/be-external.py index 2cce772..9bd0fbb 100644 --- a/wicd/backends/be-external.py +++ b/wicd/backends/be-external.py @@ -13,8 +13,8 @@ class WirelessInterface() -- Control a wireless network interface. """ # -# Copyright (C) 2008 Adam Blackburn -# Copyright (C) 2008 Dan O'Reilly +# Copyright (C) 2008-2009 Adam Blackburn +# Copyright (C) 2008-2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/backends/be-ioctl.py b/wicd/backends/be-ioctl.py index 0b80a2b..fc9a278 100644 --- a/wicd/backends/be-ioctl.py +++ b/wicd/backends/be-ioctl.py @@ -14,8 +14,8 @@ class WirelessInterface() -- Control a wireless network interface. """ # -# Copyright (C) 2008 Adam Blackburn -# Copyright (C) 2008 Dan O'Reilly +# Copyright (C) 2008-2009 Adam Blackburn +# Copyright (C) 2008-2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/configmanager.py b/wicd/configmanager.py index acfb8a1..19da2bc 100644 --- a/wicd/configmanager.py +++ b/wicd/configmanager.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -""" Wicd Configuration Manager +""" configmanager -- Wicd configuration file manager Wrapper around ConfigParser for wicd, though it should be reusable for other purposes as well. @@ -8,8 +8,8 @@ reusable for other purposes as well. """ # -# Copyright (C) 2008 Adam Blackburn -# Copyright (C) 2008 Dan O'Reilly +# Copyright (C) 2008-2009 Adam Blackburn +# Copyright (C) 2008-2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/configscript.py b/wicd/configscript.py index 9e1a7c5..bb6fa28 100755 --- a/wicd/configscript.py +++ b/wicd/configscript.py @@ -1,6 +1,6 @@ #!/usr/bin/env python -""" Configure the scripts for a particular network. +""" configscript -- Configure the scripts for a particular network. Script for configuring the scripts for a network passed in as a command line argument. This needs to run a separate process because @@ -10,8 +10,8 @@ run as the current user. """ # -# Copyright (C) 2007-2008 Adam Blackburn -# Copyright (C) 2007-2008 Dan O'Reilly +# Copyright (C) 2007-2009 Adam Blackburn +# Copyright (C) 2007-2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/dbusmanager.py b/wicd/dbusmanager.py index 0c25b6c..6cd3ec3 100644 --- a/wicd/dbusmanager.py +++ b/wicd/dbusmanager.py @@ -7,8 +7,8 @@ A module for managing wicd's dbus interfaces. """ # -# Copyright (C) 2008 Adam Blackburn -# Copyright (C) 2008 Dan O'Reilly +# Copyright (C) 2008-2009 Adam Blackburn +# Copyright (C) 2008-2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/gui.py b/wicd/gui.py index 6832337..61b0b5b 100644 --- a/wicd/gui.py +++ b/wicd/gui.py @@ -1,15 +1,14 @@ #!/usr/bin/python -""" Wicd GUI module. +""" gui -- The main wicd GUI module. -Module containg all the code (other than the tray icon) related to the -Wicd user interface. +Module containing the code for the main wicd GUI. """ # -# Copyright (C) 2007 Adam Blackburn -# Copyright (C) 2007 Dan O'Reilly +# Copyright (C) 2007-2009 Adam Blackburn +# Copyright (C) 2007-2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/guiutil.py b/wicd/guiutil.py index 8eea489..454f37d 100644 --- a/wicd/guiutil.py +++ b/wicd/guiutil.py @@ -1,7 +1,7 @@ """ guiutil - A collection of commonly used gtk/gui functions and classes. """ # -# Copyright (C) 2007 - 2008 Adam Blackburn -# Copyright (C) 2007 - 2008 Dan O'Reilly +# Copyright (C) 2007 - 2009 Adam Blackburn +# Copyright (C) 2007 - 2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/logfile.py b/wicd/logfile.py index c25dd03..408aea2 100644 --- a/wicd/logfile.py +++ b/wicd/logfile.py @@ -2,7 +2,7 @@ # # Copyright (C) 1999-2006 Keith Dart -# Copyright (C) 2008 Dan O'Reilly +# Copyright (C) 2008-2009 Dan O'Reilly # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public diff --git a/wicd/misc.py b/wicd/misc.py index 0c6dbaa..2d552fd 100644 --- a/wicd/misc.py +++ b/wicd/misc.py @@ -1,8 +1,13 @@ -""" Misc - miscellaneous functions for wicd """ +""" misc - miscellaneous functions for wicd + +This module contains a large variety of utility functions used +throughout wicd. + +""" # -# Copyright (C) 2007 - 2008 Adam Blackburn -# Copyright (C) 2007 - 2008 Dan O'Reilly +# Copyright (C) 2007 - 2009 Adam Blackburn +# Copyright (C) 2007 - 2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/monitor.py b/wicd/monitor.py index 7333724..d47add5 100755 --- a/wicd/monitor.py +++ b/wicd/monitor.py @@ -8,8 +8,8 @@ when appropriate. """ # -# Copyright (C) 2007 - 2008 Adam Blackburn -# Copyright (C) 2007 - 2008 Dan O'Reilly +# Copyright (C) 2007 - 2009 Adam Blackburn +# Copyright (C) 2007 - 2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/netentry.py b/wicd/netentry.py index a6e1919..6ccd36c 100644 --- a/wicd/netentry.py +++ b/wicd/netentry.py @@ -1,6 +1,13 @@ +""" netentry -- Network entry widgets for the GUI. + +This module provides GUI widgets used to represent wired and wireless +entries in the GUI's network list, as well as any settings dialogs +contained within them. + +""" # -# Copyright (C) 2007 Adam Blackburn -# Copyright (C) 2007 Dan O'Reilly +# Copyright (C) 2008-2009 Adam Blackburn +# Copyright (C) 2008-2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/networking.py b/wicd/networking.py index 6f8e42e..084b8e3 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -19,9 +19,9 @@ class WiredConnectThread() -- Connection thread for wired """ # -# Copyright (C) 2007 - 2008 Adam Blackburn -# Copyright (C) 2007 - 2008 Dan O'Reilly -# Copyright (C) 2007 - 2008 Byron Hillis +# Copyright (C) 2007 - 2009 Adam Blackburn +# Copyright (C) 2007 - 2009 Dan O'Reilly +# Copyright (C) 2007 - 2009 Byron Hillis # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/prefs.py b/wicd/prefs.py index d25267b..f511c42 100644 --- a/wicd/prefs.py +++ b/wicd/prefs.py @@ -1,6 +1,6 @@ #!/usr/bin/python -""" Wicd Preferences Dialog. +""" prefs -- Wicd Preferences Dialog. Displays the main settings dialog window for wicd and handles recieving/sendings the settings from/to the daemon. @@ -8,8 +8,8 @@ handles recieving/sendings the settings from/to the daemon. """ # -# Copyright (C) 2007 Adam Blackburn -# Copyright (C) 2007 Dan O'Reilly +# Copyright (C) 2008-2009 Adam Blackburn +# Copyright (C) 2008-2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/suspend.py b/wicd/suspend.py index 217a655..e60f5c6 100755 --- a/wicd/suspend.py +++ b/wicd/suspend.py @@ -8,8 +8,8 @@ Used for when a laptop enters hibernation/suspension. """ # -# Copyright (C) 2007 - 2008 Adam Blackburn -# Copyright (C) 2007 - 2008 Dan O'Reilly +# Copyright (C) 2007 - 2009 Adam Blackburn +# Copyright (C) 2007 - 2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/translations.py b/wicd/translations.py index 308d620..327951c 100644 --- a/wicd/translations.py +++ b/wicd/translations.py @@ -1,6 +1,7 @@ #!/usr/bin/env python # -* coding: utf-8 -*- +""" translations -- module for handling the translation strings for wicd. """ # # Copyright (C) 2007 - 2009 Adam Blackburn # Copyright (C) 2007 - 2009 Dan O'Reilly diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index 8cac87e..715de5a 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -14,14 +14,12 @@ class TrayIcon() -- Parent class of TrayIconGUI and IconConnectionInfo. class StatusTrayIconGUI() -- Implements the tray icon using a gtk.StatusIcon. class EggTrayIconGUI() -- Implements the tray icon using egg.trayicon. -def usage() -- Prints usage information. -def main() -- Runs the wicd frontend main loop. """ # -# Copyright (C) 2007 - 2008 Adam Blackburn -# Copyright (C) 2007 - 2008 Dan O'Reilly +# Copyright (C) 2007 - 2009 Adam Blackburn +# Copyright (C) 2007 - 2009 Dan O'Reilly # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as @@ -464,7 +462,6 @@ class TrayIcon(object): signal_img = 'signal-25.png' return wpath.images + signal_img - @catchdbus def on_net_menu_activate(self, item): """ Trigger a background scan to populate the network menu. @@ -475,18 +472,20 @@ class TrayIcon(object): mousing past the menu to select another menu item. """ - def dummy(x=None): pass - if self._is_scanning: return True self.init_network_menu() - time.sleep(.4) + gobject.timeout_add(800, self._trigger_scan_if_needed, item) + + @catchdbus + def _trigger_scan_if_needed(self, item): while gtk.events_pending(): gtk.main_iteration() if item.state != gtk.STATE_PRELIGHT: - return True + return False wireless.Scan(False) + return False @catchdbus def populate_network_menu(self, data=None): @@ -535,7 +534,7 @@ class TrayIcon(object): net_menuitem.show() def init_network_menu(self): - """ Set the right-click menu for to the scanning state. """ + """ Set the right-click network menu to the scanning state. """ net_menuitem = self.manager.get_widget("/Menubar/Menu/Connect/") submenu = net_menuitem.get_submenu() self._clear_menu(submenu) @@ -592,6 +591,7 @@ class TrayIcon(object): if event.button == 1: self.toggle_wicd_gui() elif event.button == 3: + self._menu_just_opened = True self.init_network_menu() self.menu.popup(None, None, None, event.button, event.time) @@ -629,6 +629,7 @@ class TrayIcon(object): def on_popup_menu(self, status, button, timestamp): """ Opens the right click menu for the tray icon. """ + self._menu_just_opened = True self.init_network_menu() self.menu.popup(None, None, None, button, timestamp) diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index 6525f27..5344d9c 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -8,19 +8,16 @@ connection management, for both wireless and wired networks. The daemon must be run as root to control the networks, however the user interface components should be run as a normal user. -class LogWriter() -- Class to redirect stdout and stderr to a log file. -class ConnectionWizard() -- DBUS interface to manage the network. -class ConnectionStatus() -- Updates the current connection state -def usage() -- Print usage information. -def daemonize() -- Daemonize the current process with a double fork. -def main() -- The wicd daemon main loop. +class WicdDaemon() -- DBus interface to manage general wicd processes. +class WiredDaemon() -- DBus interface to managed the wired network. +class WirelessDaemon() -- DBus interface to managed the wireless network. """ # -# Copyright (C) 2007 - 2008 Adam Blackburn -# Copyright (C) 2007 - 2008 Dan O'Reilly -# Copyright (C) 2007 - 2008 Byron Hillis +# Copyright (C) 2007 - 2009 Adam Blackburn +# Copyright (C) 2007 - 2009 Dan O'Reilly +# Copyright (C) 2007 - 2009 Byron Hillis # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 968d3be..52cdda6 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -6,18 +6,16 @@ This module implements functions to control and obtain information from network interfaces. -def SetDNS() -- Set the DNS servers of the system. -def GetWirelessInterfaces() -- Get the wireless interfaces available. -class Interface() -- Control a network interface. -class WiredInterface() -- Control a wired network interface. -class WirelessInterface() -- Control a wireless network interface. +class BaseInterface() -- Control a network interface. +class BaseWiredInterface() -- Control a wired network interface. +class BaseWirelessInterface() -- Control a wireless network interface. """ # -# Copyright (C) 2007 - 2008 Adam Blackburn -# Copyright (C) 2007 - 2008 Dan O'Reilly -# Copyright (C) 2007 - 2008 Byron Hillis +# Copyright (C) 2007 - 2009 Adam Blackburn +# Copyright (C) 2007 - 2009 Dan O'Reilly +# Copyright (C) 2007 - 2009 Byron Hillis # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License Version 2 as From d09344b32908ed8e42f6e1bb990ab72e52afa0e1 Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Sun, 22 Mar 2009 18:39:44 -0400 Subject: [PATCH 2/4] Update docstrings. --- wicd/wicd-client.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index 715de5a..dc363f5 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -465,11 +465,9 @@ class TrayIcon(object): def on_net_menu_activate(self, item): """ Trigger a background scan to populate the network menu. - Called when the network submenu is moused over. We - sleep briefly, clear pending gtk events, and if - we're still being moused over we trigger a scan. - This is to prevent scans when the user is just - mousing past the menu to select another menu item. + Clear the network menu, and schedule a method to be + called in .8 seconds to trigger a scan if the menu + is still being moused over. """ if self._is_scanning: @@ -480,6 +478,7 @@ class TrayIcon(object): @catchdbus def _trigger_scan_if_needed(self, item): + """ Trigger a scan if the network menu is being hovered over. """ while gtk.events_pending(): gtk.main_iteration() if item.state != gtk.STATE_PRELIGHT: From bb9d3690de47e207bc5c867b6b81ba2fff8440d1 Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Mon, 23 Mar 2009 01:28:50 -0400 Subject: [PATCH 3/4] Make the ioctl backends use of python-iwscan and python-wpactrl optional. Don't use __all__ in wnettools.py, and make the backends explicitly import the methods/classes they need from wnettools.py. --- wicd/backends/be-external.py | 19 ++++++++-------- wicd/backends/be-ioctl.py | 43 +++++++++++++++++++++++++----------- wicd/wnettools.py | 3 --- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/wicd/backends/be-external.py b/wicd/backends/be-external.py index 9bd0fbb..daa8a08 100644 --- a/wicd/backends/be-external.py +++ b/wicd/backends/be-external.py @@ -31,7 +31,9 @@ class WirelessInterface() -- Control a wireless network interface. from wicd import misc from wicd import wnettools -from wicd.wnettools import * +from wicd.wnettools import GetDefaultGateway, GetWiredInterfaces, \ +GetWirelessInterfaces, IsValidWpaSuppDriver, BaseWirelessInterface, \ +BaseWiredInterface, BaseInterface import re import os import os.path @@ -53,11 +55,11 @@ RALINK_DRIVER = 'ralink legacy' def NeedsExternalCalls(*args, **kargs): - """ Return True, since this backend using iwconfig/ifconfig. """ + """ Return True, since this backend uses iwconfig/ifconfig. """ return True -class Interface(wnettools.BaseInterface): +class Interface(BaseInterface): """ Control a network interface. """ def __init__(self, iface, verbose=False): """ Initialize the object. @@ -67,11 +69,11 @@ class Interface(wnettools.BaseInterface): verbose -- whether to print every command run """ - wnettools.BaseInterface.__init__(self, iface, verbose) + BaseInterface.__init__(self, iface, verbose) self.Check() -class WiredInterface(Interface, wnettools.BaseWiredInterface): +class WiredInterface(Interface, BaseWiredInterface): """ Control a wired network interface. """ def __init__(self, iface, verbose=False): """ Initialise the wired network interface class. @@ -81,11 +83,11 @@ class WiredInterface(Interface, wnettools.BaseWiredInterface): verbose -- print all commands """ - wnettools.BaseWiredInterface.__init__(self, iface, verbose) + BaseWiredInterface.__init__(self, iface, verbose) Interface.__init__(self, iface, verbose) -class WirelessInterface(Interface, wnettools.BaseWirelessInterface): +class WirelessInterface(Interface, BaseWirelessInterface): """ Control a wireless network interface. """ def __init__(self, iface, verbose=False, wpa_driver='wext'): """ Initialise the wireless network interface class. @@ -95,7 +97,6 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface): verbose -- print all commands """ - wnettools.BaseWirelessInterface.__init__(self, iface, verbose, - wpa_driver) + BaseWirelessInterface.__init__(self, iface, verbose, wpa_driver) Interface.__init__(self, iface, verbose) diff --git a/wicd/backends/be-ioctl.py b/wicd/backends/be-ioctl.py index fc9a278..868b47f 100644 --- a/wicd/backends/be-ioctl.py +++ b/wicd/backends/be-ioctl.py @@ -33,11 +33,23 @@ class WirelessInterface() -- Control a wireless network interface. from wicd import misc from wicd import wnettools from wicd import wpath -from wicd.wnettools import * +from wicd.wnettools import GetDefaultGateway, GetWiredInterfaces, \ +GetWirelessInterfaces, IsValidWpaSuppDriver, BaseWirelessInterface, \ +BaseWiredInterface, BaseInterface from wicd.wnettools import wep_pattern, signaldbm_pattern, neediface -import iwscan -import wpactrl +try: + import iwscan + IWSCAN_AVAIL = True +except ImportError: + print "WARNING: python-iwscan not found, falling back to using iwlist scan." + IWSCAN_AVAIL = False +try: + import wpactrl + WPACTRL_AVAIL = True +except ImportError: + print "WARNING: python-wpactrl not found, falling back to using wpa_cli." + WPACTRL_AVAIL = False import re import os @@ -56,7 +68,7 @@ This backend uses IOCTL calls and python libraries to query network information whenever possible. This makes it fast, but it may not work properly on all systems. -Dependencies: +(Optional) Dependencies: python-wpactrl (http://projects.otaku42.de/wiki/PythonWpaCtrl) python-iwscan (http://projects.otaku42.de/browser/python-iwscan/)""" @@ -105,7 +117,7 @@ def NeedsExternalCalls(*args, **kargs): return False -class Interface(wnettools.BaseInterface): +class Interface(BaseInterface): """ Control a network interface. """ def __init__(self, iface, verbose=False): """ Initialise the object. @@ -115,7 +127,7 @@ class Interface(wnettools.BaseInterface): verbose -- whether to print every command run """ - wnettools.BaseInterface.__init__(self, iface, verbose) + BaseInterface.__init__(self, iface, verbose) self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) self.Check() @@ -162,7 +174,7 @@ class Interface(wnettools.BaseInterface): return bool(flags & 1) -class WiredInterface(Interface, wnettools.BaseWiredInterface): +class WiredInterface(Interface, BaseWiredInterface): """ Control a wired network interface. """ def __init__(self, iface, verbose=False): """ Initialise the wired network interface class. @@ -172,7 +184,7 @@ class WiredInterface(Interface, wnettools.BaseWiredInterface): verbose -- print all commands """ - wnettools.BaseWiredInterface.__init__(self, iface, verbose) + BaseWiredInterface.__init__(self, iface, verbose) Interface.__init__(self, iface, verbose) @neediface(False) @@ -240,7 +252,7 @@ class WiredInterface(Interface, wnettools.BaseWiredInterface): return bool(reg & 0x0004) -class WirelessInterface(Interface, wnettools.BaseWirelessInterface): +class WirelessInterface(Interface, BaseWirelessInterface): """ Control a wireless network interface. """ def __init__(self, iface, verbose=False, wpa_driver='wext'): """ Initialise the wireless network interface class. @@ -250,7 +262,7 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface): verbose -- print all commands """ - wnettools.BaseWirelessInterface.__init__(self, iface, verbose, + BaseWirelessInterface.__init__(self, iface, verbose, wpa_driver) Interface.__init__(self, iface, verbose) self.scan_iface = None @@ -263,6 +275,10 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface): A list containing available wireless networks. """ + if not IWSCAN_AVAIL: + # Use the slow version if python-iwscan isn't available. + return BaseWirelessInterface.GetNetworks(self) + if not self.scan_iface: try: self.scan_iface = iwscan.WirelessInterface(self.iface) @@ -361,9 +377,10 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface): False otherwise. """ - error= "Unable to find ctrl_interface for wpa_supplicant. " + \ - "Could not validate authentication." - + if not WPACTRL_AVAIL: + # If we don't have python-wpactrl, use the slow version. + return BaseWirelessInterface.ValidateAuthentication(self, auth_time) + # Right now there's no way to do this for ralink drivers if self.wpa_driver == RALINK_DRIVER: return True diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 52cdda6..f085206 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -72,9 +72,6 @@ blacklist_strict = '!"#$%&\'()*+,./:;<=>?@[\\]^`{|}~ ' blacklist_norm = ";`$!*|><&\\" blank_trans = maketrans("", "") -__all__ = ["GetDefaultGateway", "GetWiredInterfaces", - "GetWirelessInterfaces", "IsValidWpaSuppDriver"] - def _sanitize_string(string): if string: return translate(str(string), blank_trans, blacklist_norm) From ad09dea66e28acbdea0bab8bd24a8d64966145a2 Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Mon, 23 Mar 2009 01:30:16 -0400 Subject: [PATCH 4/4] Merge to import lines. --- wicd/backends/be-ioctl.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/wicd/backends/be-ioctl.py b/wicd/backends/be-ioctl.py index 868b47f..98c9aae 100644 --- a/wicd/backends/be-ioctl.py +++ b/wicd/backends/be-ioctl.py @@ -35,8 +35,7 @@ from wicd import wnettools from wicd import wpath from wicd.wnettools import GetDefaultGateway, GetWiredInterfaces, \ GetWirelessInterfaces, IsValidWpaSuppDriver, BaseWirelessInterface, \ -BaseWiredInterface, BaseInterface -from wicd.wnettools import wep_pattern, signaldbm_pattern, neediface +BaseWiredInterface, BaseInterface, wep_pattern, signaldbm_pattern, neediface try: import iwscan