示例#1
0
    def test_guess_package_name(self):
        EXP = {
            'wat-1.2.rpm':
            'wat',
            'will-crash-0.5-2.fc20.src.rpm':
            'will-crash',
            'will-crash-0.5-2.fc20.src':
            'will-crash',
            'will-crash-0.5-2.fc20':
            'will-crash',
            'will-crash-0.5-2':
            'will-crash',
            'will-crash-0.5-2.rpm':
            'will-crash',
            'will-crash-0.5-2.src.rpm':
            'will-crash',
            'will-crash':
            'will-crash',
            'pkgname7.src.rpm':
            'pkgname7',
            'copr-frontend-1.14-1.git.65.9ba5393.fc20.noarch':
            'copr-frontend',
            'noversion.fc20.src.rpm':
            'noversion',
            'nothing':
            'nothing',
            'ruby193':
            'ruby193',
            'xorg-x11-fonts-ISO8859-1-75dpi-7.1-2.1.el5.noarch.rpm':
            'xorg-x11-fonts-ISO8859-1-75dpi',
        }

        for pkg, expected in EXP.iteritems():
            assert parse_package_name(pkg) == expected
示例#2
0
    def test_guess_package_name(self):
        EXP = {
            'wat-1.2.rpm': 'wat',
            'will-crash-0.5-2.fc20.src.rpm': 'will-crash',
            'will-crash-0.5-2.fc20.src': 'will-crash',
            'will-crash-0.5-2.fc20': 'will-crash',
            'will-crash-0.5-2': 'will-crash',
            'will-crash-0.5-2.rpm': 'will-crash',
            'will-crash-0.5-2.src.rpm': 'will-crash',
            'will-crash': 'will-crash',
            'pkgname7.src.rpm': 'pkgname7',
            'copr-frontend-1.14-1.git.65.9ba5393.fc20.noarch': 'copr-frontend',
            'noversion.fc20.src.rpm': 'noversion',
            'nothing': 'nothing',
            'ruby193': 'ruby193',
            'xorg-x11-fonts-ISO8859-1-75dpi-7.1-2.1.el5.noarch.rpm': 'xorg-x11-fonts-ISO8859-1-75dpi',
        }

        for pkg, expected in EXP.items():
            assert parse_package_name(pkg) == expected
示例#3
0
文件: filters.py 项目: 1dot75cm/Copr
def parse_package_name(pkg):
    if pkg is not None:
        return helpers.parse_package_name(os.path.basename(pkg))
    return pkg
示例#4
0
文件: filters.py 项目: 0-T-0/copr
def parse_package_name(pkg):
    if pkg is not None:
        return helpers.parse_package_name(os.path.basename(pkg))
    return pkg
示例#5
0
    def get_monitor_data(cls, copr):
        # builds are sorted by build id descending
        builds = BuildsLogic.get_multiply_by_copr(copr).all()

        chroots = set(chroot.name for chroot in copr.active_chroots)
        if builds:
            latest_build = builds[0]
            chroots.union(
                [chroot.name for chroot in latest_build.build_chroots])
        else:
            latest_build = None

        chroots = sorted(chroots)

        # { pkg_name -> { chroot -> (build_id, pkg_version, status) }}
        build_result_by_pkg_chroot = defaultdict(
            lambda: defaultdict(lambda: None))

        # collect information about pkg version and build states
        for build in builds:
            chroot_results = {
                chroot.name: chroot.state
                for chroot in build.build_chroots
            }

            pkg = os.path.basename(build.pkgs)
            pkg_name = helpers.parse_package_name(pkg)

            for chroot_name, state in chroot_results.items():
                # set only latest version/state
                if build_result_by_pkg_chroot[pkg_name][chroot_name] is None:
                    build_result_by_pkg_chroot[pkg_name][chroot_name] = (
                        build.id, build.pkg_version, state)

        # "transpose" data to present build status per package
        packages = []
        for pkg_name, chroot_dict in build_result_by_pkg_chroot.items():
            br = []
            try:
                latest_build_id = max([
                    build_id
                    for build_id, pkg_version, state in chroot_dict.values()
                ])
            except ValueError:
                latest_build_id = None

            for chroot_name in chroots:
                chroot_result = chroot_dict.get(chroot_name)
                if chroot_result:
                    build_id, pkg_version, state = chroot_result
                    br.append((build_id, state, pkg_version, chroot_name))
                else:
                    br.append((latest_build_id, None, None, chroot_name))

            packages.append((pkg_name, br))

        packages.sort()

        result = {
            "builds": builds,
            "chroots": chroots,
            "packages": packages,
            "latest_build": latest_build,
        }
        app.logger.debug("Monitor data: \n{}".format(pprint.pformat(result)))
        return result