1
0
mirror of https://github.com/gryf/wicd.git synced 2026-04-01 01:43:31 +02:00

Adding GetOperationalMode() to determine op mode of an interface

This commit is contained in:
Dario Freddi
2009-03-01 19:31:34 +01:00
parent 2898adec48
commit 9213c7c333
3 changed files with 28 additions and 0 deletions

View File

@@ -62,6 +62,7 @@ wpa2_pattern = re.compile('(WPA2)', __re_mode)
ip_pattern = re.compile(r'inet [Aa]d?dr[^.]*:([^.]*\.[^.]*\.[^.]*\.[0-9]*)',re.S)
bssid_pattern = re.compile('.*Access Point: (([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)
# Regular expressions for wpa_cli output
auth_pattern = re.compile('.*wpa_state=(.*?)\n', __re_mode)
@@ -1198,6 +1199,18 @@ class BaseWirelessInterface(BaseInterface):
bitrate = misc.RunRegex(bitrate_pattern, output)
return bitrate + 's'
def GetOperationalMode(self, iwconfig=None):
""" Get the MAC address for the interface. """
if not iwconfig:
cmd = 'iwconfig ' + self.iface
if self.verbose: print cmd
output = misc.Run(cmd)
else:
output = iwconfig
opmode = misc.RunRegex(opmode_pattern, output)
return opmode
def _get_link_quality(self, output):
""" Parse out the link quality from iwlist scan or iwconfig output. """
try: