]> scripts.mit.edu Git - wizard.git/blobdiff - wizard/deploy.py
Refactor calculate_repository() and calculate_tag() to deploy.
[wizard.git] / wizard / deploy.py
index 64083e67b1a6e750668d083a65273ff86a76dd4b..c565ea3405997dbc8ba7a7661e1c7166f0ade3d9 100644 (file)
@@ -6,48 +6,6 @@ import distutils.version
 
 import wizard
 
-class Error(wizard.Error):
-    """Base error class for deploy errors"""
-    pass
-
-class NoSuchApplication(Error):
-    pass
-
-class DeploymentParseError(Error):
-    def __init__(self, malformed):
-        self.malformed = malformed
-    def __str__(self):
-        return """
-
-ERROR: Could not parse deployment string:
-%s
-""" % self.malformed
-
-class ScriptsVersionTooManyFieldsError(Error):
-    def __str__(self):
-        return """
-
-ERROR: Could not parse .scripts-version file.  It
-contained too many fields.
-"""
-
-class ScriptsVersionNotEnoughFieldsError(Error):
-    def __str__(self):
-        return """
-
-ERROR: Could not parse .scripts-version file. It
-didn't contain enough fields.
-"""
-
-class ScriptsVersionNoSuchFile(Error):
-    def __init__(self, file):
-        self.file = file
-    def __str__(self):
-        return """
-
-ERROR: File %s didn't exist.
-""" % self.file
-
 def getInstallLines(global_options):
     """Retrieves a list of lines from the version directory that
     can be passed to Deployment.parse()"""
@@ -114,10 +72,16 @@ class Application(object):
     def __init__(self, name):
         self.name = name
         self.versions = {}
-        # Some cache variables for fast access of calculated data
+        # This is 'wizard summary' specific code
         self._total = 0
         self._max   = 0
         self._c_exists = {}
+    def getRepository(self):
+        """Returns the Git repository that would contain this application."""
+        repo = os.path.join("/afs/athena.mit.edu/contrib/scripts/wizard/srv", self.name + ".git")
+        if not os.path.isdir(repo):
+            raise NoRepositoryError(app)
+        return repo
     def getVersion(self, version):
         if version not in self.versions:
             self.versions[version] = ApplicationVersion(distutils.version.LooseVersion(version), self)
@@ -261,6 +225,11 @@ class ApplicationVersion(object):
         self.application = application
         self.c = 0
         self.c_exists = {}
+    def getScriptsTag(self):
+        """Returns the name of the Git tag for this version"""
+        # XXX: This assume sthat there's only a -scripts version
+        # which will not be true in the future.
+        return "v%s-scripts" % self.version
     def __cmp__(x, y):
         return cmp(x.version, y.version)
     @staticmethod
@@ -306,6 +275,48 @@ class ApplicationVersion(object):
         return "    %-12s %3d  %s" \
             % (self.version, self.c, self.application._graph(self.c))
 
+class Error(wizard.Error):
+    """Base error class for deploy errors"""
+    pass
+
+class NoSuchApplication(Error):
+    pass
+
+class DeploymentParseError(Error):
+    def __init__(self, malformed):
+        self.malformed = malformed
+    def __str__(self):
+        return """
+
+ERROR: Could not parse deployment string:
+%s
+""" % self.malformed
+
+class ScriptsVersionTooManyFieldsError(Error):
+    def __str__(self):
+        return """
+
+ERROR: Could not parse .scripts-version file.  It
+contained too many fields.
+"""
+
+class ScriptsVersionNotEnoughFieldsError(Error):
+    def __str__(self):
+        return """
+
+ERROR: Could not parse .scripts-version file. It
+didn't contain enough fields.
+"""
+
+class ScriptsVersionNoSuchFile(Error):
+    def __init__(self, file):
+        self.file = file
+    def __str__(self):
+        return """
+
+ERROR: File %s didn't exist.
+""" % self.file
+
 # If you want, you can wrap this up into a registry and access things
 # through that, but it's not really necessary