- fh = open(file)
- except IOError:
- raise ScriptsVersionNoSuchFile(file)
- for line in fh:
- line = line.rstrip()
- if not line:
- append(rev)
- i = 0
- rev = DeployRevision()
- continue
- if i == 0:
- rev.datetime = dateutil.parser.parse(line)
- elif i == 1:
- rev.user = line
- elif i == 2:
- rev.source = DeploySource.parse(line)
- elif i == 3:
- rev.version = ApplicationVersion.parse(line)
- else:
- # ruh oh
- raise ScriptsVersionTooManyFieldsError()
- i += 1
- append(rev)
- return DeployLog(revs)
- def __repr__(self):
- return '<DeployLog %s>' % list.__repr__(self)
-
-class DeployRevision(object):
- """A single entry in the .scripts-version file. Contains who deployed
- this revision, what application version this is, etc."""
- def __init__(self, datetime=None, user=None, source=None, version=None):
- """ `datetime` Time this revision was deployed
- `user` Person who deployed this revision, in user@host format.
- `source` Instance of DeploySource
- `version` Instance of ApplicationVersion
- Note: This object is typically built incrementally."""
- self.datetime = datetime
- self.user = user
- self.source = source
- self.version = version
-
-class DeploySource(object):
- """Source of the deployment; see subclasses for examples"""
- def __init__(self):
- raise NotImplementedError # abstract class
- @staticmethod
- def parse(line):
- # munge out common prefix
- rel = os.path.relpath(line, "/afs/athena.mit.edu/contrib/scripts/")
- parts = rel.split("/")
- if parts[0] == "wizard":
- return WizardUpdate()
- elif parts[0] == "deploy" or parts[0] == "deploydev":
- isDev = ( parts[0] == "deploydev" )
- try:
- if parts[1] == "updates":
- return OldUpdate(isDev)
- else:
- return TarballInstall(line, isDev)
- except IndexError:
- pass
- return UnknownDeploySource(line)
-
-class TarballInstall(DeploySource):
- """Original installation from tarball, characterized by
- /afs/athena.mit.edu/contrib/scripts/deploy/APP-x.y.z.tar.gz
- """
- def __init__(self, location, isDev):
- self.location = location
- self.isDev = isDev
-
-class OldUpdate(DeploySource):
- """Upgrade using old upgrade infrastructure, characterized by
- /afs/athena.mit.edu/contrib/scripts/deploydev/updates/update-scripts-version.pl
- """
- def __init__(self, isDev):
- self.isDev = isDev
-
-class WizardUpdate(DeploySource):
- """Upgrade using wizard infrastructure, characterized by
- /afs/athena.mit.edu/contrib/scripts/wizard/bin/wizard HASHGOBBLEDYGOOK
- """
- def __init__(self):
- pass
-
-class UnknownDeploySource(DeploySource):
- """Deployment that we don't know the meaning of. Wot!"""
- def __init__(self, line):
- self.line = line