From b81941bd7e75e1642005216827a75efebf79c2a6 Mon Sep 17 00:00:00 2001 From: Joe MacMahon Date: Sun, 29 Jan 2012 04:05:16 +0000 Subject: [PATCH] Moved StopWPA functions up to superclasses. --- wicd/networking.py | 18 +++++++++++------- wicd/wnettools.py | 14 +++++++------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/wicd/networking.py b/wicd/networking.py index 9bf2e5f..ff9563f 100644 --- a/wicd/networking.py +++ b/wicd/networking.py @@ -518,6 +518,12 @@ class ConnectThread(threading.Thread): finally: self.lock.release() + @abortable + def stop_wpa(self, iface): + """ Stops wpa_supplicant. """ + print 'Stopping wpa_supplicant' + iface.StopWPA() + @abortable def put_iface_up(self, iface): """ Bring up given interface. """ @@ -968,13 +974,6 @@ class WirelessConnectThread(ConnectThread): self.abort_connection('association_failed') else: print 'not verifying' - - - @abortable - def stop_wpa(self, wiface): - """ Stops wpa_supplicant. """ - print 'Stopping wpa_supplicant' - wiface.StopWPA() @abortable def generate_psk_and_authenticate(self, wiface): @@ -1073,6 +1072,10 @@ class Wired(Controller): def Disconnect(self): Controller.Disconnect(self, 'wired', 'wired', 'wired') + self.StopWPA() + + def StopWPA(self): + self.liface.StopWPA() def DetectWiredInterface(self): """ Attempts to automatically detect a wired interface. """ @@ -1143,6 +1146,7 @@ class WiredConnectThread(ConnectThread): self.put_iface_down(liface) self.release_dhcp_clients(liface) self.reset_ip_addresses(liface) + self.stop_wpa(liface) self.flush_routes(liface) # Bring up interface. diff --git a/wicd/wnettools.py b/wicd/wnettools.py index 8cec435..3a8bf89 100644 --- a/wicd/wnettools.py +++ b/wicd/wnettools.py @@ -768,6 +768,13 @@ class BaseInterface(object): print "Could not open %s, using ifconfig to determine status" % flags_file return self._slow_is_up(ifconfig) return bool(int(flags, 16) & 1) + + @neediface(False) + def StopWPA(self): + """ Terminates wpa using wpa_cli""" + cmd = 'wpa_cli -i %s terminate' % self.iface + if self.verbose: print cmd + misc.Run(cmd) def _slow_is_up(self, ifconfig=None): @@ -1392,13 +1399,6 @@ class BaseWirelessInterface(BaseInterface): print 'wpa_supplicant rescan forced...' cmd = 'wpa_cli -i' + self.iface + ' scan' misc.Run(cmd) - - @neediface(False) - def StopWPA(self): - """ Terminates wpa using wpa_cli""" - cmd = 'wpa_cli -i %s terminate' % self.iface - if self.verbose: print cmd - misc.Run(cmd) @neediface("") def GetBSSID(self, iwconfig=None):