Do not exit after updating cached remotes
authorFrederic Massart <fred@moodle.com>
Wed, 23 Jan 2013 06:39:49 +0000 (14:39 +0800)
committerFrederic Massart <fred@moodle.com>
Wed, 23 Jan 2013 06:39:49 +0000 (14:39 +0800)
moodle-update.py

index 9496a4d..9202677 100755 (executable)
@@ -24,7 +24,7 @@ http://github.com/FMCorz/mdk
 
 import sys
 import argparse
-from lib import workplace, moodle, tools
+from lib import workplace
 from lib.tools import debug
 from lib.config import Conf
 
@@ -37,23 +37,23 @@ parser.add_argument('-a', '--all', action='store_true', help='runs the script on
 parser.add_argument('-i', '--integration', action='store_true', help='runs the script on the integration instances', dest='integration')
 parser.add_argument('-s', '--stable', action='store_true', help='runs the script on the stable instances', dest='stable')
 parser.add_argument('-u', '--upgrade', action='store_true', help='upgrade the instance after successful update', dest='upgrade')
-parser.add_argument('-c', '--update-cache', action='store_true', help='only update the cached remotes. Useful when using cache as remote.', dest='updatecache')
+parser.add_argument('-c', '--update-cache', action='store_true', help='update the cached remotes. Useful when using cache as remote.', dest='updatecache')
 parser.add_argument('names', metavar='names', default=None, nargs='*', help='name of the instances')
 args = parser.parse_args()
 
 # Updating cache only
 if args.updatecache:
-       debug('Updating cached remote')
-       Wp.updateCachedClones()
-       debug('Done.')
-       sys.exit(0)
+    debug('Updating cached remote')
+    Wp.updateCachedClones()
+    debug('Done.')
+    debug('')
 
 # Updating instances
 names = args.names
 if args.all:
-       names = Wp.list()
+    names = Wp.list()
 elif args.integration or args.stable:
-       names = Wp.list(integration = args.integration, stable = args.stable)
+    names = Wp.list(integrationc=args.integration, stablec=args.stable)
 
 Mlist = Wp.resolveMultiple(names)
 if len(Mlist) < 1:
@@ -63,27 +63,27 @@ if len(Mlist) < 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:
-               if args.upgrade:
-                       try:
-                               M.upgrade()
-                       except Exception as e:
-                               errors.append(M)
-                               debug('Error during the upgrade of %s' % M.get('identifier'))
-                               pass
-       debug('')
+    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:
+        if args.upgrade:
+            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)
+    debug('')
+    debug('/!\ Some errors occurred on the following instances:')
+    for M in errors:
+        debug('- %s' % M.get('identifier'))
+    sys.exit(1)