From 96a7d07bca6dba459d32791872d18e7acd05a1df Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Sat, 20 Jun 2009 13:42:21 -0500 Subject: [PATCH 1/2] return 101 as the signal strength if altstrenth_pattern fails to find the strength --- wicd/wnettools.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 65a2018..ac6d1c8 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -1366,7 +1366,14 @@ class BaseWirelessInterface(BaseInterface): (strength, max_strength) = (None, None) if strength in ['', None]: - [(strength, max_strength)] = altstrength_pattern.findall(output) + try: + [(strength, max_strength)] = altstrength_pattern.findall(output) + except ValueError: + # if the pattern was unable to match anything + # we'll return 101, which will allow us to stay + # connected even though we don't know the strength + # it also allows us to tell if + return 101 if strength not in ['', None] and max_strength: return (100 * int(strength) // int(max_strength)) elif strength not in ["", None]: From c93f3696bc08c699f50b9a0c699336d05e8e4fc9 Mon Sep 17 00:00:00 2001 From: Adam Blackburn Date: Sat, 20 Jun 2009 14:40:30 -0500 Subject: [PATCH 2/2] update FormatSignalForPrinting to return ??% instead of 101% --- wicd/wicd-daemon.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wicd/wicd-daemon.py b/wicd/wicd-daemon.py index 24289ed..cf180d2 100644 --- a/wicd/wicd-daemon.py +++ b/wicd/wicd-daemon.py @@ -309,7 +309,13 @@ class WicdDaemon(dbus.service.Object): if self.GetSignalDisplayType() == 1: return (signal + " dBm") else: - return (signal + "%") + try: + if int(signal) == 101: + return '??%' + else: + return (signal + "%") + except ValueError: + return (signal + "%") @dbus.service.method('org.wicd.daemon') def SetSuspend(self, val):