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


Python apt_pkg.init方法代碼示例

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


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

示例1: install_maas_cli

# 需要導入模塊: import apt_pkg [as 別名]
# 或者: from apt_pkg import init [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

示例2: openstack_upgrade_available

# 需要導入模塊: import apt_pkg [as 別名]
# 或者: from apt_pkg import init [as 別名]
def openstack_upgrade_available(self, package=None, snap=None):
        """Check if an OpenStack upgrade is available

        :param package: str Package name to use to check upgrade availability
        :returns: bool
        """
        if not package:
            package = self.release_pkg
        if not snap:
            snap = self.release_snap

        src = self.config['openstack-origin']
        cur_vers = self.get_os_version_package(package)
        avail_vers = os_utils.get_os_version_install_source(src)
        if os_utils.snap_install_requested():
            cur_vers = self.get_os_version_snap(snap)
        else:
            cur_vers = self.get_os_version_package(package)
        apt.init()
        return apt.version_compare(avail_vers, cur_vers) == 1 
開發者ID:openstack,項目名稱:charms.openstack,代碼行數:22,代碼來源:core.py

示例3: getDependencies

# 需要導入模塊: import apt_pkg [as 別名]
# 或者: from apt_pkg import init [as 別名]
def getDependencies(self, packageName):
        # Simulate a set using a hash (to a dummy value);
        # sets were only added in Python 2.4
        result = {}
        if not self.cache:
            import apt_pkg
            apt_pkg.init()
            self.cache = apt_pkg.Cache()
        packages = self.cache.packages
        for package in packages:
            if package.name == packageName:
                current = package.current_ver
                if not current:
                    raise PackageNotFoundError(packageName)
                depends = current.depends_list
                list = depends['Depends']
                for dependency in list:
                    name = dependency[0].target_pkg.name
                    # Add to the hash using a dummy value
                    result[name] = None
        return list(result.keys()) 
開發者ID:vhumpa,項目名稱:dogtail,代碼行數:23,代碼來源:distro.py

示例4: openstack_upgrade_available

# 需要導入模塊: import apt_pkg [as 別名]
# 或者: from apt_pkg import init [as 別名]
def openstack_upgrade_available(package):
    """
    Determines if an OpenStack upgrade is available from installation
    source, based on version of installed package.

    :param package: str: Name of installed package.

    :returns: bool:    : Returns True if configured installation source offers
                         a newer version of package.

    """

    import apt_pkg as apt
    src = config('openstack-origin')
    cur_vers = get_os_version_package(package)
    if "swift" in package:
        codename = get_os_codename_install_source(src)
        avail_vers = get_os_version_codename_swift(codename)
    else:
        avail_vers = get_os_version_install_source(src)
    apt.init()
    if "swift" in package:
        major_cur_vers = cur_vers.split('.', 1)[0]
        major_avail_vers = avail_vers.split('.', 1)[0]
        major_diff = apt.version_compare(major_avail_vers, major_cur_vers)
        return avail_vers > cur_vers and (major_diff == 1 or major_diff == 0)
    return apt.version_compare(avail_vers, cur_vers) == 1 
開發者ID:openstack,項目名稱:charm-plumgrid-gateway,代碼行數:29,代碼來源:utils.py

示例5: openstack_upgrade_available

# 需要導入模塊: import apt_pkg [as 別名]
# 或者: from apt_pkg import init [as 別名]
def openstack_upgrade_available(package):
    """
    Determines if an OpenStack upgrade is available from installation
    source, based on version of installed package.

    :param package: str: Name of installed package.

    :returns: bool:    : Returns True if configured installation source offers
                         a newer version of package.
    """

    import apt_pkg as apt
    src = config('openstack-origin')
    cur_vers = get_os_version_package(package)
    if not cur_vers:
        # The package has not been installed yet do not attempt upgrade
        return False
    if "swift" in package:
        codename = get_os_codename_install_source(src)
        avail_vers = get_os_version_codename_swift(codename)
    else:
        avail_vers = get_os_version_install_source(src)
    apt.init()
    if "swift" in package:
        major_cur_vers = cur_vers.split('.', 1)[0]
        major_avail_vers = avail_vers.split('.', 1)[0]
        major_diff = apt.version_compare(major_avail_vers, major_cur_vers)
        return avail_vers > cur_vers and (major_diff == 1 or major_diff == 0)
    return apt.version_compare(avail_vers, cur_vers) == 1 
開發者ID:openstack,項目名稱:charm-swift-proxy,代碼行數:31,代碼來源:utils.py

示例6: apt_cache

# 需要導入模塊: import apt_pkg [as 別名]
# 或者: from apt_pkg import init [as 別名]
def apt_cache(in_memory=True, progress=None):
    """Build and return an apt cache."""
    from apt import apt_pkg
    apt_pkg.init()
    if in_memory:
        apt_pkg.config.set("Dir::Cache::pkgcache", "")
        apt_pkg.config.set("Dir::Cache::srcpkgcache", "")
    return apt_pkg.Cache(progress) 
開發者ID:openstack,項目名稱:charm-swift-proxy,代碼行數:10,代碼來源:ubuntu.py


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