]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/command/mass_migrate.py
Fix bug where php.ini not being rewritten for MediaWiki.
[wizard.git] / wizard / command / mass_migrate.py
index fbaaa60217fd0b763fc1fe2a2cce6ddf6b9df05c..c4f4389eca5c9551f47ef2b7c56cc04e2f30de91 100644 (file)
@@ -3,7 +3,7 @@ import os
 import os.path
 import itertools
 
-from wizard import deploy, shell, sset, command
+from wizard import deploy, report, shell, sset, command
 
 def main(argv, baton):
     options, args = parse_args(argv, baton)
@@ -13,11 +13,11 @@ def main(argv, baton):
     command.create_logdir(options.log_dir)
     seen = sset.make(options.seen)
     is_root = not os.getuid()
-    report = command.open_reports(options.log_dir)
+    runtime = report.make_fresh(options.log_dir, "success", "warnings", "errors")
     # loop stuff
     errors = {}
     i = 0
-    deploys = deploy.parse_install_lines(app, options.versions_path)
+    deploys = deploy.parse_install_lines(app, options.versions_path, user=options.user)
     requested_deploys = itertools.islice(deploys, options.limit)
     for i, d in enumerate(requested_deploys, 1):
         # check if we want to punt due to --limit
@@ -36,20 +36,17 @@ def main(argv, baton):
             # we need to make another stack frame so that d and i get specific bindings.
             def on_success(stdout, stderr):
                 if stderr:
-                    report.warnings.write("%s\n" % d.location) # pylint: disable-msg=E1101
                     logging.warning("Warnings [%04d] %s:\n%s" % (i, d.location, stderr))
-                seen.add(d.location)
+                    runtime.write("warnings", i, d.location)
+                runtime.write("success", i, d.location)
             def on_error(e):
                 if e.name == "wizard.command.migrate.AlreadyMigratedError" or \
                    e.name == "AlreadyMigratedError":
-                    seen.add(d.location)
                     logging.info("Skipped already migrated %s" % d.location)
                 else:
-                    name = e.name
-                    if name not in errors: errors[name] = []
-                    errors[name].append(d)
-                    logging.error("%s in [%04d] %s" % (name, i, d.location))
-                    report.errors.write("%s\n" % d.location) # pylint: disable-msg=E1101
+                    errors.setdefault(e.name, []).append(d)
+                    logging.error("%s in [%04d] %s", e.name, i, d.location)
+                    runtime.write("errors", i, d.location)
             return (on_success, on_error)
         on_success, on_error = make_on_pair(d, i)
         sh.call("wizard", "migrate", d.location, *child_args,
@@ -75,10 +72,11 @@ the scripts AFS patch."""
     baton.push(parser, "dry_run")
     baton.push(parser, "max_processes")
     parser.add_option("--force", dest="force", action="store_true",
-            default=False, help="Force migrations to occur even if .scripts or .git exists.")
+            default=False, help="Force migrations to occur even if .wizard or .git exists.")
     baton.push(parser ,"limit")
     baton.push(parser, "versions_path")
     baton.push(parser, "srv_path")
+    baton.push(parser, "user")
     options, args, = parser.parse_all(argv)
     if len(args) > 1:
         parser.error("too many arguments")