]> scripts.mit.edu Git - wizard.git/commitdiff
Automatically perform logging during --continue.
authorEdward Z. Yang <ezyang@mit.edu>
Sun, 11 Oct 2009 22:49:07 +0000 (18:49 -0400)
committerEdward Z. Yang <ezyang@mit.edu>
Sun, 11 Oct 2009 22:49:07 +0000 (18:49 -0400)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
TODO
tests/test-continue-upgrade-mediawiki.sh
wizard/command/__init__.py
wizard/command/upgrade.py

diff --git a/TODO b/TODO
index a4c4e142678cca157322fbb70d4d76d3e7e7ef1f..8580d3e056a3beeb68de5366ee4c4c95cbb4dcb8 100644 (file)
--- a/TODO
+++ b/TODO
@@ -20,9 +20,6 @@ TODO NOW:
   to users)
     - Figure out a way of collecting blacklist data from .scripts/blacklisted
       and aggregate it together
-    - Failed migrations should be wired to have wizard commands in them
-      automatically log to the relevant file.  In addition, the seen file
-      should get updated when one of them gets fixed.
 
 - Let users use Wizard when ssh'ed into Scripts
     - Make single user mass-migrate work when not logged in as root
index e03e1572e6716f8580e546ff0db85a0732a12601..0c5493ad400da52018ab071b15af8caf2f495a19 100755 (executable)
@@ -11,7 +11,7 @@ mv "$TESTDIR/$FROB" "$TESTDIR/$FROB.bak"
 echo "this is a bad file" > "$TESTDIR/$FROB"
 
 # attempt an upgrade, this will fail
-RESULT=`! wizard upgrade "$TESTDIR"`
+RESULT=`! wizard upgrade "$TESTDIR" --log-file=/tmp/testboo`
 TMPTESTDIR=`echo "$RESULT" | awk '{print $2}'`
 
 # resolve the upgrade
index c03cfdac723577d0ecb731eddc3899a16c365b7f..a3c06c29f067d936e1bb0b76a641e1419508a35a 100644 (file)
@@ -41,19 +41,13 @@ def makeLogger(options, numeric_args):
     stderr.setFormatter(logging.Formatter('%(levelname)s: %(message)s'))
     if not options.quiet: logger.addHandler(stderr)
     else: logger.addHandler(NullLogHandler()) # prevent default
-    if options.log_file:
-        file = logging.FileHandler(options.log_file)
-        logformatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s", "%Y-%m-%d %H:%M")
-        file.setFormatter(logformatter)
-        logger.addHandler(file)
+    if options.log_file: addFileLogger(options.log_file, options.debug)
     if options.debug:
         logger.setLevel(logging.DEBUG)
     else:
         stderr.setLevel(logging.WARNING)
         if options.verbose:
             stderr.setLevel(logging.INFO)
-        if options.log_file:
-            file.setLevel(logging.INFO)
     def our_excepthook(type, value, tb):
         logging.error("".join(traceback.format_exception(type,value,tb)))
         sys.exit(1)
@@ -61,6 +55,16 @@ def makeLogger(options, numeric_args):
     logging_setup = True
     return logger
 
+def addFileLogger(log_file, debug):
+    logger = logging.getLogger()
+    file = logging.FileHandler(log_file)
+    logformatter = logging.Formatter("%(asctime)s %(levelname)s: %(message)s", "%Y-%m-%d %H:%M")
+    file.setFormatter(logformatter)
+    logger.addHandler(file)
+    if not debug:
+        file.setLevel(logging.INFO)
+    return file
+
 def makeBaseArgs(options, **grab):
     """Takes parsed options, and breaks them back into a command
     line string that we can pass into a subcommand"""
index 94af4f674d876d4e5818729483d2d53d5b3af536..18e7f9efe837d3d7990015fc7c2e8714bd858cc9 100644 (file)
@@ -28,6 +28,11 @@ def main(argv, baton):
         user_commit, next_commit = open(".git/WIZARD_PARENTS", "r").read().split()
         repo = open(".git/WIZARD_REPO", "r").read()
         version = open(".git/WIZARD_UPGRADE_VERSION", "r").read()
+        if not options.log_file and os.path.exists(".git/WIZARD_LOG_FILE"):
+            options.log_file = open(".git/WIZARD_LOG_FILE", "r").read()
+            # reload logging
+            command.addFileLogger(options.log_file, options.debug)
+        logging.info("Continuing upgrade...")
         util.chdir(sh.eval("git", "config", "remote.origin.url"))
         d = deploy.Deployment(".")
         try:
@@ -74,6 +79,7 @@ def main(argv, baton):
             open(".git/WIZARD_REPO", "w").write(repo)
             open(".git/WIZARD_UPGRADE_VERSION", "w").write(version)
             open(".git/WIZARD_PARENTS", "w").write("%s\n%s" % (user_commit, next_commit))
+            if options.log_file: open(".git/WIZARD_LOG_FILE", "w").write(options.log_file)
             perform_merge(sh, repo, d, version, use_shm)
     # variables: version, user_commit, next_commit, temp_wc_dir
     with util.ChangeDirectory(temp_wc_dir):