diff options
Diffstat (limited to 'func/minion/modules/process.py')
-rw-r--r-- | func/minion/modules/process.py | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/func/minion/modules/process.py b/func/minion/modules/process.py index 92c6d6a..bdd5193 100644 --- a/func/minion/modules/process.py +++ b/func/minion/modules/process.py @@ -32,22 +32,27 @@ class ProcessModule(func_module.FuncModule): } func_module.FuncModule.__init__(self) - def info(self,flags="-auxh"): + def info(self, flags="-auxh"): """ Returns a struct of hardware information. By default, this pulls down all of the devices. If you don't care about them, set with_devices to False. """ - flags.replace(";","") # prevent stupidity + flags.replace(";", "") # prevent stupidity + cmd = sub_process.Popen(["/bin/ps", flags], executable="/bin/ps", + stdout=sub_process.PIPE, + stderr=sub_process.PIPE, + shell=False) - #FIXME: we need to swallow stdout/stderr as well, right now it spews to the console - cmd = sub_process.Popen(["/bin/ps", flags] ,executable="/bin/ps", stdout=sub_process.PIPE,shell=False) - data = cmd.communicate()[0] + data, error = cmd.communicate() - results = [] + # We can get warnings for odd formatting. warnings != errors. + if error and error[:7] != "Warning": + raise codes.FuncException(error.split('\n')[0]) + results = [] for x in data.split("\n"): tokens = x.split() results.append(tokens) @@ -196,17 +201,20 @@ class ProcessModule(func_module.FuncModule): if pid == "0": raise codes.FuncException("Killing pid group 0 not permitted") if signal == "": - # this is default /bin/kill behaviour, it claims, but enfore it anyway + # this is default /bin/kill behaviour, + # it claims, but enfore it anyway signal = "-TERM" if signal[0] != "-": signal = "-%s" % signal - rc = sub_process.call(["/bin/kill",signal, pid], executable="/bin/kill", shell=False) + rc = sub_process.call(["/bin/kill",signal, pid], + executable="/bin/kill", shell=False) print rc return rc def pkill(self,name,level=""): # example killall("thunderbird","-9") - rc = sub_process.call(["/usr/bin/pkill", name, level], executable="/usr/bin/pkill", shell=False) + rc = sub_process.call(["/usr/bin/pkill", name, level], + executable="/usr/bin/pkill", shell=False) return rc methods = ProcessModule() |