mirror of
https://github.com/gryf/wicd.git
synced 2025-12-28 01:12:34 +01:00
Fix issue where signal strength wouldn't be reported correctly if the first link quality regex didn't match.
Add some helper methods that will eventually be used for encryption template parsing. Use more specific exception checking in a few places.
This commit is contained in:
@@ -33,8 +33,7 @@ from wicd import misc
|
||||
from wicd import wnettools
|
||||
from wicd import wpath
|
||||
from wicd.wnettools import *
|
||||
from wicd.wnettools import strength_pattern, altstrength_pattern, wep_pattern, \
|
||||
signaldbm_pattern
|
||||
from wicd.wnettools import wep_pattern, signaldbm_pattern
|
||||
|
||||
import iwscan
|
||||
import wpactrl
|
||||
@@ -311,17 +310,10 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
|
||||
|
||||
# Link Quality
|
||||
ap['qual_found'] = True
|
||||
try:
|
||||
[(strength, max_strength)] = strength_pattern.findall(cell["stats"])
|
||||
if max_strength:
|
||||
ap["quality"] = 100 * int(strength) // int(max_strength)
|
||||
else:
|
||||
ap["quality"] = int(strength)
|
||||
except ValueError:
|
||||
ap['quality'] = misc.RunRegex(altstrength_pattern,cell["stats"])
|
||||
if not ap['quality']:
|
||||
ap['qual_found'] = False
|
||||
ap['quality'] = -1
|
||||
ap['quality'] = self._get_link_quality(cell['stats'])
|
||||
if ap['quality'] is None:
|
||||
ap['qual_found'] = False
|
||||
ap['quality'] = -1
|
||||
|
||||
# Signal Strength (only used if user doesn't want link
|
||||
# quality displayed or it isn't found)
|
||||
@@ -498,10 +490,12 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
|
||||
buff = get_iw_ioctl_result(self.iface, SIOCGIWSTATS)
|
||||
strength = ord(buff[2])
|
||||
max_strength = self._get_max_strength()
|
||||
if strength and max_strength:
|
||||
if strength not in ['', None] and max_strength:
|
||||
return 100 * int(strength) // int(max_strength)
|
||||
|
||||
return strength
|
||||
elif strength not in ['', None]:
|
||||
return int(strength)
|
||||
else:
|
||||
return None
|
||||
|
||||
def _get_max_strength(self):
|
||||
""" Gets the maximum possible strength from the wireless driver. """
|
||||
|
||||
Reference in New Issue
Block a user