mirror of
https://github.com/gryf/wicd.git
synced 2026-01-05 21:34:16 +01:00
Merge r463 of mainline 1.6.
This commit is contained in:
@@ -31,7 +31,7 @@ class WirelessInterface() -- Control a wireless network interface.
|
||||
|
||||
from wicd.wnettools import GetDefaultGateway, GetWiredInterfaces, \
|
||||
GetWirelessInterfaces, IsValidWpaSuppDriver, BaseWirelessInterface, \
|
||||
BaseWiredInterface, BaseInterface
|
||||
BaseWiredInterface, BaseInterface, GetWpaSupplicantDrivers
|
||||
|
||||
NAME = "external"
|
||||
UPDATE_INTERVAL = 5
|
||||
|
||||
@@ -34,7 +34,8 @@ from wicd import misc
|
||||
from wicd import wpath
|
||||
from wicd.wnettools import GetDefaultGateway, GetWiredInterfaces, \
|
||||
GetWirelessInterfaces, IsValidWpaSuppDriver, BaseWirelessInterface, \
|
||||
BaseWiredInterface, BaseInterface, wep_pattern, signaldbm_pattern, neediface
|
||||
BaseWiredInterface, BaseInterface, GetWpaSupplicantDrivers, wep_pattern, \
|
||||
signaldbm_pattern, neediface
|
||||
|
||||
try:
|
||||
import iwscan
|
||||
|
||||
@@ -124,6 +124,9 @@ class ConfigManager(RawConfigParser):
|
||||
|
||||
def write(self):
|
||||
""" Writes the loaded config file to disk. """
|
||||
for section in self.sections():
|
||||
if not section:
|
||||
self.remove_section(section)
|
||||
configfile = open(self.config_file, 'w')
|
||||
RawConfigParser.write(self, configfile)
|
||||
configfile.close()
|
||||
|
||||
@@ -528,6 +528,14 @@ class ConnectThread(threading.Thread):
|
||||
print 'Putting interface up...'
|
||||
self.SetStatus('interface_up')
|
||||
iface.Up()
|
||||
for x in range(0, 5):
|
||||
time.sleep(2)
|
||||
if iface.IsUp():
|
||||
return
|
||||
self.abort_if_needed()
|
||||
|
||||
# If we get here, the interface never came up
|
||||
print "WARNING: Timed out waiting for interface to come up"
|
||||
|
||||
|
||||
class Wireless(Controller):
|
||||
@@ -697,10 +705,9 @@ class Wireless(Controller):
|
||||
""" Get the out of iwconfig. """
|
||||
return self.wiface.GetIwconfig()
|
||||
|
||||
def GetWpaSupplicantDrivers(self, drivers):
|
||||
""" Returns all valid wpa_supplicant drivers in a list. """
|
||||
return [driver for driver in drivers if
|
||||
BACKEND.IsValidWpaSuppDriver(driver)]
|
||||
def GetWpaSupplicantDrivers(self):
|
||||
""" Returns all valid wpa_supplicant drivers on the system. """
|
||||
return BACKEND.GetWpaSupplicantDrivers()
|
||||
|
||||
def StopWPA(self):
|
||||
return self.wiface.StopWPA()
|
||||
@@ -771,7 +778,7 @@ class Wireless(Controller):
|
||||
iwconfig = self.GetIwconfig()
|
||||
else:
|
||||
iwconfig = None
|
||||
bssid = self.wiface.GetBSSID(iwconfig),
|
||||
bssid = self.wiface.GetBSSID(iwconfig)
|
||||
essid = self.wiface.GetCurrentNetwork(iwconfig)
|
||||
|
||||
Controller.Disconnect(self, bssid, essid)
|
||||
|
||||
@@ -375,9 +375,7 @@ class PreferencesDialog(object):
|
||||
|
||||
# Replacement for the combo box hack
|
||||
self.wpadrivercombo = build_combobox("pref_wpa_combobox")
|
||||
self.wpadrivers = ["wext", "hostap", "madwifi", "atmel",
|
||||
"ndiswrapper", "ipw"]
|
||||
self.wpadrivers = wireless.GetWpaSupplicantDrivers(self.wpadrivers)
|
||||
self.wpadrivers = wireless.GetWpaSupplicantDrivers()
|
||||
self.wpadrivers.append("ralink_legacy")
|
||||
|
||||
for x in self.wpadrivers:
|
||||
|
||||
@@ -1145,7 +1145,7 @@ class WirelessDaemon(dbus.service.Object):
|
||||
'predisconnectscript')
|
||||
self.wifi.post_disconnect_script = self.GetWirelessProperty(id,
|
||||
'postdisconnectscript')
|
||||
print 'Connecting to wireless network ' + self.LastScan[id]['essid']
|
||||
print 'Connecting to wireless network ' + str(self.LastScan[id]['essid'])
|
||||
self.daemon.wired_bus.wired.Disconnect()
|
||||
self.daemon.SetForcedDisconnect(False)
|
||||
conthread = self.wifi.Connect(self.LastScan[id], debug=self.debug_mode)
|
||||
@@ -1270,9 +1270,9 @@ class WirelessDaemon(dbus.service.Object):
|
||||
self.config.remove_section(essid_key)
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.wireless')
|
||||
def GetWpaSupplicantDrivers(self, drivers):
|
||||
""" Returns all valid wpa_supplicant drivers in a given list. """
|
||||
return self.wifi.GetWpaSupplicantDrivers(drivers)
|
||||
def GetWpaSupplicantDrivers(self):
|
||||
""" Returns all valid wpa_supplicant drivers. """
|
||||
return self.wifi.GetWpaSupplicantDrivers()
|
||||
|
||||
@dbus.service.method('org.wicd.daemon.wireless')
|
||||
def ReloadConfig(self):
|
||||
@@ -1447,6 +1447,8 @@ class WiredDaemon(dbus.service.Object):
|
||||
@dbus.service.method('org.wicd.daemon.wired')
|
||||
def CreateWiredNetworkProfile(self, profilename, default=False):
|
||||
""" Creates a wired network profile. """
|
||||
if not profilename:
|
||||
return False
|
||||
profilename = misc.to_unicode(profilename)
|
||||
print "Creating wired profile for " + profilename
|
||||
if self.config.has_section(profilename):
|
||||
@@ -1687,7 +1689,7 @@ def main(argv):
|
||||
logpath = os.path.join(wpath.log, 'wicd.log')
|
||||
if not os.path.exists(wpath.log):
|
||||
os.makedirs(wpath.log)
|
||||
os.chmod(wpath.log, 755)
|
||||
os.chmod(wpath.log, 0755)
|
||||
output = ManagedStdio(logpath)
|
||||
if os.path.exists(logpath):
|
||||
try:
|
||||
|
||||
@@ -156,6 +156,17 @@ def NeedsExternalCalls():
|
||||
""" Returns True if the backend needs to use an external program. """
|
||||
raise NotImplementedError
|
||||
|
||||
def GetWpaSupplicantDrivers():
|
||||
""" Returns a list of all valid wpa_supplicant drivers. """
|
||||
output = misc.Run(["wpa_supplicant", "-h"])
|
||||
try:
|
||||
output = output.split("drivers:")[1].split("options:")[0].strip()
|
||||
except:
|
||||
print "Warning: Couldn't get list of valid wpa_supplicant drivers"
|
||||
return [""]
|
||||
patt = re.compile("(\S+)\s+=.*")
|
||||
return patt.findall(output) or [""]
|
||||
|
||||
def IsValidWpaSuppDriver(driver):
|
||||
""" Returns True if given string is a valid wpa_supplicant driver. """
|
||||
output = misc.Run(["wpa_supplicant", "-D%s" % driver, "-iolan19",
|
||||
@@ -551,19 +562,20 @@ class BaseInterface(object):
|
||||
if self.verbose: print cmd
|
||||
self.dhcp_object = misc.Run(cmd, include_stderr=True, return_obj=True)
|
||||
pipe = self.dhcp_object.stdout
|
||||
client_dict = { misc.DHCLIENT : self._parse_dhclient,
|
||||
misc.DHCPCD : self._parse_dhcpcd,
|
||||
misc.PUMP : self._parse_pump,
|
||||
misc.UDHCPC : self._parse_udhcpc,
|
||||
}
|
||||
|
||||
DHCP_CLIENT = self._get_dhcp_command()
|
||||
if DHCP_CLIENT == misc.DHCLIENT:
|
||||
return self._parse_dhclient(pipe)
|
||||
elif DHCP_CLIENT == misc.PUMP:
|
||||
return self._parse_pump(pipe)
|
||||
elif DHCP_CLIENT == misc.DHCPCD:
|
||||
return self._parse_dhcpcd(pipe)
|
||||
elif DHCP_CLIENT == misc.UDHCPC:
|
||||
return self._parse_udhcpc(pipe)
|
||||
DHCP_CLIENT = self._get_dhcp_command()
|
||||
if DHCP_CLIENT in client_dict:
|
||||
ret = client_dict[DHCP_CLIENT](pipe)
|
||||
else:
|
||||
print 'ERROR no dhclient found!'
|
||||
|
||||
print "ERROR: no dhcp client found"
|
||||
ret = None
|
||||
return ret
|
||||
|
||||
@neediface(False)
|
||||
def ReleaseDHCP(self):
|
||||
""" Release the DHCP lease for this interface. """
|
||||
@@ -844,7 +856,7 @@ class BaseWirelessInterface(BaseInterface):
|
||||
essid -- essid to set the interface to
|
||||
|
||||
"""
|
||||
cmd = ['iwconfig', self.iface, 'essid', essid]
|
||||
cmd = ['iwconfig', self.iface, 'essid', str(essid)]
|
||||
if self.verbose: print str(cmd)
|
||||
misc.Run(cmd)
|
||||
|
||||
@@ -1055,7 +1067,7 @@ class BaseWirelessInterface(BaseInterface):
|
||||
if not wpa_pass_path: return None
|
||||
key_pattern = re.compile('network={.*?\spsk=(.*?)\n}.*',
|
||||
re.I | re.M | re.S)
|
||||
cmd = [wpa_pass_path, network['essid'], str(network['key'])]
|
||||
cmd = [wpa_pass_path, str(network['essid']), str(network['key'])]
|
||||
if self.verbose: print cmd
|
||||
return misc.RunRegex(key_pattern, misc.Run(cmd))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user