import sys
import argparse
-from lib import workplace, moodle, tools
+from lib import workplace
from lib.tools import debug
from lib.config import Conf
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:
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)