]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/command/restore.py
Convert ad hoc shell calls to singleton instance; fix upgrade bug.
[wizard.git] / wizard / command / restore.py
index c5d73c98b2844ff33d72c55585849b54ab10e2dd..eae157f3b63beebc9444c8195c7abdd4a39f1594 100644 (file)
@@ -1,10 +1,8 @@
 import logging
 import os
-import optparse
 import sys
-import distutils.version
 
-from wizard import command, deploy, git, shell, util
+from wizard import command, deploy, shell
 
 def main(argv, baton):
     options, args = parse_args(argv, baton)
@@ -29,22 +27,22 @@ def main(argv, baton):
     if backup == "top":
         try:
             backup = sorted(os.listdir(backups))[-1]
+            logging.warning("Using backup %s" % backup)
         except IndexError:
             raise Exception("No restore points available")
     bits = backup.split('-')
     date = '-'.join(bits[-3:])
     version = '-'.join(bits[0:-3])
     shell.drop_priviledges(".", options.log_file)
-    d = deploy.Deployment(".")
+    d = deploy.ProductionCopy(".")
     d.verify()
     d.verifyConfigured()
     tag = "%s-%s" % (d.application.name, version)
-    sh = shell.Shell()
     try:
-        sh.call("git", "rev-parse", tag)
+        shell.call("git", "rev-parse", tag)
     except shell.CallError:
         raise Exception("Tag %s doesn't exist in repository" % tag)
-    sh.call("git", "reset", "--hard", tag)
+    shell.call("git", "reset", "-q", "--hard", tag)
     d.restore(backup, options)
 
 def parse_args(argv, baton):