Handle KeyboardInterrupt in Buck build wrapper scripts
Pressing Ctrl-C during the build results in an ugly Python TraceBack. Add handling of KeyboardInterrupt and print a useful message. This fixes most cases, but there are still a few TraceBacks coming from inside Buck. These will need to be fixed upstream. Change-Id: I3f0dc19f3be599460a2a6409642a70a195b50753
This commit is contained in:
		| @@ -21,6 +21,7 @@ from os import path | ||||
| from subprocess import Popen, PIPE, CalledProcessError, check_call | ||||
| from xml.dom import minidom | ||||
| import re | ||||
| import sys | ||||
|  | ||||
| MAIN = ['//tools/eclipse:classpath'] | ||||
| GWT = ['//gerrit-gwtui:ui_module'] | ||||
| @@ -141,17 +142,21 @@ def gen_classpath(): | ||||
|   with open(p, 'w') as fd: | ||||
|     doc.writexml(fd, addindent='  ', newl='\n', encoding='UTF-8') | ||||
|  | ||||
| if args.src: | ||||
| try: | ||||
|   if args.src: | ||||
|     try: | ||||
|       check_call([path.join(ROOT, 'tools', 'download_all.py'), '--src']) | ||||
|     except CalledProcessError as err: | ||||
|       exit(1) | ||||
|  | ||||
|   gen_project() | ||||
|   gen_classpath() | ||||
|  | ||||
|   try: | ||||
|     check_call([path.join(ROOT, 'tools', 'download_all.py'), '--src']) | ||||
|     targets = ['//tools:buck.properties'] + MAIN + GWT | ||||
|     check_call(['buck', 'build'] + targets) | ||||
|   except CalledProcessError as err: | ||||
|     exit(1) | ||||
|  | ||||
| gen_project() | ||||
| gen_classpath() | ||||
|  | ||||
| try: | ||||
|   targets = ['//tools:buck.properties'] + MAIN + GWT | ||||
|   check_call(['buck', 'build'] + targets) | ||||
| except CalledProcessError as err: | ||||
| except KeyboardInterrupt: | ||||
|   print('Interrupted by user', file=sys.stderr) | ||||
|   exit(1) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 David Pursehouse
					David Pursehouse