]> scripts.mit.edu Git - wizard.git/blobdiff - bin/wizard
Remove unnecessary commands, add help to install.
[wizard.git] / bin / wizard
index e00eb8ff8fbf367e526c623851dd6cf0f56c6dc4..a4da6a8a618cc10c68f3f43eb56d644361c8f828 100755 (executable)
@@ -3,11 +3,16 @@
 import os
 import optparse
 import sys
+import logging
+import traceback
+
+# import some non-standard modules to make it fail out early
+import decorator
 
 sys.path.insert(0,os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
 
 import wizard
-from wizard import command
+from wizard import command, prompt
 
 def main():
     usage = """usage: %prog COMMAND [ARGS]
@@ -22,6 +27,7 @@ User commands:
     upgrade         Upgrades an autoinstall to the latest version
 
 Administrative commands:
+    blacklist       Marks an autoinstall to not try upgrades
     errors          Lists all broken autoinstall metadata
     list            Lists autoinstalls, with optional filtering
     mass-migrate    Performs mass migration of autoinstalls of an application
@@ -30,7 +36,8 @@ Administrative commands:
     summary         Generate statistics (see help for subcommands)
 
 Utility commands:
-    configure       Configures an autoinstall (database, etc) to work
+    prepare-pristine    Downloads and extracts pristine upstream files
+    prepare-new     Prepares a new repository
     prepare-config  Prepares configuration files for versioning
 
 See '%prog help COMMAND' for more information on a specific command."""
@@ -50,12 +57,12 @@ See '%prog help COMMAND' for more information on a specific command."""
             default=False, help="Performs the operation without actually modifying any files.  Use in combination with --verbose to see commands that will be run.")
     # 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.")
+            default=None, help="File to read/write paths of successfully modified installs;"
+            "these will be skipped on re-runs.  If --log-dir is specified, this is automatically enabled.")
     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=40, help="Maximum subprocesses to run concurrently")
+            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.")
     baton.add("--user", "-u", dest="user",
@@ -64,7 +71,7 @@ See '%prog help COMMAND' for more information on a specific command."""
         command_name = args[0]
     except IndexError:
         parser.print_help()
-        raise SystemExit(1)
+        sys.exit(1)
     baton.add("--log-dir", dest="log_dir",
         default=getenvpath("WIZARD_LOG_DIR") or "/tmp/wizard-%s" % command_name,
         help="Log files for Wizard children processes are placed here.")
@@ -75,14 +82,26 @@ See '%prog help COMMAND' for more information on a specific command."""
             parser.error("invalid action")
         except IndexError:
             parser.print_help()
-            raise SystemExit(1)
+            sys.exit(1)
         help_module.main(['--help'], baton)
     # Dispatch commands
+    command_module = get_command(command_name)
     try:
-        command_module = get_command(command_name)
-    except ImportError:
-        parser.error("invalid action")
-    command_module.main(rest_argv, baton)
+        command_module.main(rest_argv, baton)
+    except prompt.UserCancel as e:
+        print str(e)
+        sys.exit(1)
+    except Exception as e:
+        # log the exception
+        msg = traceback.format_exc()
+        if command.logging_setup:
+            logging.error(msg)
+        else:
+            sys.stderr.write(msg)
+        if isinstance(e, wizard.Error):
+            sys.exit(e.exitcode)
+        else:
+            sys.exit(1)
 
 def get_command(name):
     name = name.replace("-", "_")