summaryrefslogtreecommitdiffstats
path: root/func/minion/modules/process.py
diff options
context:
space:
mode:
authorLuke Macken <lmacken@redhat.com>2008-01-15 17:42:18 -0500
committerLuke Macken <lmacken@redhat.com>2008-01-15 17:42:18 -0500
commit5d7f93adae47ae2aa137f3f44fb077ed26ed9012 (patch)
tree605eed9003647afac258f1c3f00e5f1d975f43a0 /func/minion/modules/process.py
parent23c9c26d270ff766133e7aeebffc99a35633ef41 (diff)
parentdc85cea9b1912ad2cbe59224050b8ae38b051167 (diff)
downloadthird_party-func-5d7f93adae47ae2aa137f3f44fb077ed26ed9012.tar.gz
third_party-func-5d7f93adae47ae2aa137f3f44fb077ed26ed9012.tar.xz
third_party-func-5d7f93adae47ae2aa137f3f44fb077ed26ed9012.zip
Merge branch 'master' of ssh+git://git.fedorahosted.org/git/func
Diffstat (limited to 'func/minion/modules/process.py')
-rw-r--r--func/minion/modules/process.py26
1 files changed, 17 insertions, 9 deletions
diff --git a/func/minion/modules/process.py b/func/minion/modules/process.py
index 18b5abe..e5b9183 100644
--- a/func/minion/modules/process.py
+++ b/func/minion/modules/process.py
@@ -24,22 +24,27 @@ import func_module
class ProcessModule(func_module.FuncModule):
- 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)
@@ -188,15 +193,18 @@ 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