mirror of
https://github.com/gryf/wicd.git
synced 2025-12-23 06:37:59 +01:00
added support for passing parameters to the global scripts
This commit is contained in:
11
wicd/misc.py
11
wicd/misc.py
@@ -180,18 +180,19 @@ def WriteLine(my_file, text):
|
||||
""" write a line to a file """
|
||||
my_file.write(text + "\n")
|
||||
|
||||
def ExecuteScripts(scripts_dir, verbose=False):
|
||||
def ExecuteScripts(scripts_dir, verbose=False, extra_parameters=()):
|
||||
""" Execute every executable file in a given directory. """
|
||||
for obj in os.listdir(scripts_dir):
|
||||
obj = os.path.abspath(os.path.join(scripts_dir, obj))
|
||||
if os.path.isfile(obj) and os.access(obj, os.X_OK):
|
||||
ExecuteScript(os.path.abspath(obj), verbose=verbose)
|
||||
ExecuteScript(os.path.abspath(obj), verbose=verbose,
|
||||
extra_parameters=extra_parameters)
|
||||
|
||||
def ExecuteScript(script, verbose=False):
|
||||
def ExecuteScript(script, verbose=False, extra_parameters=()):
|
||||
""" Execute a command and send its output to the bit bucket. """
|
||||
if verbose:
|
||||
print "Executing %s" % script
|
||||
ret = call("%s > /dev/null 2>&1" % script, shell=True)
|
||||
print "Executing %s with params %s" % (script, ' '.join(extra_parameters))
|
||||
ret = call("%s %s > /dev/null 2>&1" % (script, ' '.join(extra_parameters)), shell=True)
|
||||
if verbose:
|
||||
print "%s returned %s" % (script, ret)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user