]> scripts.mit.edu Git - wizard.git/commitdiff
Make some exceptions quiet.
authorEdward Z. Yang <ezyang@mit.edu>
Tue, 22 Dec 2009 18:54:58 +0000 (13:54 -0500)
committerEdward Z. Yang <ezyang@mit.edu>
Tue, 22 Dec 2009 18:54:58 +0000 (13:54 -0500)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
TODO
bin/wizard
wizard/__init__.py
wizard/command/__init__.py
wizard/command/migrate.py
wizard/command/upgrade.py

diff --git a/TODO b/TODO
index 839d96b0c6ae5851df028e25792e4eacbb21aa92..5845f56495e83c4a7c144fe7f4ddc4111d2b4809 100644 (file)
--- a/TODO
+++ b/TODO
@@ -4,6 +4,9 @@ TODO NOW:
 
 - If you try to do an install on scripts w/o sql, it will sign you up but fail to write
   the sql.cnf file. This sucks.
+- Make an awesome wizard subcommand that you can point at a file that is DOS
+  when the source wants it to be UNIX, or the other way around, and it will
+  redo the merge on that file correctly.
 
 - wizard install wordpress should ask for password.  One problem with this is that
   Wordpress will still send mail with the wrong username and password, so Wordpress
index a4da6a8a618cc10c68f3f43eb56d644361c8f828..55730a73c22709d5695ea4514de042f8b958c1f1 100755 (executable)
@@ -95,12 +95,18 @@ See '%prog help COMMAND' for more information on a specific command."""
         # log the exception
         msg = traceback.format_exc()
         if command.logging_setup:
-            logging.error(msg)
+            outfun = logging.error
         else:
-            sys.stderr.write(msg)
+            outfun = sys.stderr.write
         if isinstance(e, wizard.Error):
+            if e.quiet and not command.debug:
+                msg = str(e)
+                if command.logging_setup:
+                    msg = msg.replace("ERROR: ", "")
+            outfun(msg)
             sys.exit(e.exitcode)
         else:
+            outfun(msg)
             sys.exit(1)
 
 def get_command(name):
index ffe308f5945de9ad2c7c40ab5484b15f0e7f161e..647d77b98077538c1045cd278b58f50627741937 100644 (file)
@@ -2,4 +2,6 @@ class Error(Exception):
     """Base exception for all Wizard exceptions"""
     #: Code to exit the application with.
     exitcode = 1
+    #: Whether or not to suppress the backtrace (unless in debug mode)
+    quiet = False
 
index 4362e2f179abc93e43dedd8e22d27ef59fc09f25..e23603e146b9cbfb177ab50e5aaadae75809aeaa 100644 (file)
@@ -12,6 +12,7 @@ import wizard
 from wizard import util
 
 logging_setup = False
+debug = True # This will get overwritten with the real value early on
 
 def boolish(val):
     """
@@ -229,6 +230,7 @@ class WizardOptionParser(optparse.OptionParser):
         self.add_option_group(group)
         options, numeric_args = self.parse_args(*args, **kwargs)
         setup_logger(options, numeric_args)
+        debug = options.debug
         # we're going to process the global --log-dir/--seen dependency here
         if hasattr(options, "seen") and hasattr(options, "log_dir"):
             if not options.seen and options.log_dir:
index 25845a88b20284bc975bdd556bae6256185157f4..7af52a8e6c1251f4bcb70db5b604791623736e64 100644 (file)
@@ -148,6 +148,7 @@ class Error(command.Error):
     pass
 
 class AlreadyMigratedError(Error):
+    quiet = True
     def __init__(self, dir):
         self.dir = dir
     def __str__(self):
index 476c1b78ca3890be9715227ac3bb382dff42adfb..2a0e6067c594a83709a5851741066ec401f1d0bc 100644 (file)
@@ -303,16 +303,19 @@ upgrade.
 """
 
 class AlreadyUpgraded(Error):
+    quiet = True
     def __str__(self):
         return """
 
 ERROR: This autoinstall is already at the latest version."""
 
 class MergeFailed(Error):
+    quiet = True
     def __str__(self):
         return """
 
-ERROR: Merge failed.  Resolve the merge by cd'ing to the
+ERROR: Merge failed.  Above is the temporary directory that
+the conflicted merge is in: resolve the merge by cd'ing to the
 temporary directory, finding conflicted files with `git status`,
 resolving the files, adding them using `git add` and then
 running `wizard upgrade --continue`."""