]> scripts.mit.edu Git - wizard.git/commitdiff
Nicer errors if not in autoinstall directory.
authorEdward Z. Yang <ezyang@mit.edu>
Wed, 3 Mar 2010 04:27:30 +0000 (23:27 -0500)
committerEdward Z. Yang <ezyang@mit.edu>
Wed, 3 Mar 2010 04:29:19 +0000 (23:29 -0500)
Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
TODO
wizard/command/blacklist.py
wizard/command/database.py
wizard/command/prepare_new.py
wizard/command/prepare_pristine.py
wizard/command/restore.py
wizard/command/upgrade.py
wizard/deploy.py

diff --git a/TODO b/TODO
index 6750cb80d2643b78f583e1b23635dde43f636a5e..a778057ad6b0f2e9828db51abd74de712ade13e7 100644 (file)
--- a/TODO
+++ b/TODO
@@ -3,7 +3,6 @@ The Git Autoinstaller
 TODO NOW:
 
 - Add support for mypristine workflow
-- Make a nicer backtrace if not in a Git working copy directory
 - Wordpress needs to get rid of the siteurl hack, so that it actually
   has a fully-qualified URL http://foo.scripts.mit.edu/blah.  This will
   also fix Wordpress's cron functionality.  We should be careful not
index f20e43d8b6748460d24368d8d41625d69c8d1089..a5978e53a6e3ffe56ea03769217c0ad1c5693602 100644 (file)
@@ -1,16 +1,18 @@
 import os
 
-from wizard import command, shell, util
+from wizard import command, deploy, shell, util
 
 def main(argv, baton):
     options, args = parse_args(argv, baton)
     reason = args[0]
-    # XXX: this should be abstracted away!
-    if os.path.exists(".git/WIZARD_REPO"):
-        util.chdir(shell.eval('git', 'config', 'remote.origin.url'))
     # Directory information not transferred via command line, so this
     # will not error due to the changed directory.
     shell.drop_priviledges(".", options.log_file)
+    # XXX: this should be abstracted away!
+    if os.path.exists(".git/WIZARD_REPO"):
+        util.chdir(shell.eval('git', 'config', 'remote.origin.url'))
+    production = deploy.ProductionCopy(".")
+    production.verify()
     open('.scripts/blacklisted', 'w').write(reason + "\n")
 
 def parse_args(argv, baton):
index c2a1d4d6f635b1a472f21702c3be7e7f4a83d1c9..5a8dfebc7ddb4fc11435a7a611a0b8cb3115298b 100644 (file)
@@ -7,6 +7,8 @@ def main(argv, baton):
     dir = os.path.abspath(args[0]) if args else os.getcwd()
     shell.drop_priviledges(dir, options.log_file)
     deployment = deploy.ProductionCopy(dir)
+    deployment.verify()
+    deployment.verifyConfigured()
     print deployment.dsn.database
 
 def parse_args(argv, baton):
index 56416022e23c7ac2ff54df835aa7a1842158ee3e..e80790a38e0c94a28926ef5fec4f29c84d8616b3 100644 (file)
@@ -1,9 +1,12 @@
 import os
+import os.path
 
 from wizard import command
 
 def main(argv, baton):
     options, args = parse_args(argv, baton)
+    if not os.path.exists(",git"):
+        raise Exception("Not in root directory of Git working copy")
     os.mkdir(".scripts")
     open(".scripts/.htaccess", "w").write("Deny from all\n")
 
index 729ebb6586f72ce035dd394ce62d28d0f3896e06..b628a42e05c9f9eb4c6c94f63f4584ffb99cec55 100644 (file)
@@ -1,6 +1,7 @@
 import urllib
 import shutil
 import os
+import os.path
 
 from wizard import app, command, shell
 
@@ -56,6 +57,8 @@ local diffs: you can override this safety mechanism with --force.
     return options, args
 
 def check_directory(options):
+    if not os.path.exists(".git"):
+        raise Exception("Not in root directory of Git repository")
     files = shell.eval("git", "ls-files", "-o")
     if files:
         raise Exception("Unversioned files exist, refusing to remove (override with --force)")
index feeb0b017179c763b8dc238fa2ba45457bc5bd3f..4410611766758a1ff8983704a1016617ca105112 100644 (file)
@@ -6,6 +6,8 @@ from wizard import command, deploy, shell
 
 def main(argv, baton):
     options, args = parse_args(argv, baton)
+    d = deploy.ProductionCopy(".")
+    d.verify()
     backups = ".scripts/backups"
     if not args:
         if not os.path.exists(backups):
index e56675bbe6aaf8e74d7452df1c692b9229efc06a..5021915092d564ac71c7ce559d6f680aad4f67af 100644 (file)
@@ -152,11 +152,11 @@ class Upgrade(object):
         options = self.options
         while True:
             self.prod = deploy.ProductionCopy(".")
+            self.prod.verify()
             self.repo = self.prod.application.repository(options.srv_path)
             # XXX: put this in Application
             self.version = shell.eval("git", "--git-dir="+self.repo, "describe", "--tags", "master")
             self.preflightBlacklist()
-            self.prod.verify()
             self.prod.verifyTag(options.srv_path)
             self.prod.verifyGit(options.srv_path)
             self.prod.verifyConfigured()
index 4fdff7d5dde202d63fcfbc4fa769ebd6f4425eb1..5b0e525881bca9c5148950beaacfa4415f2a4ad2 100644 (file)
@@ -143,6 +143,8 @@ class Deployment(object):
             elif not has_git and not has_scripts:
                 if os.path.isfile(".scripts-version"):
                     raise NotMigratedError(self.location)
+                else:
+                    raise NotAutoinstallError(self.location)
 
     def verifyTag(self, srv_path):
         """
@@ -518,17 +520,21 @@ ERROR: Directory contains a .scripts directory,
 but not a .git directory."""
 
 class NotAutoinstallError(Error):
-    """The directory was not an autoinstall, due to missing .scripts-version file."""
-    #: Directory in question
+    """Application is not an autoinstall."""
+    #: Directory of the not autoinstall
     dir = None
     def __init__(self, dir):
         self.dir = dir
     def __str__(self):
         return """
 
-ERROR: Could not find .scripts-version file. Are you sure
-this is an autoinstalled application?
-"""
+ERROR: The directory
+
+    %s
+
+does not appear to be an autoinstall.  If you are in a
+subdirectory of an autoinstall, you need to use the root
+directory for the autoinstall.""" % self.dir
 
 class NoTagError(Error):
     """Deployment has a tag that does not have an equivalent in upstream repository."""
@@ -631,4 +637,3 @@ host and path were in order to perform a web request
 on the application.  You can specify this manually using
 the WIZARD_WEB_HOST and WIZARD_WEB_PATH environment
 variables."""
-