summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2013-10-18 15:08:44 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2013-10-18 15:10:25 +0900
commit7a16e859a44a582fcba46bcd3c6f729ad2448b4e (patch)
tree8128db47d9bebf6339ca2d68e1756468a8c4353a
parent757f88ae0d746124bee621aabdc8bc141d93fc2f (diff)
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
-rwxr-xr-xtools/eclipse/project.py25
-rwxr-xr-xtools/pack_war.py12
2 files changed, 24 insertions, 13 deletions
diff --git a/tools/eclipse/project.py b/tools/eclipse/project.py
index e20798e46b..4707de5124 100755
--- a/tools/eclipse/project.py
+++ b/tools/eclipse/project.py
@@ -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)
diff --git a/tools/pack_war.py b/tools/pack_war.py
index 4c5cd89fbb..4ddd6e30f2 100755
--- a/tools/pack_war.py
+++ b/tools/pack_war.py
@@ -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) \ No newline at end of file