summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-21 18:03:43 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-09-21 18:03:43 -0400
commit74b4897547980bf8512be7806d1ee8f5ef28aaf8 (patch)
tree7b56845b4ea211978469e9a98a260c45618a1e9a /modules
parent51c125269630afa95cb00a9850c32bee16108753 (diff)
downloadthird_party-func-74b4897547980bf8512be7806d1ee8f5ef28aaf8.tar.gz
third_party-func-74b4897547980bf8512be7806d1ee8f5ef28aaf8.tar.xz
third_party-func-74b4897547980bf8512be7806d1ee8f5ef28aaf8.zip
Process module. Accepts flags to PS, returns nicely formatted tabular output.
Diffstat (limited to 'modules')
-rwxr-xr-xmodules/process.py57
1 files changed, 57 insertions, 0 deletions
diff --git a/modules/process.py b/modules/process.py
new file mode 100755
index 0000000..91b7939
--- /dev/null
+++ b/modules/process.py
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+
+##
+## Process lister (control TBA)
+##
+## Copyright 2007, Red Hat, Inc
+## Michael DeHaan <mdehaan@redhat.com>
+##
+## This software may be freely redistributed under the terms of the GNU
+## general public license.
+##
+## You should have received a copy of the GNU General Public License
+## along with this program; if not, write to the Free Software
+## Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+##
+
+# other modules
+import subprocess
+
+# our modules
+from codes import *
+from modules import func_module
+
+# =================================
+
+class ProcessModule(func_module.FuncModule):
+ def __init__(self):
+ self.methods = {
+ "info": self.info
+ }
+ func_module.FuncModule.__init__(self)
+
+ def info(self,flags="-aux"):
+ """
+ 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
+
+ cmd = subprocess.Popen("ps %s" % flags,stdout=subprocess.PIPE,shell=True)
+ data = cmd.communicate()[0]
+
+ results = []
+
+ for x in data.split("\n"):
+ tokens = x.split()
+ results.append(tokens)
+
+ return results
+
+methods = ProcessModule()
+register_rpc = methods.register_rpc
+
+
+