diff options
-rw-r--r-- | client/test_func.py | 4 | ||||
-rwxr-xr-x | modules/process.py | 57 |
2 files changed, 61 insertions, 0 deletions
diff --git a/client/test_func.py b/client/test_func.py index 57cf5d7..866af36 100644 --- a/client/test_func.py +++ b/client/test_func.py @@ -5,6 +5,7 @@ import xmlrpclib +TEST_PROCESS = True TEST_VIRT = False TEST_SERVICES = True TEST_HARDWARE = True @@ -15,6 +16,9 @@ s = xmlrpclib.ServerProxy("http://127.0.0.1:51234") # here's the basic test... print s.test.add(1, 2) +if TEST_PROCESS: + print s.process.info() + # here's the service module testing if TEST_SERVICES: print s.service.restart("httpd") 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 + + + |