mirror of
https://github.com/gryf/wicd.git
synced 2025-12-20 21:08:06 +01:00
Testing/Experimental:
- Replaced uses of /proc/net/wireless with /sys/class/net/<iface>.
This commit is contained in:
25
wicd.py
25
wicd.py
@@ -245,20 +245,19 @@ class TrayIcon:
|
|||||||
""" Determines what network activity state we are in. """
|
""" Determines what network activity state we are in. """
|
||||||
transmitting = False
|
transmitting = False
|
||||||
receiving = False
|
receiving = False
|
||||||
rcvbytes = None
|
|
||||||
sndbytes = None
|
dev_dir = '/sys/class/net/'
|
||||||
|
wiface = daemon.GetWirelessInterface()
|
||||||
dev_file = open('/proc/net/dev','r')
|
for fldr in os.listdir(dev_dir):
|
||||||
device_data = dev_file.read().split('\n')
|
if fldr == wiface:
|
||||||
dev_file.close()
|
dev_dir = dev_dir + fldr + "/statistics/"
|
||||||
|
|
||||||
# Get the data for the wireless interface.
|
|
||||||
for line in device_data:
|
|
||||||
if daemon.GetWirelessInterface() in line:
|
|
||||||
line = line.replace(':', ' ').split()
|
|
||||||
rcvbytes = int(line[1])
|
|
||||||
sndbytes = int(line[9])
|
|
||||||
break
|
break
|
||||||
|
try:
|
||||||
|
rcvbytes = int(open(dev_dir + "rx_bytes", "r").read().strip())
|
||||||
|
sndbytes = int(open(dev_dir + "tx_bytes", "r").read().strip())
|
||||||
|
except IOError:
|
||||||
|
sndbytes = None
|
||||||
|
rcvbytes = None
|
||||||
|
|
||||||
if not rcvbytes or not sndbytes:
|
if not rcvbytes or not sndbytes:
|
||||||
return 'idle-'
|
return 'idle-'
|
||||||
|
|||||||
22
wnettools.py
22
wnettools.py
@@ -133,26 +133,14 @@ def GetWirelessInterfaces():
|
|||||||
return iface
|
return iface
|
||||||
|
|
||||||
def _fast_get_wifi_interfaces():
|
def _fast_get_wifi_interfaces():
|
||||||
""" Tries to get a wireless interface by parsing /proc/net/wireless. """
|
""" Tries to get a wireless interface using /sys/class/net. """
|
||||||
device = re.compile('[a-z]{3,4}[0-9]')
|
dev_dir = '/sys/class/net/'
|
||||||
ifnames = []
|
ifnames = []
|
||||||
|
|
||||||
try:
|
ifnames = [iface for iface in os.listdir(dev_dir) if 'wireless' \
|
||||||
f = open('/proc/net/wireless', 'r')
|
in os.listdir(dev_dir + iface)]
|
||||||
except IOError:
|
|
||||||
return None
|
|
||||||
data = f.readlines()
|
|
||||||
f.close()
|
|
||||||
for line in data:
|
|
||||||
try:
|
|
||||||
ifnames.append(device.search(line).group())
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if ifnames:
|
return bool(ifnames) and ifnames[0] or None
|
||||||
return ifnames[0]
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def get_iw_ioctl_result(iface, call):
|
def get_iw_ioctl_result(iface, call):
|
||||||
""" Makes the given ioctl call and returns the results.
|
""" Makes the given ioctl call and returns the results.
|
||||||
|
|||||||
Reference in New Issue
Block a user