From 37838ba0574df7a973d0464a01221e037297e26b Mon Sep 17 00:00:00 2001 From: imdano <> Date: Sun, 24 Aug 2008 08:15:24 +0000 Subject: [PATCH] experimental: - Some minor cleanup/formatting fixes - Add a missing DetectWiredInterfaces() method to networking.py --- wicd/daemon.py | 4 +--- wicd/netentry.py | 8 ++++---- wicd/networking.py | 7 +++++++ wicd/wnettools.py | 6 ++---- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/wicd/daemon.py b/wicd/daemon.py index 7dc596d..b9f6144 100644 --- a/wicd/daemon.py +++ b/wicd/daemon.py @@ -1402,7 +1402,6 @@ def main(argv): sys.exit(2) no_poll = False - scan_interval = "120000" for o, a in opts: if o in ('-h', '--help'): usage() @@ -1437,8 +1436,7 @@ def main(argv): gobject.threads_init() if not no_poll: - (child_pid, x, x, x) = gobject.spawn_async([wpath.bin + "monitor.py", - scan_interval], + (child_pid, x, x, x) = gobject.spawn_async([wpath.bin + "monitor.py"], flags=gobject.SPAWN_CHILD_INHERITS_STDIN) signal.signal(signal.SIGTERM, sigterm_caught) diff --git a/wicd/netentry.py b/wicd/netentry.py index 8088a5a..d0fece6 100644 --- a/wicd/netentry.py +++ b/wicd/netentry.py @@ -407,7 +407,7 @@ class WirelessSettingsDialog(AdvancedSettingsDialog): if ID == -1: self.combo_encryption.set_active(0) ID = 0 - + opts = methods[ID][2] for x in opts: box = None @@ -417,9 +417,9 @@ class WirelessSettingsDialog(AdvancedSettingsDialog): box = LabelEntry(opts[x][0].replace('_',' ')) box.set_auto_hidden(True) self.vbox_encrypt_info.pack_start(box) - #add the data to any array, so that the information - #can be easily accessed by giving the name of the wanted - #data + # Add the data to any array, so that the information + # can be easily accessed by giving the name of the wanted + # data. self.encryption_info[opts[x][1]] = box.entry box.entry.set_text(noneToBlankString( diff --git a/wicd/networking.py b/wicd/networking.py index 7e01019..9d67c4e 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -800,6 +800,13 @@ class Wired(Controller): self.connecting_thread.setDaemon(True) self.connecting_thread.start() return True + + def DetectWiredInterface(self): + """ Attempts to automatically detect a wired interface. """ + try: + return wnettools.GetWiredInterfaces()[0] + except IndexError: + return None def GetIP(self, fast=False): """ Get the IP of the interface. diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 190a2d7..6202a32 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -80,10 +80,10 @@ SIOCGIWAP = 0x8B15 def _sanitize_string(string): blacklist = [';', '`', '$', '!', '*', '|', '>', '<'] new_string = [] - + if not string: return string - + for c in string: if c in blacklist: new_string.append("\\" + c) @@ -273,8 +273,6 @@ class Interface(object): client = "pump" return client - print 'checking dhcp...' - if self.DHCP_CLIENT: dhcp_client = get_client_name(self.DHCP_CLIENT) dhcp_path = self._find_client_path(dhcp_client)