From 712682a3b09f7934a4f121557407a26efd8cf1e4 Mon Sep 17 00:00:00 2001 From: Sam Parkinson Date: Sat, 22 Nov 2014 07:39:31 +1100 Subject: [PATCH] BundleBuilder: Don't crash on malformed translation files The BundleBuilder currently crashes on a malformed translation file. This is good for humans (makes them fix their issues) but crashes bots who need it compiled and don't care about that single translation file. This patch adds a --no-fail option which stops the builder from crashing --- src/sugar3/activity/bundlebuilder.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/sugar3/activity/bundlebuilder.py b/src/sugar3/activity/bundlebuilder.py index 3a090e83..d1095aa9 100644 --- a/src/sugar3/activity/bundlebuilder.py +++ b/src/sugar3/activity/bundlebuilder.py @@ -103,8 +103,9 @@ class Config(object): class Builder(object): - def __init__(self, config): + def __init__(self, config, no_fail=False): self.config = config + self._no_fail = no_fail self.locale_dir = os.path.join(self.config.build_dir, 'locale') def build(self): @@ -137,6 +138,8 @@ class Builder(object): retcode = subprocess.call(args) if retcode: print 'ERROR - msgfmt failed with return code %i.' % retcode + if self._no_fail: + continue cat = gettext.GNUTranslations(open(mo_file, 'r')) translated_name = cat.gettext(self.config.activity_name) @@ -329,7 +332,7 @@ def cmd_dev(config, options): def cmd_dist_xo(config, options): """Create a xo bundle package""" - packager = XOPackager(Builder(config)) + packager = XOPackager(Builder(config, options.no_fail)) packager.package() @@ -427,7 +430,12 @@ def start(): default=1, nargs='?', help="verbosity for the unit tests") - subparsers.add_parser("dist_xo", help="Create a xo bundle package") + dist_parser = subparsers.add_parser("dist_xo", + help="Create a xo bundle package") + dist_parser.add_argument("--no-fail", dest="no_fail", action="store_true", + default=False, + help="continue past failure when building xo file") + subparsers.add_parser("dist_source", help="Create a tar source package") subparsers.add_parser("build", help="Build generated files") subparsers.add_parser(