diff options
author | Michael DeHaan <mdehaan@mdehaan.rdu.redhat.com> | 2007-09-28 15:37:40 -0400 |
---|---|---|
committer | Michael DeHaan <mdehaan@mdehaan.rdu.redhat.com> | 2007-09-28 15:37:40 -0400 |
commit | 114dd90baf8d300e7ba6f058fe42a0d2ebdbd223 (patch) | |
tree | 57038d490020a7ec1772e8c91e26a8c03ff118a3 /modules | |
parent | fe69fb77f1c504b885720d2238478a2467ebac16 (diff) | |
download | third_party-func-114dd90baf8d300e7ba6f058fe42a0d2ebdbd223.tar.gz third_party-func-114dd90baf8d300e7ba6f058fe42a0d2ebdbd223.tar.xz third_party-func-114dd90baf8d300e7ba6f058fe42a0d2ebdbd223.zip |
Make the command module use subprocess to capture stdin/stdout and return them to the caller.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/command.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/modules/command.py b/modules/command.py index d862199..5dc0292 100644 --- a/modules/command.py +++ b/modules/command.py @@ -25,8 +25,16 @@ class Command(func_module.FuncModule): func_module.FuncModule.__init__(self) def run(self, command): - return sub_process.call(command.split()) + """ + Runs a command, returning the return code, stdout, and stderr as a tuple. + NOT FOR USE WITH INTERACTIVE COMMANDS. + """ + cmdref = sub_process.Popen(command.split(),stdout=sub_process.PIPE,stderr=sub_process.PIPE, shell=False) + data = cmdref.communicate() + return (cmdref.returncode, data[0], data[1]) methods = Command() register_rpc = methods.register_rpc + + |