]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/command/upgrade.py
Revamp database infrastructure.
[wizard.git] / wizard / command / upgrade.py
index 4c2632df64c43c94ba3c447d2942c29b927aa277..476c1b78ca3890be9715227ac3bb382dff42adfb 100644 (file)
@@ -1,16 +1,15 @@
-import optparse
 import sys
 import distutils.version
 import os
 import shutil
 import logging.handlers
-import errno
 import tempfile
 import itertools
 
 from wizard import app, command, deploy, scripts, shell, util
 
 kib_buffer = 1024 * 30 # 30 MiB we will always leave available
+errno_blacklisted = 64
 
 def main(argv, baton):
     options, args = parse_args(argv, baton)
@@ -47,8 +46,12 @@ def main(argv, baton):
             d = deploy.ProductionCopy(".")
             if os.path.exists(".scripts/blacklisted"):
                 reason = open(".scripts/blacklisted").read()
-                print "-1 " + reason
-                raise BlacklistedError(reason)
+                # ignore blank blacklisted files
+                if reason:
+                    print reason
+                    raise BlacklistedError(reason)
+                else:
+                    logging.warning("Application was blacklisted, but no reason was found");
             d.verify()
             d.verifyTag(options.srv_path)
             d.verifyGit(options.srv_path)
@@ -89,7 +92,7 @@ def main(argv, baton):
                 open(".git/WIZARD_SIZE", "w").write(str(scripts.get_disk_usage()))
                 if options.log_file:
                     open(".git/WIZARD_LOG_FILE", "w").write(options.log_file)
-                perform_merge(sh, repo, wc, version, use_shm, kib_limit and kib_limit - kib_usage or None)
+                perform_merge(sh, repo, d, wc, version, use_shm, kib_limit and kib_limit - kib_usage or None)
         # variables: version, user_commit, next_commit, temp_wc_dir
         with util.ChangeDirectory(temp_wc_dir):
             try:
@@ -142,7 +145,7 @@ def main(argv, baton):
                 except deploy.WebVerificationError as e:
                     logging.warning("Web verification failed: rolling back")
                     perform_restore(d, backup)
-                    raise app.UpgradeVerificationFailure(e.contents)
+                    raise app.UpgradeVerificationFailure()
         # XXX: frob .htaccess to make site accessible
         #       to do this, check if .htaccess changed, first.  Upgrade
         #       process might have frobbed it.  Don't be
@@ -202,7 +205,7 @@ def perform_tmp_clone(sh, use_shm):
     sh.call("git", "clone", "-q", "--shared", ".", temp_wc_dir)
     return temp_dir, temp_wc_dir
 
-def perform_merge(sh, repo, wc, version, use_shm, kib_avail):
+def perform_merge(sh, repo, d, wc, version, use_shm, kib_avail):
     # Note: avail_quota == None means unlimited
     # naive merge algorithm:
     # sh.call("git", "merge", "-m", message, "scripts/master")
@@ -210,7 +213,7 @@ def perform_merge(sh, repo, wc, version, use_shm, kib_avail):
     def make_virtual_commit(tag, parents = []):
         """WARNING: Changes state of Git repository"""
         sh.call("git", "checkout", "-q", tag, "--")
-        wc.parametrize()
+        wc.parametrize(d)
         for file in wc.application.parametrized_files:
             try:
                 sh.call("git", "add", "--", file)
@@ -229,7 +232,10 @@ def perform_merge(sh, repo, wc, version, use_shm, kib_avail):
             "-p", base_virtual_commit, input="", log=True)
     sh.call("git", "checkout", user_virtual_commit, "--")
     wc.prepareMerge()
-    sh.call("git", "commit", "--amend", "-a", "-m", "amendment")
+    try:
+        sh.call("git", "commit", "--amend", "-a", "-m", "amendment")
+    except shell.CallError as e:
+        pass
     try:
         sh.call("git", "merge", next_virtual_commit)
     except shell.CallError as e:
@@ -324,6 +330,7 @@ this actually works)."""
 class BlacklistedError(Error):
     #: Reason why the autoinstall was blacklisted
     reason = None
+    exitcode = errno_blacklisted
     def __init__(self, reason):
         self.reason = reason
     def __str__(self):