diff options
author | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-12-28 17:58:34 (GMT) |
---|---|---|
committer | Daniel Narvaez <dwnarvaez@gmail.com> | 2012-12-28 17:58:34 (GMT) |
commit | 18bda03d4ba8722b9d78d4a83896b8cfbb2ba489 (patch) | |
tree | 6762695dcc77cf0158820abcf97ff63bc748aa59 /devbot | |
parent | ce40e73ae0ce6593d2871c8a42d37a2be679454f (diff) |
Use command to run so we get logging for free
Diffstat (limited to 'devbot')
-rw-r--r-- | devbot/run.py | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/devbot/run.py b/devbot/run.py index 08ebe94..23ef801 100644 --- a/devbot/run.py +++ b/devbot/run.py @@ -7,10 +7,11 @@ import time import tempfile from devbot import config +from devbot import command -def run(command): - args = [command, "--home-dir", config.home_dir] +def run(cmd): + args = [cmd, "--home-dir", config.home_dir] resolution = config.get_pref("RESOLUTION") if resolution: @@ -20,24 +21,18 @@ def run(command): if output: args.extend(["--output", output]) - stdout = open(config.log_path, 'a') - stderr = stdout + command.run(args) - os.dup2(stdout.fileno(), sys.stdout.fileno()) - os.dup2(stderr.fileno(), sys.stderr.fileno()) - os.execlp(args[0], *args) - - -def run_test(command, test_path): +def run_test(test_cmd, test_path): temp_dir = tempfile.mkdtemp("sugar-build-test") display_path = os.path.join(temp_dir, "display") - args = [command, + args = [test_cmd, "--display-path", display_path, "--virtual"] - command_process = subprocess.Popen(args, stdout=subprocess.PIPE) + test_cmd_process = subprocess.Popen(args, stdout=subprocess.PIPE) while True: if not os.path.exists(display_path): @@ -52,12 +47,12 @@ def run_test(command, test_path): os.rmdir(temp_dir) try: - subprocess.check_call(["python", "-u", test_path]) + command.run(["python", "-u", test_path]) result = True except subprocess.CalledProcessError: result = False - command_process.terminate() + test_cmd_process.terminate() return result |