]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/deploy.py
Rewrite parametrize to use new parametrizeWithVars
[wizard.git] / wizard / deploy.py
index a748f1b78aaf82d2701c1f1a684465c3643c052f..6d3ec6702f6ec3bef6520483eb1d1134cb23b52c 100644 (file)
@@ -53,6 +53,11 @@ def parse_install_lines(show, versions_store, yield_errors = False, user = None)
             d = Deployment.parse(line)
             name = d.application.name
         except app.NoSuchApplication as e:
             d = Deployment.parse(line)
             name = d.application.name
         except app.NoSuchApplication as e:
+            if not e.location:
+                try:
+                    e.location = line.split(':')[0]
+                except IndexError:
+                    e.location = line
             if yield_errors:
                 yield e
             continue
             if yield_errors:
                 yield e
             continue
@@ -143,6 +148,8 @@ class Deployment(object):
             elif not has_git and not has_scripts:
                 if os.path.isfile(".scripts-version"):
                     raise NotMigratedError(self.location)
             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):
         """
 
     def verifyTag(self, srv_path):
         """
@@ -199,7 +206,6 @@ class Deployment(object):
         if not str(real) == self.app_version.pristine_tag.partition('-')[2]:
             raise VersionMismatchError(real, self.version)
 
         if not str(real) == self.app_version.pristine_tag.partition('-')[2]:
             raise VersionMismatchError(real, self.version)
 
-    @property
     @chdir_to_location
     def detectVersion(self):
         """
     @chdir_to_location
     def detectVersion(self):
         """
@@ -303,6 +309,12 @@ class Deployment(object):
         if not self._url:
             raise UnknownWebPath
         return self._url
         if not self._url:
             raise UnknownWebPath
         return self._url
+    def enableOldStyleUrls(self):
+        """
+        Switches to using http://user.scripts.mit.edu/~user/app URLs.
+        No effect if they have an explicit .scripts/url override.
+        """
+        self._url = scripts.fill_url(self.location, self.application.url(self), old_style = True)
     @staticmethod
     def parse(line):
         """
     @staticmethod
     def parse(line):
         """
@@ -398,6 +410,12 @@ class ProductionCopy(Deployment):
         this application uses.
         """
         self.application.remove(self, options)
         this application uses.
         """
         self.application.remove(self, options)
+    def verifyDatabase(self):
+        """
+        Checks if the autoinstall has a properly configured database.
+        """
+        if not self.application.checkDatabase(self):
+            raise DatabaseVerificationError
     def verifyWeb(self):
         """
         Checks if the autoinstall is viewable from the web.
     def verifyWeb(self):
         """
         Checks if the autoinstall is viewable from the web.
@@ -416,6 +434,13 @@ class WorkingCopy(Deployment):
     modifications to without fear of interfering with a production
     deployment.  More operations are permitted on these copies.
     """
     modifications to without fear of interfering with a production
     deployment.  More operations are permitted on these copies.
     """
+    def setAppVersion(self, app_version):
+        """
+        Manually resets the application version; useful if the working
+        copy is off in space (i.e. not anchored to something we can
+        git describe off of.)
+        """
+        self._app_version = app_version
     @chdir_to_location
     def parametrize(self, deployment):
         """
     @chdir_to_location
     def parametrize(self, deployment):
         """
@@ -506,17 +531,21 @@ ERROR: Directory contains a .scripts directory,
 but not a .git directory."""
 
 class NotAutoinstallError(Error):
 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 """
 
     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."""
 
 class NoTagError(Error):
     """Deployment has a tag that does not have an equivalent in upstream repository."""
@@ -609,6 +638,15 @@ web.  This may indicate that the website is behind
 authentication on the htaccess level.  You can find
 the contents of the page from the debug backtraces."""
 
 authentication on the htaccess level.  You can find
 the contents of the page from the debug backtraces."""
 
+class DatabaseVerificationError(Error):
+    """Could not access the database"""
+    def __str__(self):
+        return """
+
+ERROR: We were not able to access the database for
+this application; this probably means that your database
+configuration is misconfigured."""
+
 class UnknownWebPath(Error):
     """Could not determine application's web path."""
     def __str__(self):
 class UnknownWebPath(Error):
     """Could not determine application's web path."""
     def __str__(self):
@@ -619,4 +657,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."""
 on the application.  You can specify this manually using
 the WIZARD_WEB_HOST and WIZARD_WEB_PATH environment
 variables."""
-