summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--func/minion/modules/command.py13
-rw-r--r--test/unittest/test_client.py5
2 files changed, 14 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])
diff --git a/test/unittest/test_client.py b/test/unittest/test_client.py
index 4734093..d1b37a5 100644
--- a/test/unittest/test_client.py
+++ b/test/unittest/test_client.py
@@ -170,6 +170,11 @@ class TestCommand(BaseTest):
assert result[self.th][1].split("-")[0] == "filesystem"
+ def test_env(self):
+ result = self.overlord.command.run("env",
+ {'BLIPPYFOO':'awesome'})
+ self.assert_on_fault(result)
+ assert result[self.th][1].strip() == "BLIPPYFOO=awesome"
class TestCopyfile(BaseTest):
fn = "/tmp/func_test_file"