From 531cde7250f75129813313e552f190375d166e09 Mon Sep 17 00:00:00 2001 From: Dan O'Reilly Date: Mon, 27 Apr 2009 19:17:01 -0400 Subject: [PATCH] Correctly handle case where a key is all digits and starts with a '0'. Remove some unused imports. Simplfy code that checks for valid wpa_supplicant drivers. --- wicd/autoconnect.py | 1 - wicd/configmanager.py | 3 ++- wicd/dbusmanager.py | 1 - wicd/gui.py | 5 ++--- wicd/logfile.py | 2 -- wicd/monitor.py | 3 +-- wicd/netentry.py | 2 +- wicd/prefs.py | 2 +- wicd/wicd-client.py | 1 - wicd/wnettools.py | 12 ++++-------- 10 files changed, 11 insertions(+), 21 deletions(-) diff --git a/wicd/autoconnect.py b/wicd/autoconnect.py index b591076..b68a5c7 100755 --- a/wicd/autoconnect.py +++ b/wicd/autoconnect.py @@ -23,7 +23,6 @@ from wicd import dbusmanager import dbus import time -import gobject import sys if getattr(dbus, 'version', (0, 0, 0)) < (0, 80, 0): diff --git a/wicd/configmanager.py b/wicd/configmanager.py index 9426e53..24d8dd4 100644 --- a/wicd/configmanager.py +++ b/wicd/configmanager.py @@ -106,7 +106,8 @@ class ConfigManager(RawConfigParser): # Try to intelligently handle the type of the return value. try: - ret = int(ret) + if not ret.startswith('0') or len(ret) == 1: + ret = int(ret) except (ValueError, TypeError): ret = Noneify(ret) # This is a workaround for a python-dbus issue on 64-bit systems. diff --git a/wicd/dbusmanager.py b/wicd/dbusmanager.py index 6cd3ec3..17e9e0c 100644 --- a/wicd/dbusmanager.py +++ b/wicd/dbusmanager.py @@ -24,7 +24,6 @@ A module for managing wicd's dbus interfaces. # import dbus -from dbus import DBusException if getattr(dbus, "version", (0, 0, 0)) < (0, 80, 0): import dbus.glib else: diff --git a/wicd/gui.py b/wicd/gui.py index e6bdecb..8db8b6f 100644 --- a/wicd/gui.py +++ b/wicd/gui.py @@ -31,7 +31,6 @@ import pango import gtk import gtk.glade from dbus import DBusException -from dbus import version as dbus_version from wicd import misc from wicd import wpath @@ -41,7 +40,7 @@ from wicd import netentry from wicd.misc import noneToString from wicd.netentry import WiredNetworkEntry, WirelessNetworkEntry from wicd.prefs import PreferencesDialog -from wicd.guiutil import error, GreyLabel, LabelEntry, SmallLabel +from wicd.guiutil import error, LabelEntry from wicd.translations import language if __name__ == '__main__': @@ -709,7 +708,7 @@ class appGui(object): try: daemon.WriteWindowSize(width, height, "main") daemon.SetGUIOpen(False) - except dbusmanager.DBusException: + except DBusException: pass if self.standalone: diff --git a/wicd/logfile.py b/wicd/logfile.py index 408aea2..639a912 100644 --- a/wicd/logfile.py +++ b/wicd/logfile.py @@ -25,8 +25,6 @@ import sys import os import time -import wicd.wpath as wpath - class SizeError(IOError): pass diff --git a/wicd/monitor.py b/wicd/monitor.py index 82727cd..4accb0e 100755 --- a/wicd/monitor.py +++ b/wicd/monitor.py @@ -26,7 +26,6 @@ when appropriate. import gobject import time -import sys from dbus import DBusException @@ -53,7 +52,7 @@ def diewithdbus(func): ret = func(self, *__args, **__kargs) self.__lost_dbus_count = 0 return ret - except dbusmanager.DBusException, e: + except DBusException, e: print "Caught exception %s" % str(e) if not hasattr(self, "__lost_dbus_count"): self.__lost_dbus_count = 0 diff --git a/wicd/netentry.py b/wicd/netentry.py index 28722ab..460f387 100644 --- a/wicd/netentry.py +++ b/wicd/netentry.py @@ -29,7 +29,7 @@ import misc import wpath import dbusmanager from misc import noneToString, stringToNone, noneToBlankString, to_bool -from guiutil import error, SmallLabel, LabelEntry, GreyLabel, LeftAlignedLabel, string_input +from guiutil import error, LabelEntry, GreyLabel, LeftAlignedLabel, string_input from translations import language diff --git a/wicd/prefs.py b/wicd/prefs.py index f511c42..30d7a5d 100644 --- a/wicd/prefs.py +++ b/wicd/prefs.py @@ -26,7 +26,7 @@ handles recieving/sendings the settings from/to the daemon. import gtk import gobject -import pango +#import pango import os import gtk.glade diff --git a/wicd/wicd-client.py b/wicd/wicd-client.py index bcb4900..0c34f7e 100755 --- a/wicd/wicd-client.py +++ b/wicd/wicd-client.py @@ -40,7 +40,6 @@ import gobject import getopt import os import pango -import time import atexit from dbus import DBusException diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 51ad50c..d09e8f2 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -112,10 +112,9 @@ def GetWirelessInterfaces(): """ dev_dir = '/sys/class/net/' - ifnames = [] - - ifnames = [iface for iface in os.listdir(dev_dir) if os.path.isdir(dev_dir + iface) - and 'wireless' in os.listdir(dev_dir + iface)] + ifnames = [iface for iface in os.listdir(dev_dir) + if os.path.isdir(dev_dir + iface) and + 'wireless' in os.listdir(dev_dir + iface)] return ifnames @@ -134,10 +133,7 @@ def IsValidWpaSuppDriver(driver): """ Returns True if given string is a valid wpa_supplicant driver. """ output = misc.Run(["wpa_supplicant", "-D%s" % driver, "-iolan19", "-c/etc/abcd%sdefzz.zconfz" % random.randint(1, 1000)]) - if re.match("Unsupported driver", output): - return False - else: - return True + return not "Unsupported driver" in output def neediface(default_response): """ A decorator for only running a method if self.iface is defined.