Upgrade and update report the failed ones at the end of the process
authorFrederic Massart <fred@moodle.com>
Thu, 20 Sep 2012 12:18:42 +0000 (20:18 +0800)
committerFrederic Massart <fred@moodle.com>
Thu, 20 Sep 2012 12:49:26 +0000 (20:49 +0800)
moodle-update.py
moodle-upgrade.py

index 525f5cc..bd6043c 100755 (executable)
@@ -59,11 +59,14 @@ if len(Mlist) < 1:
     debug('No instances to work on. Exiting...')
     sys.exit(1)
 
+errors = []
+
 for M in Mlist:
        debug('Updating %s...' % M.get('identifier'))
        try:
                M.update()
        except Exception as e:
+               errors.append(M)
                debug('Error during the update of %s' % M.get('identifier'))
                debug(e)
        else:
@@ -71,7 +74,15 @@ for M in Mlist:
                        try:
                                M.upgrade()
                        except Exception as e:
+                               errors.append(M)
+                               debug('Error during the upgrade of %s' % M.get('identifier'))
                                pass
        debug('')
-
 debug('Done.')
+
+if errors and len(Mlist) > 1:
+       debug('')
+       debug('/!\ Some errors occurred on the following instances:')
+       for M in errors:
+               debug('- %s' % M.get('identifier'))
+       sys.exit(1)
index 03963df..a647b68 100755 (executable)
@@ -51,12 +51,15 @@ if len(Mlist) < 1:
     debug('No instances to work on. Exiting...')
     sys.exit(1)
 
+errors = []
+
 for M in Mlist:
        if args.update:
                debug('Updating %s...' % M.get('identifier'))
                try:
                        M.update()
                except Exception as e:
+                       errors.append(M)
                        debug('Error during update. Skipping...')
                        debug(e)
                        continue
@@ -65,8 +68,15 @@ for M in Mlist:
        try:
                M.upgrade(args.nocheckout)
        except Exception as e:
+               errors.append(M)
                debug('Error during the upgrade of %s' % M.get('identifier'))
                debug(e)
        debug('')
-
 debug('Done.')
+
+if errors and len(Mlist) > 1:
+       debug('')
+       debug('/!\ Some errors occurred on the following instances:')
+       for M in errors:
+               debug('- %s' % M.get('identifier'))
+       sys.exit(1)