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


Python apt_pkg.Cache方法代碼示例

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


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

示例1: cmp_pkgrevno

# 需要導入模塊: import apt_pkg [as 別名]
# 或者: from apt_pkg import Cache [as 別名]
def cmp_pkgrevno(package, revno, pkgcache=None):
    """Compare supplied revno with the revno of the installed package

    *  1 => Installed revno is greater than supplied arg
    *  0 => Installed revno is the same as supplied arg
    * -1 => Installed revno is less than supplied arg

    This function imports apt_cache function from charmhelpers.fetch if
    the pkgcache argument is None. Be sure to add charmhelpers.fetch if
    you call this function, or pass an apt_pkg.Cache() instance.
    """
    import apt_pkg
    if not pkgcache:
        from charmhelpers.fetch import apt_cache
        pkgcache = apt_cache()
    pkg = pkgcache[package]
    return apt_pkg.version_compare(pkg.current_ver.ver_str, revno) 
開發者ID:openstack,項目名稱:charm-plumgrid-gateway,代碼行數:19,代碼來源:host.py

示例2: cmp_pkgrevno

# 需要導入模塊: import apt_pkg [as 別名]
# 或者: from apt_pkg import Cache [as 別名]
def cmp_pkgrevno(package, revno, pkgcache=None):
    """Compare supplied revno with the revno of the installed package.

    *  1 => Installed revno is greater than supplied arg
    *  0 => Installed revno is the same as supplied arg
    * -1 => Installed revno is less than supplied arg

    This function imports apt_cache function from charmhelpers.fetch if
    the pkgcache argument is None. Be sure to add charmhelpers.fetch if
    you call this function, or pass an apt_pkg.Cache() instance.
    """
    import apt_pkg
    if not pkgcache:
        from charmhelpers.fetch import apt_cache
        pkgcache = apt_cache()
    pkg = pkgcache[package]
    return apt_pkg.version_compare(pkg.current_ver.ver_str, revno) 
開發者ID:openstack,項目名稱:charm-swift-proxy,代碼行數:19,代碼來源:ubuntu.py

示例3: install_maas_cli

# 需要導入模塊: import apt_pkg [as 別名]
# 或者: from apt_pkg import Cache [as 別名]
def install_maas_cli(self):
        """Ensure maas-cli is installed

        Fallback to MAAS stable PPA when needed.
        """
        apt.init()
        cache = apt.Cache()

        try:
            pkg = cache['maas-cli']
        except KeyError:
            cmd = ['add-apt-repository', '-y', MAAS_STABLE_PPA]
            subprocess.check_call(cmd)
            cmd = ['apt-get', 'update']
            subprocess.check_call(cmd)
            self.install_maas_cli()
            return

        if not pkg.current_ver:
            apt_install('maas-cli', fatal=True) 
開發者ID:openstack,項目名稱:charm-hacluster,代碼行數:22,代碼來源:maas.py


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