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

Unified Diff: gclient_utils.py

Issue 7891058: Print diagnosis message when a task is Ctrl-C'ed out (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 3 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: gclient_utils.py
diff --git a/gclient_utils.py b/gclient_utils.py
index 9be529cc01ee08cdee8eb690ad34c45dffc6106f..89050b7add1469f184c83b1c636910e7aa88a04f 100644
--- a/gclient_utils.py
+++ b/gclient_utils.py
@@ -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:
# 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.
- in_byte = kid.stdout.read(1)
- if in_byte:
- if call_filter_on_first_line:
- filter_fn(None)
- in_line = ''
- while in_byte:
- if in_byte != '\r':
- if print_stdout:
- stdout.write(in_byte)
- if in_byte != '\n':
- in_line += in_byte
- else:
- filter_fn(in_line)
- in_line = ''
- in_byte = kid.stdout.read(1)
- # Flush the rest of buffered output. This is only an issue with
- # stdout/stderr not ending with a \n.
- if len(in_line):
- filter_fn(in_line)
- rv = kid.wait()
+ try:
+ in_byte = kid.stdout.read(1)
+ if in_byte:
+ if call_filter_on_first_line:
+ filter_fn(None)
+ in_line = ''
+ while in_byte:
+ if in_byte != '\r':
+ if print_stdout:
+ stdout.write(in_byte)
+ if in_byte != '\n':
+ in_line += in_byte
+ else:
+ filter_fn(in_line)
+ in_line = ''
+ in_byte = kid.stdout.read(1)
+ # Flush the rest of buffered output. This is only an issue with
+ # stdout/stderr not ending with a \n.
+ if len(in_line):
+ filter_fn(in_line)
+ rv = kid.wait()
+ except KeyboardInterrupt:
+ print >> sys.stderr, 'Failed while running "%s"' % ' '.join(args)
+ raise
+
if rv:
raise subprocess2.CalledProcessError(
rv, args, kwargs.get('cwd', None), None, None)
« 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