- def __init__(self):
- pass
-
-class UnknownDeploySource(DeploySource):
- """Deployment that we don't know the meaning of. Wot!"""
- def __init__(self, line):
- self.line = line
-
-class ApplicationVersion(object):
- """Represents an abstract notion of a version for an application"""
- def __init__(self, version, application):
- """ `version` Instance of distutils.LooseVersion
- `application` Instance of Application
- WARNING: Please don't call this directly; instead, use getVersion()
- on the application you want, so that this version gets registered."""
- self.version = version
- self.application = application
- self.c = 0
- self.c_exists = {}
- def __cmp__(x, y):
- return cmp(x.version, y.version)
- @staticmethod
- def parse(deploydir,applookup=None):
- # The version of the deployment, will be:
- # /afs/athena.mit.edu/contrib/scripts/deploy/APP-x.y.z for old style installs
- # /afs/athena.mit.edu/contrib/scripts/wizard/srv/APP.git vx.y.z-scripts for new style installs
- name = deploydir.split("/")[-1]
- try:
- if name.find(" ") != -1:
- raw_app, raw_version = name.split(" ")
- version = raw_version[1:] # remove leading v
- app, _ = raw_app.split(".") # remove trailing .git
- elif name.find("-") != -1:
- app, version = name.split("-")
- elif name == "deploy":
- # Assume that it's django, since those were botched
- app = "django"
- version = "0.1-scripts"
- else:
- raise DeploymentParseError(deploydir)
- except ValueError: # mostly from the a, b = foo.split(' ')
- raise DeploymentParseError(deploydir)
- if not applookup: applookup = applications
- try:
- # defer to the application for version creation
- return applookup[app].getVersion(version)
- except KeyError:
- raise NoSuchApplication
- # This is summary specific code
- def count(self, deployment):
- self.c += 1
- self.application._total += 1
- if self.c > self.application._max:
- self.application._max = self.c
- def count_exists(self, deployment, n):
- if n in self.c_exists: self.c_exists[n] += 1
- else: self.c_exists[n] = 1
- if n in self.application._c_exists: self.application._c_exists[n] += 1
- else: self.application._c_exists[n] = 1
- def report(self):
- return " %-12s %3d %s" \
- % (self.version, self.c, self.application._graph(self.c))
-
-# If you want, you can wrap this up into a registry and access things
-# through that, but it's not really necessary
-
-application_list = [
- "mediawiki", "wordpress", "joomla", "e107", "gallery2",
- "phpBB", "advancedbook", "phpical", "trac", "turbogears", "django",
- # these are technically deprecated
- "advancedpoll", "gallery",
-]
-
-"""Hash table for looking up string application name to instance"""
-applications = dict([(n,Application(n)) for n in application_list ])
+ The deployment contains a .scripts-version file, but no .git
+ or .scripts directory.
+ """
+ #: Directory of deployment
+ dir = None
+ def __init__(self, dir):
+ self.dir = dir
+ def __str__(self):
+ return """This installation was not migrated"""
+
+class AlreadyVersionedError(Error):
+ """The deployment contained a .git directory but no .scripts directory."""
+ #: Directory of deployment
+ dir = None
+ def __init__(self, dir):
+ self.dir = dir
+ def __str__(self):
+ return """
+
+ERROR: Directory contains a .git directory, but not
+a .scripts directory. If this is not a corrupt
+migration, this means that the user was versioning their
+install using Git."""
+
+class NotConfiguredError(Error):
+ """The install was missing essential configuration."""
+ #: Directory of unconfigured install
+ dir = None
+ def __init__(self, dir):
+ self.dir = dir
+ def __str__(self):
+ return """
+
+ERROR: The install was well-formed, but not configured
+(essential configuration files were not found.)"""
+
+class CorruptedAutoinstallError(Error):
+ """The install was missing a .git directory, but had a .scripts directory."""
+ #: Directory of the corrupted install
+ dir = None
+ def __init__(self, dir):
+ self.dir = dir
+ def __str__(self):
+ return """
+
+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
+ 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?
+"""
+
+class NoTagError(Error):
+ """Deployment has a tag that does not have an equivalent in upstream repository."""
+ #: Missing tag
+ tag = None
+ def __init__(self, tag):
+ self.tag = tag
+ def __str__(self):
+ return """
+
+ERROR: Could not find tag %s in repository.""" % self.tag
+
+class NoLocalTagError(Error):
+ """Could not find tag in local repository."""
+ #: Missing tag
+ tag = None
+ def __init__(self, tag):
+ self.tag = tag
+ def __str__(self):
+ return """
+
+ERROR: Could not find tag %s in local repository.""" % self.tag
+
+class InconsistentPristineTagError(Error):
+ """Pristine tag commit ID does not match upstream pristine tag commit ID."""
+ #: Inconsistent tag
+ tag = None
+ def __init__(self, tag):
+ self.tag = tag
+ def __str__(self):
+ return """
+
+ERROR: Local pristine tag %s did not match repository's. This
+probably means an upstream rebase occured.""" % self.tag
+
+class InconsistentScriptsTagError(Error):
+ """Scripts tag commit ID does not match upstream scripts tag commit ID."""
+ #: Inconsistent tag
+ tag = None
+ def __init__(self, tag):
+ self.tag = tag
+ def __str__(self):
+ return """
+
+ERROR: Local scripts tag %s did not match repository's. This
+probably means an upstream rebase occurred.""" % self.tag
+
+class HeadNotDescendantError(Error):
+ """HEAD is not connected to tag."""
+ #: Tag that HEAD should have been descendant of.
+ tag = None
+ def __init__(self, tag):
+ self.tag = tag
+ def __str__(self):
+ return """
+
+ERROR: HEAD is not a descendant of %s. This probably
+means that an upstream rebase occurred, and new tags were
+pulled, but local user commits were never rebased.""" % self.tag
+
+class VersionDetectionError(Error):
+ """Could not detect real version of application."""
+ def __str__(self):
+ return """
+
+ERROR: Could not detect the real version of the application."""
+
+class VersionMismatchError(Error):
+ """Git version of application does not match detected version."""
+ #: Detected version
+ real_version = None
+ #: Version from Git
+ git_version = None
+ def __init__(self, real_version, git_version):
+ self.real_version = real_version
+ self.git_version = git_version
+ def __str__(self):
+ return """
+
+ERROR: The detected version %s did not match the Git
+version %s.""" % (self.real_version, self.git_version)
+
+class WebVerificationError(Error):
+ """Could not access the application on the web"""
+ def __str__(self):
+ return """
+
+ERROR: We were not able to access the application on the
+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."""
+
+class UnknownWebPath(Error):
+ """Could not determine application's web path."""
+ def __str__(self):
+ return """
+
+ERROR: We were not able to determine what the application's
+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."""