Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(220)

Unified Diff: lib/cros_build_lib.py

Issue 6296013: Add a verbose option to RunCommandCaptureOutput. Not used yet, does not (Closed) Base URL: http://git.chromium.org/git/crosutils.git@master
Patch Set: Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/cros_build_lib.py
diff --git a/lib/cros_build_lib.py b/lib/cros_build_lib.py
index 2e6876060c1dce08b93bfa630402f598e7ba548d..bb1aba32ac8f692f00bcf45036c704a8b16c8717 100644
--- a/lib/cros_build_lib.py
+++ b/lib/cros_build_lib.py
@@ -95,7 +95,8 @@ def RunCommand(cmd, print_cmd=True, error_ok=False, error_message=None,
def RunCommandCaptureOutput(cmd, print_cmd=True, cwd=None, input=None,
enter_chroot=False,
- combine_stdout_stderr=True):
+ combine_stdout_stderr=True,
+ verbose=False):
"""Runs a shell command. Differs from RunCommand, because it allows
you to run a command and capture the exit code, output, and stderr
all at the same time.
@@ -109,6 +110,7 @@ def RunCommandCaptureOutput(cmd, print_cmd=True, cwd=None, input=None,
enter_chroot: this command should be run from within the chroot. If set,
cwd must point to the scripts directory.
combine_stdout_stderr -- combine outputs together.
+ verbose -- also echo cmd.stdout and cmd.stderr to stdout and stderr
Returns:
Returns a tuple: (exit_code, stdout, stderr) (integer, string, string)
@@ -132,7 +134,11 @@ def RunCommandCaptureOutput(cmd, print_cmd=True, cwd=None, input=None,
proc = subprocess.Popen(cmd, cwd=cwd, stdin=stdin,
stdout=stdout, stderr=stderr)
- (output, error) = proc.communicate(input)
+ output, error = proc.communicate(input)
sosa 2011/01/20 03:40:55 I'm not sure this completely helps us because if t
+
+ if verbose:
+ if output: sys.stdout.write(output)
+ if error: sys.stderr.write(error)
# Error is None if stdout, stderr are combined.
return proc.returncode, output, error
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698