Пример #1
0
    def add_buildout(self, data, host, checksum):
        packages = []

        for package_info in data.packages:
            package = Package.get_by_nameversion(package_info['name'],
                                                 package_info['version'])
            if not package:
                equation = package_info.get('equation', None)
                version = Version.get_by_version(package_info['version']) or\
                    Version.add(package_info['version'], equation)
                requirements = self.get_requirements(
                    package_info['requirements'], data.versionmap)
                package = Package.add(package_info['name'], version,
                                      requirements)

            packages.append(package)

        buildout = Buildout(data.name,
                            host,
                            checksum,
                            started=data.started,
                            finished=data.finished,
                            packages=packages,
                            config=data.config)

        DBSession.add(buildout)
        self.remove_old_buildouts(data.name)
        return buildout
Пример #2
0
    def add_buildout(self, data, host, checksum):
        packages = []

        for package_info in data.packages:
            package = Package.get_by_nameversion(package_info['name'],
                                                 package_info['version'])
            if not package:
                equation = package_info.get('equation', None)
                version = Version.get_by_version(package_info['version']) or\
                    Version.add(package_info['version'], equation)
                requirements = self.get_requirements(
                    package_info['requirements'], data.versionmap)
                package = Package.add(package_info['name'],
                                      version,
                                      requirements)

            packages.append(package)

        buildout = Buildout(data.name, host, checksum, started=data.started,
                            finished=data.finished, packages=packages,
                            config=data.config)

        DBSession.add(buildout)
        self.remove_old_buildouts(data.name)
        return buildout
Пример #3
0
    def get_requirements(self, requirements, versionmap):
        """Return list of package requirements."""
        packages = []

        for req in requirements:
            name = req.get('name')
            version = req.get('version')
            # Below version related code is crap
            # TODO: Clean the crap
            if not version:
                try:
                    version = versionmap[name]
                except KeyError:
                    version = 'stdlib'
            else:
                if version != versionmap[name]:
                    version = versionmap[name]
            package = Package.get_by_nameversion(name, version)
            if not package:
                equation = req.get('equation', None)
                version = Version.get_by_version(version) or\
                    Version.add(version, equation)
                package = Package.add(req['name'], version)
            packages.append(package)

        return packages
Пример #4
0
    def get_requirements(self, requirements, versionmap):
        """Return list of package requirements."""
        packages = []

        for req in requirements:
            name = req.get('name')
            version = req.get('version')
            # Below version related code is crap
            # TODO: Clean the crap
            if not version:
                try:
                    version = versionmap[name]
                except KeyError:
                    version = 'stdlib'
            else:
                if version != versionmap[name]:
                    version = versionmap[name]
            package = Package.get_by_nameversion(name,
                                                 version)
            if not package:
                equation = req.get('equation', None)
                version = Version.get_by_version(version) or\
                    Version.add(version, equation)
                package = Package.add(req['name'], version)
            packages.append(package)

        return packages
Пример #5
0
 def _createDummyContent(self, session):
     from whiskers.models import Buildout, Package, Version, Host
     host = Host('localhost', '127.0.0.1')
     version = Version('1.0')
     package = Package('req-package-1', version)
     packages = [Package('package1', version),
                 Package('package2', Version('2.0'),
                         requires=[package])]
     buildout = Buildout('buildout', host, 12345, packages=packages)
     session.add(buildout)
     session.flush()
     transaction.commit()
Пример #6
0
def add_version(package, version):
    """Add a new version and return its id"""

    existing_version = DBSession.query(Version).filter_by(version=version)

    if not existing_version.count():
        new_version = Version(version)
        DBSession.merge()
        return new_version.id
Пример #7
0
def get_version(version):
    """Returns version id for package"""

    existing_version = Version.get_by_version(version)

    if existing_version.count():
        return existing_version.first().id
    else:
        new_version_id = add_version(version)
        return new_version_id
Пример #8
0
    def create_buildout(self):
        from whiskers.models import (
            Buildout,
            Host,
            Package,
            Version,
        )

        host = Host(u'localhost', '127.0.0.1')
        self.session.add(host)
        version = Version('1.0')
        package = Package(u'example.package', version=version)
        buildout = Buildout(name=u"Example", host=host, checksum=1,
                            packages=[package])
        self.session.add(buildout)
Пример #9
0
 def _makePackage(self, name, version):
     from whiskers.models import Package, Version
     version = Version(version)
     return Package(name, version)
Пример #10
0
 def _makeOne(self, name='package', version='1.0', requires=None):
     from whiskers.models import Version
     return self._getTargetClass()(name, Version(version), requires)