]> scripts.mit.edu Git - wizard.git/commitdiff
Describe how to delete a blacklist entry.
authorEdward Z. Yang <ezyang@mit.edu>
Sun, 14 Nov 2010 16:21:17 +0000 (16:21 +0000)
committerEdward Z. Yang <ezyang@mit.edu>
Sun, 14 Nov 2010 16:21:17 +0000 (16:21 +0000)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
TODO
wizard/command/blacklist.py
wizard/command/upgrade.py

diff --git a/TODO b/TODO
index 3a1eea9a17a41646ea48cc4f10922a31cd0c11c1..5f4fd90d4b3fbfe0d4f7cff14bb2f842cac2430f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -18,8 +18,6 @@
   restore)
 - Show progress or something when upgrading
 - Allow 'sticky notes' for future upgraders to notice
-- Blacklist should allow an easy way for a user to override it,
-  described in the error message.
 - .wizard/url semantics are subtly wrong: in particular, if we
   explicitly configure a URL at install, we should be able to
   detect this URL as baked in from the configuration
index e90fa36e15e7002a34477b6499664abcb100c8f4..1d56def8a542e0aebe9daff4bc217608ecd533b6 100644 (file)
@@ -1,28 +1,46 @@
 import os
+import errno
+import logging
 
 from wizard import command, deploy, shell, util
 
 def main(argv, baton):
     options, args = parse_args(argv, baton)
-    reason = args[0]
     # Directory information not transferred via command line, so this
     # will not error due to the changed directory.
     shell.drop_priviledges(".", options.log_file)
     util.chdir_to_production()
     production = deploy.ProductionCopy(".")
     production.verify()
-    open(production.blacklisted_file, 'w').write(reason + "\n")
+    if options.delete:
+        try:
+            os.unlink(production.blacklisted_file)
+        except OSError as e:
+            if e.errno == errno.ENOENT:
+                logging.warning("No-op: application was not blacklisted")
+            else:
+                raise
+    else:
+        open(production.blacklisted_file, 'w').write(args[0] + "\n")
 
 def parse_args(argv, baton):
     usage = """usage: %prog blacklist [ARGS] REASON
+       %prog blacklist --delete
 
 Adds the file .wizard/blacklisted so that future upgrades
-are not attempted without manual intervention."""
+are not attempted without manual intervention.  If run
+with the flag --delete, it deletes the blacklist file."""
     parser = command.WizardOptionParser(usage)
+    parser.add_option("--delete", dest="delete", action="store_true",
+            default=False, help="Delete the blacklist entry, enabling normal usage.")
     options, args = parser.parse_all(argv)
-    if len(args) > 2:
-        parser.error("too many arguments")
-    if len(args) < 1:
-        parser.error("must specify reason")
+    if options.delete:
+        if len(args) > 1:
+            parser.error("too many arguments")
+    else:
+        if len(args) > 2:
+            parser.error("too many arguments")
+        if len(args) < 1:
+            parser.error("must specify reason")
     return options, args
 
index e31e7b935b9402ef51c01a673cc0b39171154b12..bea7108a5f4828adab6ddb0809335d0ec70fa1ec 100644 (file)
@@ -543,7 +543,10 @@ class BlacklistedError(Error):
 
 ERROR: This autoinstall was manually blacklisted against errors;
 if the user has not been notified of this, please send them
-mail.
+mail.  If you know that this application is blacklisted and
+would like to attempt an upgrade anyway, run:
+
+    wizard blacklist --delete
 
 The reason was: %s""" % self.reason