当前位置: 首页>>代码示例>>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;未经允许,请勿转载。