1
0
mirror of https://github.com/gryf/wicd.git synced 2025-12-26 08:22:32 +01: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

@@ -635,6 +635,16 @@ class Wireless(Controller):
"""
return self.wiface.GetCurrentBitrate(iwconfig)
def GetOperationalMode(self, iwconfig):
""" Get the current operational mode of the interface.
Returns:
The operational mode of the interface as a string, or
None if the operational mode can't be found.
"""
return self.wiface.GetOperationalMode(iwconfig)
def GetIwconfig(self):
""" Get the out of iwconfig. """
return self.wiface.GetIwconfig()

View File

@@ -1000,6 +1000,11 @@ class WirelessDaemon(dbus.service.Object):
def GetCurrentBitrate(self, iwconfig):
return self.wifi.GetCurrentBitrate(iwconfig)
@dbus.service.method('org.wicd.daemon.wireless')
def GetOperationalMode(self, iwconfig):
""" Returns the operational mode for the iwconfig parameter """
return misc.to_unicode(self.wifi.GetOperationalMode())
@dbus.service.method('org.wicd.daemon.wireless')
def CreateAdHocNetwork(self, essid, channel, ip, enctype, key, encused,
ics):

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: