]> scripts.mit.edu Git - wizard.git/commitdiff
Preliminary prototype of research.
authorEdward Z. Yang <ezyang@mit.edu>
Fri, 21 Aug 2009 06:30:35 +0000 (02:30 -0400)
committerEdward Z. Yang <ezyang@mit.edu>
Fri, 21 Aug 2009 06:30:35 +0000 (02:30 -0400)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
bin/wizard
wizard/command/research.py [new file with mode: 0644]

index 51cfaa0e71c2f18f00f73a3bca1b227528d8a413..85ac65d00f928a13374269d19986b498cc86c2a8 100755 (executable)
@@ -22,6 +22,7 @@ Its commands are:
     mass-migrate    Performs mass migration of autoinstalls of an application
     migrate         Migrate autoinstalls from old format to Git-based format
     prepare-config  Prepares configuration files for versioning
+    research        Print statistics about a possible upgrade
     summary         Generate statistics (see help for subcommands)
     upgrade         Upgrades an autoinstall to the latest version
 
diff --git a/wizard/command/research.py b/wizard/command/research.py
new file mode 100644 (file)
index 0000000..53f3d4a
--- /dev/null
@@ -0,0 +1,35 @@
+import logging
+import traceback
+import os.path
+
+from wizard import command, deploy, shell, util
+
+def main(argv, baton):
+    options, show = parse_args(argv, baton)
+    sh = shell.Shell()
+    for d in deploy.parse_install_lines(show, options.versions_path):
+        try:
+            d.verify()
+            d.verifyTag(options.srv_path)
+            d.verifyGit(options.srv_path)
+            d.verifyConfigured()
+            print d.location
+            with util.ChangeDirectory(d.location):
+                print sh.safeCall('git', 'diff', '--stat', d.app_version.scripts_tag, 'HEAD', strip=True)
+        except deploy.Error as e:
+            continue
+
+def parse_args(argv, baton):
+    usage = """usage: %prog research APP
+
+Tells you how spectacularly an upgrade here will explode."""
+    parser = command.WizardOptionParser(usage)
+    baton.push(parser, "srv_path")
+    baton.push(parser, "versions_path")
+    options, args = parser.parse_all(argv)
+    if len(args) > 1:
+        parser.error("too many arguments")
+    if not args:
+        parser.error("must specify application to research")
+    return options, args
+