mirror of
https://github.com/gryf/wicd.git
synced 2026-01-08 06:44:20 +01:00
Fixing implementation in ioctl
This commit is contained in:
@@ -46,7 +46,6 @@ import re
|
||||
import time
|
||||
import threading
|
||||
import os
|
||||
import thread
|
||||
from signal import SIGTERM
|
||||
|
||||
# wicd imports
|
||||
@@ -203,10 +202,12 @@ class Controller(object):
|
||||
def Disconnect(self, *args, **kargs):
|
||||
""" Disconnect from the network. """
|
||||
iface = self.iface
|
||||
if self.disconnect_script != None:
|
||||
misc.ExecuteScripts(wpath.disconnectscripts, self.debug)
|
||||
if self.disconnect_script:
|
||||
print 'Running disconnect script'
|
||||
misc.ExecuteScript(expand_script_macros(self.disconnect_script,
|
||||
'disconnection', *args))
|
||||
'disconnection', *args),
|
||||
self.debug)
|
||||
iface.ReleaseDHCP()
|
||||
iface.SetAddress('0.0.0.0')
|
||||
iface.FlushRoutes()
|
||||
@@ -268,7 +269,7 @@ class ConnectThread(threading.Thread):
|
||||
|
||||
is_connecting = None
|
||||
should_die = False
|
||||
lock = thread.allocate_lock()
|
||||
lock = threading.Lock()
|
||||
|
||||
def __init__(self, network, interface_name, before_script, after_script,
|
||||
disconnect_script, gdns1, gdns2, gdns3, gdns_dom, gsearch_dom,
|
||||
@@ -369,6 +370,10 @@ class ConnectThread(threading.Thread):
|
||||
self.SetStatus('interface_down')
|
||||
iface.Down()
|
||||
|
||||
@abortable
|
||||
def run_global_scripts_if_needed(self, script_dir):
|
||||
misc.ExecuteScripts(script_dir, verbose=self.debug)
|
||||
|
||||
@abortable
|
||||
def run_script_if_needed(self, script, msg, bssid='wired', essid='wired'):
|
||||
""" Execute a given script if needed.
|
||||
@@ -380,7 +385,8 @@ class ConnectThread(threading.Thread):
|
||||
"""
|
||||
if script:
|
||||
print 'Executing %s script' % (msg)
|
||||
misc.ExecuteScript(expand_script_macros(script, msg, bssid, essid))
|
||||
misc.ExecuteScript(expand_script_macros(script, msg, bssid, essid),
|
||||
self.debug)
|
||||
|
||||
@abortable
|
||||
def flush_routes(self, iface):
|
||||
@@ -471,7 +477,7 @@ class ConnectThread(threading.Thread):
|
||||
try:
|
||||
if self._should_die:
|
||||
self.connect_aborted('aborted')
|
||||
thread.exit()
|
||||
raise SystemExit
|
||||
finally:
|
||||
self.lock.release()
|
||||
|
||||
@@ -792,6 +798,7 @@ class WirelessConnectThread(ConnectThread):
|
||||
self.is_connecting = True
|
||||
|
||||
# Run pre-connection script.
|
||||
self.run_global_scripts_if_needed(wpath.preconnectscripts)
|
||||
self.run_script_if_needed(self.before_script, 'pre-connection',
|
||||
self.network['bssid'], self.network['essid'])
|
||||
|
||||
@@ -834,6 +841,7 @@ class WirelessConnectThread(ConnectThread):
|
||||
self.set_dns_addresses()
|
||||
|
||||
# Run post-connection script.
|
||||
self.run_global_scripts_if_needed(wpath.postconnectscripts)
|
||||
self.run_script_if_needed(self.after_script, 'post-connection',
|
||||
self.network['bssid'], self.network['essid'])
|
||||
|
||||
@@ -1002,6 +1010,7 @@ class WiredConnectThread(ConnectThread):
|
||||
self.is_connecting = True
|
||||
|
||||
# Run pre-connection script.
|
||||
self.run_global_scripts_if_needed(wpath.preconnectscripts)
|
||||
self.run_script_if_needed(self.before_script, 'pre-connection', 'wired',
|
||||
'wired')
|
||||
|
||||
@@ -1020,6 +1029,7 @@ class WiredConnectThread(ConnectThread):
|
||||
self.set_dns_addresses()
|
||||
|
||||
# Run post-connection script.
|
||||
self.run_global_scripts_if_needed(wpath.postconnectscripts)
|
||||
self.run_script_if_needed(self.after_script, 'post-connection', 'wired',
|
||||
'wired')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user