-from distutils.version import LooseVersion as Version
-
-class NoSuchApplication(Exception):
- pass
-
-class DeploymentParseError(Exception):
- pass
-
-class Deployment(object):
- def __init__(self, location, version):
- self.location = location
- self.version = version
- self.application = version.application
- @staticmethod
- def parse(line):
- """Parses a line from the results of parallel-find.pl.
- This will work out of the box with fileinput"""
- try:
- location, deploydir = line.rstrip().split(":")
- except ValueError:
- raise DeploymentParseError
- name = deploydir.split("/")[-1]
- if 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
- try:
- return Deployment(location, applications[app].getVersion(version))
- except KeyError:
- raise NoSuchApplication
- def count(self):
- """Simple method which registers the deployment as a +1 on the
- appropriate version. No further inspection is done."""
- self.version.count(self)
- return True
- def count_exists(self, file):
- """Checks if the codebase has a certain file/directory in it."""
- if os.path.exists(self.location + "/" + file):
- self.version.count_exists(self, file)
- return True
- return False