]> scripts.mit.edu Git - wizard.git/commitdiff
Move a number of common parameters to the baton.
authorEdward Z. Yang <ezyang@mit.edu>
Mon, 24 Aug 2009 02:46:14 +0000 (22:46 -0400)
committerEdward Z. Yang <ezyang@mit.edu>
Mon, 24 Aug 2009 02:46:14 +0000 (22:46 -0400)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
bin/wizard
wizard/command/mass_migrate.py

index aad6c9258a5050ecbf67f747c97331076a74ab7f..dad334e1cf3257e5d0e0390141a015bb7cef0b55 100755 (executable)
@@ -33,12 +33,24 @@ See '%prog help COMMAND' for more information on a specific command."""
     _, args = parser.parse_args() # no global options
     rest_argv = args[1:]
     baton = command.OptionBaton()
-    baton.add("--versions-path", dest="versions_path",
+    baton.add("--versions-path", dest="versions_path", metavar="PATH",
         default=getenvpath("WIZARD_VERSIONS_PATH") or "/afs/athena.mit.edu/contrib/scripts/sec-tools/store/versions",
         help="Location of parallel-find output directory, or a file containing a newline separated list of 'all autoinstalls' (for development work).  Environment variable is WIZARD_VERSIONS_PATH.")
-    baton.add("--srv-path", dest="srv_path",
+    baton.add("--srv-path", dest="srv_path", metavar="PATH",
         default=getenvpath("WIZARD_SRV_PATH") or "/afs/athena.mit.edu/contrib/scripts/git/autoinstalls",
         help="Location of autoinstall Git repositories, such that $REPO_PATH/$APP.git is a repository (for development work).  Environment variable is WIZARD_SRV_PATH.")
+    baton.add("--dry-run", dest="dry_run", action="store_true",
+            default=False, help="Print the results of the operation without actually executing them")
+    # common variables for mass commands
+    baton.add("--seen", dest="seen",
+            default=None, help="File to read/write paths of already processed installs."
+            "These will be skipped.")
+    baton.add("--no-parallelize", dest="no_parallelize", action="store_true",
+            default=False, help="Turn off parallelization")
+    baton.add("--max-processes", dest="max_processes", type="int", metavar="N",
+            default=10, help="Maximum subprocesses to run concurrently")
+    baton.add("--limit", dest="limit", type="int",
+            default=None, help="Limit the number of autoinstalls to look at.")
     try:
         command_name = args[0]
     except IndexError:
index 00dd006f81cd1db21b289bbb2d9629392ce57d07..b72bfd4d1f3afe9dfcc38bc44cc048d940bb19c0 100644 (file)
@@ -15,7 +15,7 @@ def main(argv, baton):
     options, args = parse_args(argv, baton)
     app = args[0]
     base_args = calculate_base_args(options)
-    sh = shell.ParallelShell.make(options.no_parallelize, options.max)
+    sh = shell.ParallelShell.make(options.no_parallelize, options.max_processes)
     seen = sset.make(options.seen)
     is_root = not os.getuid()
     warnings_log, errors_log = command.open_logs(options.log_dir)
@@ -82,19 +82,13 @@ user for testing purposes, but then you MUST NOT run this on
 untrusted repositories."""
     parser = command.WizardOptionParser(usage)
     baton.push(parser, "log_dir")
-    parser.add_option("--seen", dest="seen",
-            default=None, help="File to read/write paths of already processed installs."
-            "These will be skipped.")
-    parser.add_option("--no-parallelize", dest="no_parallelize", action="store_true",
-            default=False, help="Turn off parallelization")
-    parser.add_option("--dry-run", dest="dry_run", action="store_true",
-            default=False, help="Print commands that would be run. Implies --no-parallelize")
-    parser.add_option("--max", dest="max", type="int",
-            default=10, help="Maximum subprocesses to run concurrently")
+    baton.push(parser, "seen")
+    baton.push(parser, "no_parallelize")
+    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.")
-    parser.add_option("--limit", dest="limit", type="int",
-            default=None, help="Limit the number of autoinstalls to look at.")
+    baton.push(parser ,"limit")
     baton.push(parser, "versions_path")
     baton.push(parser, "srv_path")
     options, args, = parser.parse_all(argv)