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)

View File

@@ -13,9 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import print_function
from optparse import OptionParser
from os import environ, makedirs, path, symlink
from subprocess import check_call
import sys
from util import check_output
opts = OptionParser()
@@ -43,6 +45,10 @@ if args.lib:
link_jars(args.lib, path.join(war, 'WEB-INF', 'lib'))
if args.pgmlib:
link_jars(args.pgmlib, path.join(war, 'WEB-INF', 'pgm-lib'))
for s in ctx:
check_call(['unzip', '-q', '-d', war, s])
check_call(['zip', '-9qr', args.o, '.'], cwd = war)
try:
for s in ctx:
check_call(['unzip', '-q', '-d', war, s])
check_call(['zip', '-9qr', args.o, '.'], cwd = war)
except KeyboardInterrupt:
print('Interrupted by user', file=sys.stderr)
exit(1)