Print diagnosis message when a task is Ctrl-C'ed out

R=dpranke@chromium.org
BUG=
TEST=


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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@101133 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
maruel@chromium.org 14 years ago
parent f36c0ee520
commit 109cb9d31f

@ -343,26 +343,31 @@ def CheckCallAndFilter(args, stdout=None, filter_fn=None,
# This has to be done on a per byte basis to make sure it is not buffered: # This has to be done on a per byte basis to make sure it is not buffered:
# normally buffering is done for each line, but if svn requests input, no # normally buffering is done for each line, but if svn requests input, no
# end-of-line character is output after the prompt and it would not show up. # end-of-line character is output after the prompt and it would not show up.
in_byte = kid.stdout.read(1) try:
if in_byte: in_byte = kid.stdout.read(1)
if call_filter_on_first_line: if in_byte:
filter_fn(None) if call_filter_on_first_line:
in_line = '' filter_fn(None)
while in_byte: in_line = ''
if in_byte != '\r': while in_byte:
if print_stdout: if in_byte != '\r':
stdout.write(in_byte) if print_stdout:
if in_byte != '\n': stdout.write(in_byte)
in_line += in_byte if in_byte != '\n':
else: in_line += in_byte
filter_fn(in_line) else:
in_line = '' filter_fn(in_line)
in_byte = kid.stdout.read(1) in_line = ''
# Flush the rest of buffered output. This is only an issue with in_byte = kid.stdout.read(1)
# stdout/stderr not ending with a \n. # Flush the rest of buffered output. This is only an issue with
if len(in_line): # stdout/stderr not ending with a \n.
filter_fn(in_line) if len(in_line):
rv = kid.wait() filter_fn(in_line)
rv = kid.wait()
except KeyboardInterrupt:
print >> sys.stderr, 'Failed while running "%s"' % ' '.join(args)
raise
if rv: if rv:
raise subprocess2.CalledProcessError( raise subprocess2.CalledProcessError(
rv, args, kwargs.get('cwd', None), None, None) rv, args, kwargs.get('cwd', None), None, None)

Loading…
Cancel
Save