diff options
author | Adrian Likins <alikins@redhat.com> | 2008-08-21 13:34:15 -0400 |
---|---|---|
committer | Adrian Likins <alikins@redhat.com> | 2008-08-21 13:34:15 -0400 |
commit | 44733335dd76b59e211e8397f008abdba79a3b5f (patch) | |
tree | e23878d681379c735e683ec1e8f92e498f34df63 /func/minion/modules/command.py | |
parent | 4bd91c631f1d81daa416889b0521f95841a1a83a (diff) | |
download | func-44733335dd76b59e211e8397f008abdba79a3b5f.tar.gz func-44733335dd76b59e211e8397f008abdba79a3b5f.tar.xz func-44733335dd76b59e211e8397f008abdba79a3b5f.zip |
add support for specifying a set of enviroment variables to run
a command in.
also, add a unit test case
atm, the env variables specified completely replace the normal
enviroment
Diffstat (limited to 'func/minion/modules/command.py')
-rw-r--r-- | func/minion/modules/command.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/func/minion/modules/command.py b/func/minion/modules/command.py index cc463cf..3d23e49 100644 --- a/func/minion/modules/command.py +++ b/func/minion/modules/command.py @@ -19,17 +19,22 @@ import sub_process class Command(func_module.FuncModule): version = "0.0.1" - api_version = "0.0.1" + api_version = "0.0.2" description = "Works with shell commands." - def run(self, command): + def run(self, command, env=None): """ 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) + + if env: + cmdref = sub_process.Popen(command.split(), stdout=sub_process.PIPE, + stderr=sub_process.PIPE, shell=False, env=env) + else: + 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]) |