From ceb253aa60bb222d13324b5ed0eb3f14e877df8b Mon Sep 17 00:00:00 2001 From: Frederic Massart Date: Wed, 20 Nov 2013 11:24:37 +0800 Subject: [PATCH] Add .noupgrade to skip upgrade of an instance --- lib/commands/update.py | 4 ++++ lib/commands/upgrade.py | 5 ++++- lib/exceptions.py | 4 ++++ lib/moodle.py | 4 +++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/commands/update.py b/lib/commands/update.py index 2e44755..7462633 100644 --- a/lib/commands/update.py +++ b/lib/commands/update.py @@ -25,6 +25,7 @@ http://github.com/FMCorz/mdk import sys import logging from lib.command import Command +from lib.exceptions import UpgradeNotAllowed class UpdateCommand(Command): @@ -114,6 +115,9 @@ class UpdateCommand(Command): if args.upgrade: try: M.upgrade() + except UpgradeNotAllowed as e: + logging.info('Skipping upgrade of %s (not allowed)' % (M.get('identifier'))) + logging.debug(e) except Exception as e: errors.append(M) logging.warning('Error during the upgrade of %s' % M.get('identifier')) diff --git a/lib/commands/upgrade.py b/lib/commands/upgrade.py index f3af29d..4684dae 100644 --- a/lib/commands/upgrade.py +++ b/lib/commands/upgrade.py @@ -25,7 +25,7 @@ http://github.com/FMCorz/mdk import sys import logging from lib.command import Command - +from lib.exceptions import UpgradeNotAllowed class UpgradeCommand(Command): @@ -115,6 +115,9 @@ class UpgradeCommand(Command): try: M.upgrade(args.nocheckout) + except UpgradeNotAllowed as e: + logging.info('Skipping upgrade of %s (not allowed)' % (M.get('identifier'))) + logging.debug(e) except Exception as e: errors.append(M) logging.warning('Error during the upgrade of %s' % M.get('identifier')) diff --git a/lib/exceptions.py b/lib/exceptions.py index 997b86b..91cdeaa 100644 --- a/lib/exceptions.py +++ b/lib/exceptions.py @@ -69,3 +69,7 @@ class ScriptNotFound(Exception): class UnsupportedScript(Exception): pass + + +class UpgradeNotAllowed(Exception): + pass diff --git a/lib/moodle.py b/lib/moodle.py index 2d8c8db..30a6bf0 100644 --- a/lib/moodle.py +++ b/lib/moodle.py @@ -31,7 +31,7 @@ from tools import getMDLFromCommitMessage, mkdir, process, parseBranch from db import DB from config import Conf from git import Git, GitException -from exceptions import InstallException +from exceptions import InstallException, UpgradeNotAllowed from jira import Jira from scripts import Scripts @@ -715,6 +715,8 @@ class Moodle(object): raise Exception('Cannot upgrade an instance which is not installed.') elif not self.branch_compare(20): raise Exception('Upgrade command line tool not supported by this version.') + elif os.path.isfile(os.path.join(self.get('path'), '.noupgrade')): + raise UpgradeNotAllowed('Upgrade not allowed, found .noupgrade.') # Checkout stable if not nocheckout: -- 2.11.0