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:
David Pursehouse
2013-10-18 15:08:44 +09:00
parent 757f88ae0d
commit 7a16e859a4
2 changed files with 24 additions and 13 deletions

View File

@@ -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)