Make subprocess2.check_call() compliant with subprocess.check_call().
Rename check_call to check_call_out. It's a quite specific need when stderr is
needed or when the user doesn't want the default arguments of check_output.
R=dpranke@chromium.org
BUG=
TEST=
Review URL: http://codereview.chromium.org/6882127
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@83023 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/subprocess2.py b/subprocess2.py
index acfe4a9..4ba3c65 100644
--- a/subprocess2.py
+++ b/subprocess2.py
@@ -256,7 +256,7 @@
return communicate(args, **kwargs)[1]
-def check_call(args, **kwargs):
+def check_call_out(args, **kwargs):
"""Improved version of subprocess.check_call().
Returns (stdout, stderr), unlike subprocess.check_call().
@@ -268,6 +268,12 @@
return out
+def check_call(args, **kwargs):
+ """Emulate subprocess.check_call()."""
+ check_call_out(args, **kwargs)
+ return 0
+
+
def capture(args, **kwargs):
"""Captures stdout of a process call and returns it.
@@ -287,9 +293,9 @@
def check_output(args, **kwargs):
- """Captures stdout of a process call and returns it.
+ """Emulates subprocess.check_output().
- Returns stdout.
+ Captures stdout of a process call and returns stdout only.
- Discards stderr. By default sets stderr=STDOUT.
- Throws if return code is not 0.
@@ -302,4 +308,4 @@
kwargs['stdout'] = PIPE
if kwargs.get('stderr') is None:
kwargs['stderr'] = STDOUT
- return check_call(args, **kwargs)[0]
+ return check_call_out(args, **kwargs)[0]