当前位置: 首页>>代码示例>>Python>>正文


Python Package.get_nvr方法代码示例

本文整理汇总了Python中package.Package.get_nvr方法的典型用法代码示例。如果您正苦于以下问题:Python Package.get_nvr方法的具体用法?Python Package.get_nvr怎么用?Python Package.get_nvr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在package.Package的用法示例。


在下文中一共展示了Package.get_nvr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: main

# 需要导入模块: from package import Package [as 别名]
# 或者: from package.Package import get_nvr [as 别名]
def main():

    parser = argparse.ArgumentParser(description='Build a list of packages')
    parser.add_argument('--branch-source', default="f21", help='The branch to use as a source')
    parser.add_argument('--copr-id', default="el7-gnome-3-14", help='The COPR to use')
    parser.add_argument('--packages', default="./data/el7-gnome-3-14.txt", help='the list if packages to build')
    args = parser.parse_args()

    copr = CoprHelper(args.copr_id)
    koji = KojiHelper()

    data = ModulesXml('modules.xml')

    # add the copr id (e.g. el7) to any items in modules.xml file
    f = open(args.packages, 'r')
    for l in f.readlines():
        if l.startswith('#'):
            continue
        if l.startswith('\n'):
            continue
        linedata = l.strip().split(',')
        pkgname = linedata[0]
        item = data._get_item_by_pkgname(pkgname)
        if not item:
            print("%s not found" % pkgname)
            continue
        item.releases.append(copr.release)
        item.custom_package_url = None
        if len(linedata) > 1:
            item.custom_package_url = linedata[1]
    f.close()

    # disable any modules without the copr-specific release
    for item in data.items:
        if copr.release not in item.releases:
            item.disabled = True
            continue

    # depsolve
    print_debug("Depsolving moduleset...")
    if not data.depsolve():
        print_fail("Failed to depsolve")
        return

    # process all packages
    current_depsolve_level = 0
    for item in data.items:
        if item.disabled:
            continue;

        # wait for builds
        if current_depsolve_level != item.depsolve_level:
            rc = copr.wait_for_builds()
            if not rc:
                print_fail("A build failed, so aborting")
                break
            current_depsolve_level = item.depsolve_level
            print_debug("Now running depsolve level %i" % current_depsolve_level)

        # find the koji package
        pkg = None
        if not item.custom_package_url:
            pkg = koji.get_newest_build(args.branch_source, item.pkgname)
            if not pkg:
                print_fail("package %s does not exists in koji" % item.pkgname)
                continue
            pkg2 = koji.get_newest_build(args.branch_source + '-updates-candidate', item.pkgname)
            if not pkg2:
                print_fail("package %s does not exists in koji" % item.pkgname)
                continue

            # use the newest package
            if pkg.get_nvr() != pkg2.get_nvr():
                if rpm.labelCompare(pkg.get_evr(), pkg2.get_evr()) < 0:
                    pkg = pkg2;
        else:
            pkg = Package()
            nvr = os.path.basename(item.custom_package_url).rsplit('-', 2)
            pkg.name = nvr[0]
            pkg.version = nvr[1]
            pkg.release = nvr[2].replace('.src.rpm', '')
            pkg.url = item.custom_package_url
            
        print_debug("Latest version of %s: %s" % (item.pkgname, pkg.get_nvr()))

        # find if the package has been built in the copr
        try:
            status = copr.get_pkg_status(pkg)
        except CoprException, e:
            print_fail(str(e))
            continue
        if status == CoprBuildStatus.ALREADY_BUILT:
            print_debug("Already built")
            continue
        elif status == CoprBuildStatus.FAILED_TO_BUILD:
            print_debug("Failed, so retrying build")
        elif status == CoprBuildStatus.NOT_FOUND:
            print_debug("Not found, so building")
        elif status == CoprBuildStatus.IN_PROGRESS:
            print_debug("Already in progress")
#.........这里部分代码省略.........
开发者ID:pombreda,项目名称:mclazy,代码行数:103,代码来源:mclazy-rebase.py


注:本文中的package.Package.get_nvr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。