當前位置: 首頁>>代碼示例>>Python>>正文


Python rpm.labelCompare方法代碼示例

本文整理匯總了Python中rpm.labelCompare方法的典型用法代碼示例。如果您正苦於以下問題:Python rpm.labelCompare方法的具體用法?Python rpm.labelCompare怎麽用?Python rpm.labelCompare使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在rpm的用法示例。


在下文中一共展示了rpm.labelCompare方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: cmpKernelVer

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import labelCompare [as 別名]
def cmpKernelVer(str1, str2):
    'compare two kernel version strings and return -1, 0, 1 for less, equal, greater'
    import rpm
    return rpm.labelCompare(('', str1, ''), ('', str2, '')) 
開發者ID:rpm-software-management,項目名稱:mock,代碼行數:6,代碼來源:util.py

示例2: nvrcmp

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import labelCompare [as 別名]
def nvrcmp(nvr1, nvr2):
    if not RPM_AVAILABLE:
        raise exception.RpmModuleNotAvailable()
    t1 = string_to_version(nvr1)
    t2 = string_to_version(nvr2)
    return rpm.labelCompare(t1, t2) 
開發者ID:softwarefactory-project,項目名稱:rdopkg,代碼行數:8,代碼來源:specfile.py

示例3: vcmp

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import labelCompare [as 別名]
def vcmp(v1, v2):
    if not RPM_AVAILABLE:
        raise exception.RpmModuleNotAvailable()
    t1 = ('0', v1, '')
    t2 = ('0', v2, '')
    return rpm.labelCompare(t1, t2) 
開發者ID:softwarefactory-project,項目名稱:rdopkg,代碼行數:8,代碼來源:specfile.py

示例4: _compare_rpm_labels

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import labelCompare [as 別名]
def _compare_rpm_labels(lhs, rhs):
        lhs_epoch, lhs_version, lhs_release = lhs
        rhs_epoch, rhs_version, rhs_release = rhs
        result = _compare_rpm_field(lhs_epoch, rhs_epoch)
        if result:
            return result
        result = _compare_rpm_field(lhs_version, rhs_version)
        if result:
            return result
        return _compare_rpm_field(lhs_release, rhs_release) 
開發者ID:fedora-infra,項目名稱:the-new-hotness,代碼行數:12,代碼來源:helpers.py

示例5: rpm_cmp

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import labelCompare [as 別名]
def rpm_cmp(v1, v2):
    diff = _compare_rpm_labels((None, v1, None), (None, v2, None))
    return diff 
開發者ID:fedora-infra,項目名稱:the-new-hotness,代碼行數:5,代碼來源:helpers.py

示例6: is_pkg_vuln

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import labelCompare [as 別名]
def is_pkg_vuln(vtag, vpkg, flavor, ivers, iversonly, vvers):
    isvuln = False
    #print "cve-scan: " + vpkg + "\n\tvulnerability package version: " + vvers + "\n\timage package version: " + ivers

    if vtag == 'VulnerableIn' and vvers == 'all':
        isvuln = True
    elif vvers != 'None':
        if flavor == 'RHEL':
            fixfile = vpkg + "-" + vvers + ".arch.rpm"
            imagefile = vpkg + "-" + ivers + ".arch.rpm"
            (n1, v1, r1, e1, a1) = splitFilename(imagefile)
            (n2, v2, r2, e2, a2) = splitFilename(fixfile)
            if vtag == 'FixedIn':
                if rpm.labelCompare(('1', v1, r1), ('1', v2, r2)) < 0:
                    isvuln = True
            elif vtag == 'VulnerableIn':
                if ivers == vvers or iversonly == vvers:
                    isvuln = True

        elif flavor == 'DEB':
            if vtag == 'FixedIn':
                if ivers != vvers:
                    comp_rc = dpkg_compare_versions(ivers, 'lt', vvers)
                    if comp_rc == 0:
                        isvuln = True
            elif vtag == 'VulnerableIn':
                if ivers == vvers or iversonly == vvers:
                    isvuln = True

        elif flavor == "ALPINE":
            if vtag == 'FixedIn':
                comp_rc = apkg_compare_versions(ivers, 'lt', vvers)
                if comp_rc == 0:
                    isvuln = True
            elif vtag == 'VulnerableIn':
                if ivers == vvers or iversonly == vvers:
                    isvuln = True
    else:
        isvuln = True

    return(isvuln) 
開發者ID:anchore,項目名稱:anchore,代碼行數:43,代碼來源:anchore_utils.py

示例7: compare_evr

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import labelCompare [as 別名]
def compare_evr(evr1, evr2):
    def epoch_to_str(epoch):
        return str(epoch) if epoch is not None else None

    evr1, evr2 = ((epoch_to_str(e), v, r) for (e, v, r) in (evr1, evr2))
    return rpm.labelCompare(evr1, evr2) 
開發者ID:fedora-infra,項目名稱:koschei,代碼行數:8,代碼來源:util.py

示例8: rpmvercmp

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import labelCompare [as 別名]
def rpmvercmp(v1, v2):
    return rpm.labelCompare((None, None, v1), (None, None, v2)) 
開發者ID:fedora-infra,項目名稱:koschei,代碼行數:4,代碼來源:common.py

示例9: compare_package_versions

# 需要導入模塊: import rpm [as 別名]
# 或者: from rpm import labelCompare [as 別名]
def compare_package_versions(imageId, pkga, vera, pkgb, verb):
    # if ret == 0, versions are equal
    # if ret > 0, vers A is greater than version B
    # if ret < 0, vers A is less than version B

    fulla = '-'.join([str(pkga), str(vera)])
    fullb = '-'.join([str(pkgb), str(verb)])
    if fulla == fullb:
        return(0)

    distrometa = get_distro_from_imageId(imageId)
    idistro = distrometa['DISTRO']
    idistrovers = distrometa['DISTROVERS']
    ilikedistro = distrometa['LIKEDISTRO']
    distrodict = get_distro_flavor(idistro, idistrovers, likedistro=ilikedistro)
    flavor = distrodict['flavor']

    if flavor == "RHEL":
        fixfile = pkgb + "-" + verb + ".arch.rpm"
        imagefile = pkga + "-" + vera + ".arch.rpm"
        (n1, v1, r1, e1, a1) = splitFilename(imagefile)
        (n2, v2, r2, e2, a2) = splitFilename(fixfile)
        if rpm.labelCompare(('1', v1, r1), ('1', v2, r2)) < 0:
            return(-1)
        else:
            return(1)

    elif flavor == "DEB":
        comp_rc = dpkg_compare_versions(vera, 'lt', verb)
        if comp_rc == 0:
            return(-1)
        else:
            return(1)
    elif flavor == "ALPINE":
        comp_rc = apkg_compare_versions(vera, 'lt', verb)
        if comp_rc == 0:
            return(-1)
        else:
            return(1)
    else:
        raise ValueError("unsupported distro, cannot compare package versions")

    return(0) 
開發者ID:anchore,項目名稱:anchore,代碼行數:45,代碼來源:anchore_utils.py


注:本文中的rpm.labelCompare方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。