Use a marker instead of a string so it can be distingished when used as stdin.

R=dpranke@chromium.org
BUG=
TEST=

Review URL: http://codereview.chromium.org/6840053

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@81941 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
maruel@chromium.org 14 years ago
parent 3bc36d136c
commit 0d5ef24c5d

@ -21,7 +21,7 @@ import threading
PIPE = subprocess.PIPE PIPE = subprocess.PIPE
STDOUT = subprocess.STDOUT STDOUT = subprocess.STDOUT
# Sends stdout or stderr to os.devnull. # Sends stdout or stderr to os.devnull.
VOID = '/dev/null' VOID = object()
# Error code when a process was killed because it timed out. # Error code when a process was killed because it timed out.
TIMED_OUT = -2001 TIMED_OUT = -2001
@ -203,7 +203,11 @@ def call(args, timeout=None, **kwargs):
""" """
stdin = kwargs.pop('stdin', None) stdin = kwargs.pop('stdin', None)
if stdin is not None: if stdin is not None:
assert stdin != PIPE if stdin is VOID:
kwargs['stdin'] = open(os.devnull, 'r')
stdin = None
else:
assert isinstance(stdin, str)
# When stdin is passed as an argument, use it as the actual input data and # When stdin is passed as an argument, use it as the actual input data and
# set the Popen() parameter accordingly. # set the Popen() parameter accordingly.
kwargs['stdin'] = PIPE kwargs['stdin'] = PIPE

Loading…
Cancel
Save