From f7782797e655fc474f689307a454bfff5029cb9c Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Thu, 20 Sep 2012 20:18:42 +0800 Subject: [PATCH] Upgrade and update report the failed ones at the end of the process --- moodle-update.py | 13 ++++++++++++- moodle-upgrade.py | 12 +++++++++++- 2 files changed, 23 insertions(+), 2 deletions(-) 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) -- 2.11.0