diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 0ea04c9..c25c83d 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -58,7 +58,9 @@ wpa1_pattern = re.compile('(WPA Version 1)', _re_mode) wpa2_pattern = re.compile('(WPA2)', _re_mode) #iwconfig-only regular expressions. +ip_up = re.compile(r'flags=[0.9]*<([^>]*)>', re.S) ip_pattern = re.compile(r'inet [Aa]d?dr[^.]*:([^.]*\.[^.]*\.[^.]*\.[0-9]*)', re.S) +ip_pattern1 = re.compile(r'inet ([^.]*\.[^.]*\.[^.]*\.[0-9]*)', re.S) bssid_pattern = re.compile('.*[(Access Point)|(Cell)]: (([0-9A-Z]{2}:){5}[0-9A-Z]{2})', _re_mode) bitrate_pattern = re.compile('.*Bit Rate[=:](.*?/s)', _re_mode) opmode_pattern = re.compile('.*Mode:(.*?) ', _re_mode) @@ -724,8 +726,12 @@ class BaseInterface(object): output = self.GetIfconfig() else: output = ifconfig - return misc.RunRegex(ip_pattern, output) - + # check multiple ifconfig output styles + for pat in [ip_pattern, ip_pattern1]: + m = misc.RunRegex(ip_pattern, output) + if m: return m + return None + @neediface(False) def VerifyAPAssociation(self, gateway): """ Verify assocation with an access point. @@ -773,6 +779,11 @@ class BaseInterface(object): lines = output.split('\n') if len(lines) < 5: return False + # check alternative ifconfig output style + m = misc.RunRegex(ip_up, lines[0]) + if m and m.find('UP') > -1: + return True + # check classic ifconfig output style for line in lines[1:4]: if line.strip().startswith('UP'): return True