summaryrefslogtreecommitdiffstats
path: root/func/minion
diff options
context:
space:
mode:
authorSteve 'Ashcrow' Milner <stevem@gnulinux.net>2008-01-14 21:34:17 -0500
committerSteve 'Ashcrow' Milner <stevem@gnulinux.net>2008-01-14 21:34:17 -0500
commit462b3fbe80a6f82d207652e737212a2dc94061b7 (patch)
treee9ac447718716bf2014ad71e8b9d187bb08dd0f2 /func/minion
parentbd9e4fe320ac35efaacd792be6edfa32838801e9 (diff)
downloadfunc-462b3fbe80a6f82d207652e737212a2dc94061b7.tar.gz
func-462b3fbe80a6f82d207652e737212a2dc94061b7.tar.xz
func-462b3fbe80a6f82d207652e737212a2dc94061b7.zip
Fixed the FIXME note about stdout/stderr in process.info. Also raise exception when bad args are passed using the first line as the exception message.
Diffstat (limited to 'func/minion')
-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 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()