mirror of
https://github.com/gryf/wicd.git
synced 2026-02-19 16:35:46 +01:00
experimental:
- Add 3rd party python libraries used by ioctl backend to tree and to setup.py - Port several bug fixes from the trunk (removing reliance on shell for running external commands, unicode fixes, gui crash fixes, authentication validation improvements, several others) - Fix some crashes in ioctl backend. - Change daemon/GUI launch scripts to use the -O flag.
This commit is contained in:
0
wicd/backends/__init__.py
Normal file
0
wicd/backends/__init__.py
Normal file
@@ -1,4 +1,5 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: UTF-8 -*-
|
||||
|
||||
""" Network interface control tools for wicd.
|
||||
|
||||
@@ -253,7 +254,7 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
|
||||
cmd = 'iwlist ' + self.iface + ' scan'
|
||||
if self.verbose: print cmd
|
||||
results = misc.Run(cmd)
|
||||
|
||||
|
||||
# Split the networks apart, using Cell as our split point
|
||||
# this way we can look at only one network at a time.
|
||||
# The spaces around ' Cell ' are to minimize the chance that someone
|
||||
@@ -297,7 +298,7 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
|
||||
ap['essid'] = misc.RunRegex(essid_pattern, cell)
|
||||
try:
|
||||
ap['essid'] = misc.to_unicode(ap['essid'])
|
||||
except (UnicodeDecodeError, UnicodeEncodeError):
|
||||
except UnicodeDecodeError, UnicodeEncodeError:
|
||||
print 'Unicode problem with current network essid, ignoring!!'
|
||||
return None
|
||||
if ap['essid'] in ['<hidden>', ""]:
|
||||
@@ -385,8 +386,9 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
|
||||
if self.wpa_driver == RALINK_DRIVER or not self.WPA_CLI_FOUND:
|
||||
return True
|
||||
|
||||
MAX_TIME = 15
|
||||
MAX_TIME = 35
|
||||
MAX_DISCONNECTED_TIME = 3
|
||||
disconnected_time = 0
|
||||
while (time.time() - auth_time) < MAX_TIME:
|
||||
cmd = 'wpa_cli -i ' + self.iface + ' status'
|
||||
output = misc.Run(cmd)
|
||||
@@ -398,11 +400,15 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
|
||||
return False
|
||||
if result == "COMPLETED":
|
||||
return True
|
||||
elif result == "DISCONNECTED" and \
|
||||
(time.time() - auth_time) > MAX_DISCONNECTED_TIME:
|
||||
# Force a rescan to get wpa_supplicant moving again.
|
||||
self._ForceSupplicantScan()
|
||||
MAX_TIME += 5
|
||||
elif result == "DISCONNECTED":
|
||||
disconnected_time += 1
|
||||
if disconnected_time > MAX_DISCONNECTED_TIME:
|
||||
disconnected_time = 0
|
||||
# Force a rescan to get wpa_supplicant moving again.
|
||||
self._ForceSupplicantScan()
|
||||
MAX_TIME += 5
|
||||
else:
|
||||
disconnected_time = 0
|
||||
time.sleep(1)
|
||||
|
||||
print 'wpa_supplicant authentication may have failed.'
|
||||
|
||||
@@ -287,9 +287,14 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
|
||||
|
||||
"""
|
||||
if not self.scan_iface:
|
||||
self.scan_iface = iwscan.WirelessInterface(self.iface)
|
||||
try:
|
||||
self.scan_iface = iwscan.WirelessInterface(self.iface)
|
||||
except (iwscan.error, e):
|
||||
print "GetNetworks caught an exception: %s" %s
|
||||
return []
|
||||
|
||||
results = self.scan_iface.Scan()
|
||||
return [self._parse_ap(cell) for cell in results]
|
||||
return filter(None, [self._parse_ap(cell) for cell in results])
|
||||
|
||||
def _parse_ap(self, cell):
|
||||
""" Parse a single cell from the python-iwscan list. """
|
||||
@@ -305,16 +310,18 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
|
||||
ap['hidden'] = True
|
||||
else:
|
||||
ap['hidden'] = False
|
||||
|
||||
ap["channel"] = True and cell["channel"] or \
|
||||
self._FreqToChannel(cell["frequency"])
|
||||
|
||||
if cell["channel"]:
|
||||
ap["channel"] = True
|
||||
else:
|
||||
ap["channel"] = self._FreqToChannel(cell["frequency"])
|
||||
|
||||
ap["bssid"] = cell["bssid"]
|
||||
ap["mode"] = cell["mode"]
|
||||
|
||||
if cell["enc"]:
|
||||
ap["encryption"] = True
|
||||
if cell["ie"]:
|
||||
if cell["ie"] and cell["ie"].get('type'):
|
||||
if "WPA2" in cell['ie']['type'].upper():
|
||||
ap['encryption_method'] = 'WPA2'
|
||||
elif "WPA" in cell['ie']['type'].upper():
|
||||
@@ -383,8 +390,9 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
|
||||
|
||||
wpa = wpactrl.WPACtrl(socket)
|
||||
|
||||
MAX_TIME = 15
|
||||
MAX_TIME = 35
|
||||
MAX_DISCONNECTED_TIME = 3
|
||||
disconnected_time = 0
|
||||
while (time.time() - auth_time) < MAX_TIME:
|
||||
status = wpa.request("STATUS").split("\n")
|
||||
if self.verbose:
|
||||
@@ -398,11 +406,14 @@ class WirelessInterface(Interface, wnettools.BaseWirelessInterface):
|
||||
result = result
|
||||
if result.endswith("COMPLETED"):
|
||||
return True
|
||||
elif result.endswith("DISCONNECTED") and \
|
||||
(time.time() - auth_time) > MAX_DISCONNECTED_TIME:
|
||||
# Force a rescan to get wpa_supplicant moving again.
|
||||
wpa.request("SCAN")
|
||||
MAX_TIME += 5
|
||||
elif result.endswith("DISCONNECTED"):
|
||||
disconnected_time += 1
|
||||
if disconnected_time > MAX_DISCONNECTED_TIME:
|
||||
# Force a rescan to get wpa_supplicant moving again.
|
||||
wpa.request("SCAN")
|
||||
MAX_TIME += 5
|
||||
else:
|
||||
disconnected_time = 0
|
||||
time.sleep(1)
|
||||
|
||||
print 'wpa_supplicant authentication may have failed.'
|
||||
|
||||
Reference in New Issue
Block a user