sugar-toolkit-0.88 (0.88.1-3) 2003_bundlebuilder_exit_nonzero_on_error.patch

Summary

 src/sugar/activity/bundlebuilder.py |   28 ++++++++++++++++++++--------
 1 file changed, 20 insertions(+), 8 deletions(-)

    
download this patch

Patch contents

Description: Fail (exit with errorcode 1) on fatal errors in bundlebuilder.py
Author: Jonas Smedegaard <dr@jones.dk>
Last-Update: 2010-02-08
--- a/src/sugar/activity/bundlebuilder.py
+++ b/src/sugar/activity/bundlebuilder.py
@@ -132,6 +132,7 @@
             retcode = subprocess.call(args)
             if retcode:
                 print 'ERROR - msgfmt failed with return code %i.' % retcode
+                exit (1)
 
             cat = gettext.GNUTranslations(open(mo_file, 'r'))
             translated_name = cat.gettext(self.config.activity_name)
@@ -144,7 +145,7 @@
         files = self.config.bundle.get_files()
 
         if not files:
-            logging.error('No files found, fixing the MANIFEST.')
+            logging.warn('No files found, fixing the MANIFEST.')
             self.fix_manifest()
             files = self.config.bundle.get_files()
 
@@ -279,8 +280,9 @@
     '''Setup for development'''
 
     if args:
+        print 'ERROR - Wrong argument.'
         print 'Usage: %prog dev'
-        return
+        exit (1)
 
     bundle_path = env.get_user_activities_path()
     if not os.path.isdir(bundle_path):
@@ -293,14 +295,16 @@
             print 'ERROR - The bundle has been already setup for development.'
         else:
             print 'ERROR - A bundle with the same name is already installed.'
+        exit (1)
 
 
 def cmd_dist_xo(config, args):
     '''Create a xo bundle package'''
 
     if args:
+        print 'ERROR - Wrong argument.'
         print 'Usage: %prog dist_xo'
-        return
+        exit (1)
 
     packager = XOPackager(Builder(config))
     packager.package()
@@ -310,8 +314,9 @@
     '''Add missing files to the manifest'''
 
     if args:
+        print 'ERROR - Wrong argument.'
         print 'Usage: %prog fix_manifest'
-        return
+        exit (1)
 
     builder = Builder(config)
     builder.fix_manifest()
@@ -321,8 +326,9 @@
     '''Create a tar source package'''
 
     if args:
+        print 'ERROR - Wrong argument.'
         print 'Usage: %prog dist_source'
-        return
+        exit (1)
 
     packager = SourcePackager(config)
     packager.package()
@@ -336,8 +342,9 @@
                       help='Prefix to install files to')
     (suboptions, subargs) = parser.parse_args(args)
     if subargs:
+        print 'ERROR - Wrong argument.'
         parser.print_help()
-        return
+        exit (1)
 
     installer = Installer(Builder(config))
     installer.install(suboptions.prefix)
@@ -347,8 +354,9 @@
     '''Generate the gettext pot file'''
 
     if args:
+        print 'ERROR - Wrong argument.'
         print 'Usage: %prog genpot'
-        return
+        exit (1)
 
     po_path = os.path.join(config.source_dir, 'po')
     if not os.path.isdir(po_path):
@@ -380,14 +388,16 @@
     retcode = subprocess.call(args)
     if retcode:
         print 'ERROR - xgettext failed with return code %i.' % retcode
+        exit (1)
 
 
 def cmd_build(config, args):
     '''Build generated files'''
 
     if args:
+        print 'ERROR - Wrong argument.'
         print 'Usage: %prog build'
-        return
+        exit (1)
 
     builder = Builder(config)
     builder.build()
@@ -417,7 +427,9 @@
     try:
         globals()['cmd_' + args[0]](config, args[1:])
     except (KeyError, IndexError):
+        print 'ERROR - Wrong command or argument.'
         print_commands()
+        exit (1)
 
 
 if __name__ == '__main__':