]> scripts.mit.edu Git - wizard.git/commitdiff
More reorganization; make massmigrate catch all Wizard errors.
authorEdward Z. Yang <ezyang@mit.edu>
Sat, 27 Jun 2009 00:43:52 +0000 (20:43 -0400)
committerEdward Z. Yang <ezyang@mit.edu>
Sat, 27 Jun 2009 00:43:52 +0000 (20:43 -0400)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
TODO
bin/wizard
lib/wizard/command/__init__.py
lib/wizard/command/info.py
lib/wizard/command/massmigrate.py
lib/wizard/command/migrate.py
lib/wizard/command/summary.py
lib/wizard/deploy.py

diff --git a/TODO b/TODO
index 6728ac69a04a9e186ed548681f85e34fba39d10f..cde3b8bcb12bde29be3adaf176e18c8eb35b8ee8 100644 (file)
--- a/TODO
+++ b/TODO
@@ -14,6 +14,8 @@ TODO NOW:
     - Checks should also be performed against the partition
     X with the new --shared flag this may not be necessary
       as repos weighs less than 200K
+- Should write to a "processed" file to make resuming with
+  unexpected failure faster.
 - Check how many autoinstalls are missing w bits for
   daemon.scripts
 - Whiteboard the flow for performing an upgrade on a single
index df9b8aeca5689ce4f8b913081e70cc13cf20e7ad..8b1597ffc272122b6843fc061f3dd36e0ec607e3 100755 (executable)
@@ -41,7 +41,7 @@ See '%prog help COMMAND' for more information on a specific command."""
     command = args[0] # shouldn't fail
     if command == "help":
         try:
-            getattr(wizard.command, rest_argv[0])(['-h'], options)
+            getattr(wizard.command, rest_argv[0]).main(['-h'], options)
         except AttributeError:
             parser.error("invalid action")
         except IndexError:
@@ -49,10 +49,10 @@ See '%prog help COMMAND' for more information on a specific command."""
             raise SystemExit(-1)
     # Dispatch commands
     try:
-        command_fn = getattr(wizard.command, command)
+        command_module = getattr(wizard.command, command)
     except AttributeError:
         parser.error("invalid action")
-    command_fn(rest_argv, options)
+    command_module.main(rest_argv, options)
 
 if __name__ == "__main__":
     main()
index f675b96a9bdffa1399df424bc74965f87a311eb9..3b7c21db0892f059e41cc15ba232f51cdf145730 100644 (file)
@@ -1,5 +1,4 @@
-from info import info
-from migrate import migrate
-from summary import summary
-from massmigrate import massmigrate
-
+import migrate
+import massmigrate
+import info
+import summary
index 14c04c299dd810acaecea0bad8ff15b67d9b3765..c5c335ce0bbdae74a4b60a2bcf32b20ac4995505 100644 (file)
@@ -11,7 +11,7 @@ def indent(text, indent):
     # There should be a built-in
     return "\n".join([" " * indent + x for x in text.split("\n")])
 
-def info(argv, global_options):
+def main(argv, global_options):
     usage = """usage: %prog info [ARGS] DIR
 
 Prints information about an autoinstalled directory,
index c183e46c9f63298780f43d852280d9e9faabdf39..a796df24988f8cc41a84a2323ab7fbe84653d79d 100644 (file)
@@ -1,10 +1,11 @@
 import optparse
 
+import wizard
 from wizard import deploy
 from wizard.command import _base
 from wizard.command import migrate
 
-def massmigrate(argv, global_options, logger = None):
+def main(argv, global_options, logger = None):
     usage = """usage: %prog massmigrate [ARGS] APPLICATION
 
 Mass migrates an application to the new repository format.
@@ -45,13 +46,14 @@ output going to stdout/stderr."""
         sub_argv = base_args + [d.location]
         logger.info("$ wizard migrate " + " ".join(sub_argv))
         try:
-            migrate.migrate(sub_argv, global_options, logger)
+            migrate.main(sub_argv, global_options, logger)
         except migrate.AlreadyMigratedError as e:
             logger.info("Skipped already migrated %s" % d.location)
-        except migrate.Error as e:
-            name = e.__class__.__name__
+        except wizard.Error as e:
+            name = e.__module__ + "." + e.__class__.__name__
             if name not in errors: errors[name] = []
-            errors[name].append(d)
+            errors[name].append((d, e))
             logger.error("ERROR [%s] in %s" % (name, d.location))
+            logger.info("Backtrace:\n" + str(e))
     for name, deploys in errors.items():
         logger.warning("ERROR [%s] from %d installs" % (name, len(deploys)))
index 12f0da6016035f51fb2feafe546036c984234137..f9bc487be7b6aad35e0ce6e8048b44386ece721d 100644 (file)
@@ -80,7 +80,7 @@ for %s.  Double check and make sure
 the repository was prepared with all necessary tags!
 """ % (self.version.version, self.version.application.name)
 
-def migrate(argv, global_options, logger = None):
+def main(argv, global_options, logger = None):
     usage = """usage: %prog migrate [ARGS] DIR
 
 Migrates a directory to our Git-based autoinstall format.
index 6f254010b55b4bf13eae4bfd8c11913bbc74c511..11fc5818126d02c80973254b8968a4cb230d2c45 100644 (file)
@@ -36,7 +36,7 @@ class Printer(object):
             self._hang()
             print str
 
-def summary(argv, global_options):
+def main(argv, global_options):
     usage = """usage: %prog summary [ARGS] APPS
 
 Scans all of the collected data from parallel-find.pl, and
index 8299e17841999148deec4420216dfd132a666ab6..2b87294ef33ab77e4259613fa5a2cc41f276564b 100644 (file)
@@ -4,22 +4,32 @@ import fileinput
 import dateutil.parser
 import distutils.version
 
-def getInstallLines(global_options):
-    """Retrieves a list of lines from the version directory that
-    can be passed to Deployment.parse()"""
-    vd = global_options.version_dir
-    try:
-        return fileinput.input([vd + "/" + f for f in os.listdir(vd)])
-    except OSError:
-        print "No permissions; check if AFS is mounted"
-        raise SystemExit(-1)
+import wizard
 
-class NoSuchApplication(Exception):
+class Error(wizard.Error):
+    """Base error class for deploy errors"""
     pass
 
-class DeploymentParseError(Exception):
+class NoSuchApplication(Error):
     pass
 
+class DeploymentParseError(Error):
+    pass
+
+class ScriptsVersionTooManyFieldsError(Error):
+    def __str__(self):
+        return """
+
+ERROR: Could not parse .scripts-version file.  It
+contained too many fields.
+"""
+
+def getInstallLines(global_options):
+    """Retrieves a list of lines from the version directory that
+    can be passed to Deployment.parse()"""
+    vd = global_options.version_dir
+    return fileinput.input([vd + "/" + f for f in os.listdir(vd)])
+
 class Deployment(object):
     """Represents a deployment of an autoinstall; i.e. a concrete
     directory in web_scripts that has .scripts-version in it."""
@@ -130,7 +140,7 @@ class DeployLog(list):
                 rev.version = ApplicationVersion.parse(line)
             else:
                 # ruh oh
-                raise NotImplementedError
+                raise ScriptsVersionTooManyFieldsError()
             i += 1
         if i: revs.append(rev)
         return DeployLog(revs)