diff --git a/wicd/networking.py b/wicd/networking.py index 1260505..6d439d8 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -116,7 +116,9 @@ def expand_script_macros(script, msg, bssid, essid): script -- the script to execute. msg -- the name of the script, %{script} will be expanded to this. bssid -- the bssid of the network we connect to, defaults to 'wired'. - essid -- the essid of the network we connect to, defaults to 'wired'.""" + essid -- the essid of the network we connect to, defaults to 'wired'. + + """ def repl(match): macro = match.group(1).lower() if macro_dict.has_key(macro): @@ -564,23 +566,13 @@ class Wireless(Controller): """ def comp(x, y): - if x.has_key('quality'): - if x['quality'] > y['quality']: - return 1 - elif x['quality'] < y['quality']: - return -1 - else: - return 0 + if 'quality' in x: + key = 'quality' else: - if x['strength'] < y['strength']: - return 1 - elif x['strength'] > y['strength']: - return -1 - else: - return 0 + key = 'strength' + return cmp(x[key], y[key]) if not self.wiface: return [] - wiface = self.wiface # Prepare the interface for scanning @@ -771,6 +763,7 @@ class Wireless(Controller): """ Sets the wpa_supplicant driver associated with the interface. """ self.wiface.SetWpaDriver(driver) + class WirelessConnectThread(ConnectThread): """ A thread class to perform the connection to a wireless network. @@ -1063,4 +1056,3 @@ class WiredConnectThread(ConnectThread): self.connect_result = "Success" self.is_connecting = False - diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 62cf751..243fbff 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -220,6 +220,8 @@ class BaseInterface(object): if self.dhclient_cmd and cl in [misc.DHCLIENT, misc.AUTO]: client = "dhclient" cmd = self.dhclient_cmd + if self.dhclient_needs_verbose: + cmd += ' -v' elif self.dhcpcd_cmd and cl in [misc.DHCPCD, misc.AUTO]: client = "dhcpcd" cmd = self.dhcpcd_cmd @@ -294,6 +296,11 @@ class BaseInterface(object): """ self.dhclient_cmd = self._find_program_path("dhclient") + output = misc.Run(self.dhclient_cmd + " --version", include_stderr=True) + if '4.' in output: + self.dhclient_needs_verbose = True + else: + self.dhclient_needs_verbose = False self.dhcpcd_cmd = self._find_program_path("dhcpcd") self.pump_cmd = self._find_program_path("pump")