1
0
mirror of https://github.com/gryf/wicd.git synced 2026-01-09 07:14:13 +01:00

Wait for the network interface to finish coming up before moving on during the connection process.

Use a dict instead of if/elifs in StartDHCP() method.
This commit is contained in:
Dan O'Reilly
2009-08-28 19:47:55 -04:00
parent 126a4e145e
commit ec8eade509
2 changed files with 21 additions and 12 deletions

View File

@@ -526,6 +526,14 @@ class ConnectThread(threading.Thread):
print 'Putting interface up...' print 'Putting interface up...'
self.SetStatus('interface_up') self.SetStatus('interface_up')
iface.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): class Wireless(Controller):
@@ -769,7 +777,7 @@ class Wireless(Controller):
iwconfig = self.GetIwconfig() iwconfig = self.GetIwconfig()
else: else:
iwconfig = None iwconfig = None
bssid = self.wiface.GetBSSID(iwconfig), bssid = self.wiface.GetBSSID(iwconfig)
essid = self.wiface.GetCurrentNetwork(iwconfig) essid = self.wiface.GetCurrentNetwork(iwconfig)
Controller.Disconnect(self, bssid, essid) Controller.Disconnect(self, bssid, essid)

View File

@@ -550,18 +550,19 @@ class BaseInterface(object):
if self.verbose: print cmd if self.verbose: print cmd
self.dhcp_object = misc.Run(cmd, include_stderr=True, return_obj=True) self.dhcp_object = misc.Run(cmd, include_stderr=True, return_obj=True)
pipe = self.dhcp_object.stdout 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() DHCP_CLIENT = self._get_dhcp_command()
if DHCP_CLIENT == misc.DHCLIENT: if DHCP_CLIENT in client_dict:
return self._parse_dhclient(pipe) ret = client_dict[DHCP_CLIENT](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)
else: else:
print 'ERROR no dhclient found!' print "ERROR: no dhcp client found"
ret = None
return ret
@neediface(False) @neediface(False)
def ReleaseDHCP(self): def ReleaseDHCP(self):