mirror of
https://github.com/gryf/wicd.git
synced 2025-12-19 20:38:00 +01:00
Initial crack at global scripts support. Also includes some setup.py tweaks.
This commit is contained in:
@@ -26,6 +26,10 @@ curses_revision = '%CURSES_REVNO%'
|
||||
lib = '%LIB%'
|
||||
share = '%SHARE%'
|
||||
etc = '%ETC%'
|
||||
scripts = '%SCRIPTS%'
|
||||
disconnectscripts = '%DISCONNECTSCRIPTS%'
|
||||
preconnectscripts = '%PRECONNECTSCRIPTS%'
|
||||
postconnectscripts = '%POSTCONNECTSCRIPTS%'
|
||||
images = '%IMAGES%'
|
||||
encryption = '%ENCRYPTION%'
|
||||
bin = '%BIN%'
|
||||
|
||||
56
setup.py
56
setup.py
@@ -51,6 +51,10 @@ class configure(Command):
|
||||
('lib=', None, 'set the lib directory'),
|
||||
('share=', None, 'set the share directory'),
|
||||
('etc=', None, 'set the etc directory'),
|
||||
('scripts=', None, 'set the global scripts directory'),
|
||||
('disconnectscripts=', None, 'set the global disconnect scripts directory'),
|
||||
('preconnectscripts=', None, 'set the global preconnect scripts directory'),
|
||||
('postconnectscripts=', None, 'set the global postconnect scripts directory'),
|
||||
('images=', None, 'set the image directory'),
|
||||
('encryption=', None, 'set the encryption template directory'),
|
||||
('bin=', None, 'set the bin directory'),
|
||||
@@ -96,6 +100,10 @@ class configure(Command):
|
||||
self.lib = '/usr/lib/wicd/'
|
||||
self.share = '/usr/share/wicd/'
|
||||
self.etc = '/etc/wicd/'
|
||||
self.scripts = self.etc + "scripts/"
|
||||
self.preconnectscripts = self.scripts + "preconnect/"
|
||||
self.postconnectscripts = self.scripts + "postconnect/"
|
||||
self.disconnectscripts = self.scripts + "disconnect/"
|
||||
self.icons = '/usr/share/icons/hicolor/'
|
||||
self.images = '/usr/share/pixmaps/wicd/'
|
||||
self.encryption = self.etc + 'encryption/templates/'
|
||||
@@ -175,10 +183,12 @@ class configure(Command):
|
||||
# If we don't get anything from *-config, or it didn't run properly,
|
||||
# or the path is not a proper absolute path, raise an error
|
||||
try:
|
||||
pmtemp = subprocess.Popen(["pkg-config","--variable=pm_sleephooks","pm-utils"], stdout=subprocess.PIPE)
|
||||
pmtemp = subprocess.Popen(["pkg-config", "--variable=pm_sleephooks",
|
||||
"pm-utils"], stdout=subprocess.PIPE)
|
||||
returncode = pmtemp.wait() # let it finish, and get the exit code
|
||||
pmutils_candidate = pmtemp.stdout.readline().strip() # read stdout
|
||||
if len(pmutils_candidate) == 0 or returncode != 0 or not os.path.isabs(pmutils_candidate):
|
||||
if len(pmutils_candidate) == 0 or returncode != 0 or \
|
||||
not os.path.isabs(pmutils_candidate):
|
||||
raise ValueError
|
||||
else:
|
||||
self.pmutils = pmutils_candidate
|
||||
@@ -189,7 +199,8 @@ class configure(Command):
|
||||
kdetemp = subprocess.Popen(["kde-config","--prefix"], stdout=subprocess.PIPE)
|
||||
returncode = kdetemp.wait() # let it finish, and get the exit code
|
||||
kdedir_candidate = kdetemp.stdout.readline().strip() # read stdout
|
||||
if len(kdedir_candidate) == 0 or returncode != 0 or not os.path.isabs(kdedir_candidate):
|
||||
if len(kdedir_candidate) == 0 or returncode != 0 or \
|
||||
not os.path.isabs(kdedir_candidate):
|
||||
raise ValueError
|
||||
else:
|
||||
self.kdedir = kdedir_candidate + '/share/autostart'
|
||||
@@ -218,11 +229,10 @@ class configure(Command):
|
||||
|
||||
|
||||
def finalize_options(self):
|
||||
if self.distro_detect_failed == True:
|
||||
if not self.no_install_init:
|
||||
if self.init == 'FAIL' or self.initfile == 'FAIL':
|
||||
print 'ERROR: Failed to detect distro. Configure cannot continue. ' + \
|
||||
'Please specify --init and --initfile to continue with configuration.'
|
||||
if self.distro_detect_failed and not self.no_install_init and \
|
||||
'FAIL' in [self.init, self.initfile]:
|
||||
print 'ERROR: Failed to detect distro. Configure cannot continue. ' + \
|
||||
'Please specify --init and --initfile to continue with configuration.'
|
||||
|
||||
|
||||
# loop through the argument definitions in user_options
|
||||
@@ -408,6 +418,10 @@ try:
|
||||
(wpath.lib, ['wicd/wicd-client.py', 'wicd/monitor.py', 'wicd/wicd-daemon.py', 'wicd/configscript.py', 'wicd/suspend.py', 'wicd/autoconnect.py']), #'wicd/wicd-gui.py',
|
||||
(wpath.backends, ['wicd/backends/be-external.py', 'wicd/backends/be-ioctl.py']),
|
||||
(wpath.autostart, ['other/wicd-tray.desktop', ]),
|
||||
(wpath.scripts, []),
|
||||
(wpath.disconnectscripts, []),
|
||||
(wpath.preconnectscripts, []),
|
||||
(wpath.postconnectscripts, []),
|
||||
]
|
||||
if not wpath.no_install_ncurses:
|
||||
data.append(( wpath.lib, ['curses/curses_misc.py']))
|
||||
@@ -456,14 +470,16 @@ except Exception, e:
|
||||
python setup.py configure has not yet been run.'''
|
||||
|
||||
|
||||
wpactrl_ext = Extension(name = 'wpactrl', sources = ['depends/python-wpactrl/wpa_ctrl.c', 'depends/python-wpactrl/wpactrl.c'],
|
||||
extra_compile_args = ["-fno-strict-aliasing"])
|
||||
wpactrl_ext = Extension(name = 'wpactrl',
|
||||
sources = ['depends/python-wpactrl/wpa_ctrl.c',
|
||||
'depends/python-wpactrl/wpactrl.c'],
|
||||
extra_compile_args = ["-fno-strict-aliasing"])
|
||||
|
||||
iwscan_ext = Extension(name = 'iwscan',
|
||||
libraries = ['iw'],
|
||||
sources = ['depends/python-iwscan/pyiwscan.c'])
|
||||
iwscan_ext = Extension(name = 'iwscan', libraries = ['iw'],
|
||||
sources = ['depends/python-iwscan/pyiwscan.c'])
|
||||
|
||||
setup(cmdclass={'configure' : configure, 'get_translations' : get_translations, 'uninstall' : uninstall, 'test' : test, 'cleargenerated' : cleargenerated},
|
||||
setup(cmdclass={'configure' : configure, 'get_translations' : get_translations,
|
||||
'uninstall' : uninstall, 'test' : test, 'cleargenerated' : cleargenerated},
|
||||
name="Wicd",
|
||||
version=VERSION_NUM,
|
||||
description="A wireless and wired network manager",
|
||||
@@ -476,16 +492,12 @@ encryption types, such as WPA and WEP. Wicd will automatically
|
||||
connect at startup to any preferred network within range.
|
||||
""",
|
||||
author="Adam Blackburn, Dan O'Reilly",
|
||||
author_email="compwiz18@users.sourceforge.net, imdano@users.sourceforge.net",
|
||||
author_email="compwiz18@users.sourceforge.net, oreilldf@gmail.com",
|
||||
url="http://wicd.net",
|
||||
license="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html",
|
||||
## scripts=['configscript.py', 'autoconnect.py', 'gui.py', 'wicd.py', 'daemon.py', 'suspend.py', 'monitor.py'],
|
||||
py_modules=['wicd.networking', 'wicd.misc', 'wicd.gui', 'wicd.wnettools', 'wicd.wpath',
|
||||
'wicd.prefs', 'wicd.netentry', 'wicd.dbusmanager', 'wicd.logfile', 'wicd.backend',
|
||||
'wicd.configmanager', 'wicd.guiutil'],
|
||||
py_modules=['wicd.networking', 'wicd.misc', 'wicd.gui', 'wicd.wnettools',
|
||||
'wicd.wpath', 'wicd.prefs', 'wicd.netentry', 'wicd.dbusmanager',
|
||||
'wicd.logfile', 'wicd.backend', 'wicd.configmanager', 'wicd.guiutil'],
|
||||
ext_modules=[iwscan_ext, wpactrl_ext],
|
||||
data_files=data
|
||||
)
|
||||
##print "Running post-install configuration..."
|
||||
##os.system("other/postinst")
|
||||
##print 'Done.'
|
||||
|
||||
@@ -202,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()
|
||||
@@ -368,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.
|
||||
@@ -379,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):
|
||||
@@ -761,6 +768,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'])
|
||||
|
||||
@@ -803,6 +811,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'])
|
||||
|
||||
@@ -971,6 +980,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')
|
||||
|
||||
@@ -989,6 +999,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