From: Frederic Massart Date: Thu, 20 Sep 2012 12:18:42 +0000 (+0800) Subject: Upgrade and update report the failed ones at the end of the process X-Git-Tag: v0.1~17 X-Git-Url: https://git.cameron1729.xyz/?a=commitdiff_plain;h=f7782797e655fc474f689307a454bfff5029cb9c;p=mdk.git Upgrade and update report the failed ones at the end of the process --- diff --git a/moodle-update.py b/moodle-update.py index 525f5cc..bd6043c 100755 --- a/moodle-update.py +++ b/moodle-update.py @@ -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) diff --git a/moodle-upgrade.py b/moodle-upgrade.py index 03963df..a647b68 100755 --- a/moodle-upgrade.py +++ b/moodle-upgrade.py @@ -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)