Exemple #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
Exemple #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
Exemple #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
Exemple #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
Exemple #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()
Exemple #6
0
    def package_view(self):
        """View for individual package."""
        package_name = self.request.matchdict.get("package_name", None)
        package_id = self.request.matchdict.get("id", None)

        packages = Package.get_packages_by_name(package_name)
        requires = None
        other_versions = False

        if package_id:
            package = packages.filter(Package.id == package_id).first()
            if package and package.requires:
                requires = package.requires
        else:
            package = None

        if packages.count() > 1:
            other_versions = True

        return {
            "packages": packages.all(),
            "package": package,
            "package_name": package_name,
            "main": self.main,
            "other_versions": other_versions,
            "requires": requires,
        }
Exemple #7
0
 def __call__(self):
     """Main view for packages."""
     packages = Package.by_name()
     unused = [
         {"id": package.id, "name": package.name, "version": package.version.version}
         for package in packages
         if not package.buildouts and package.version.version != "stdlib"
     ]
     return {"packages": packages, "project": "whiskers", "unused": unused, "main": self.main}
 def __call__(self):
     """Main view for packages."""
     packages = Package.by_name()
     unused = [{'id': package.id,
                'name': package.name,
                'version': package.version.version} for package in
               packages if not package.buildouts and
               package.version.version != 'stdlib']
     return {'packages': packages,
             'project': 'whiskers',
             'unused': unused,
             'main': self.main}
Exemple #9
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)
    def package_view(self):
        """View for individual package."""
        package_name = self.request.matchdict.get('package_name', None)
        package_id = self.request.matchdict.get('id', None)

        packages = Package.get_packages_by_name(package_name)
        requires = None
        other_versions = False

        if package_id:
            package = packages.filter(Package.id == package_id).first()
            if package and package.requires:
                requires = package.requires
        else:
            package = None

        if packages.count() > 1:
            other_versions = True

        return {'packages': packages.all(), 'package': package,
                'package_name': package_name, 'main': self.main,
                'other_versions': other_versions,
                'requires': requires}
Exemple #11
0
 def _makePackage(self, name, version):
     from whiskers.models import Package, Version
     version = Version(version)
     return Package(name, version)
 def get(self):
     package_id = self.request.matchdict.get('package_id')
     package = Package.get_by_id(package_id)
     return package.get_as_dict()