本文整理汇总了Python中apt.apt_pkg.init方法的典型用法代码示例。如果您正苦于以下问题:Python apt_pkg.init方法的具体用法?Python apt_pkg.init怎么用?Python apt_pkg.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apt.apt_pkg
的用法示例。
在下文中一共展示了apt_pkg.init方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setup_ipv6
# 需要导入模块: from apt import apt_pkg [as 别名]
# 或者: from apt.apt_pkg import init [as 别名]
def setup_ipv6():
ubuntu_rel = lsb_release()['DISTRIB_CODENAME'].lower()
if CompareHostReleases(ubuntu_rel) < "trusty":
raise Exception("IPv6 is not supported in the charms for Ubuntu "
"versions less than Trusty 14.04")
from apt import apt_pkg
apt_pkg.init()
# Need haproxy >= 1.5.3 for ipv6 so for Trusty if we are <= Kilo we need to
# use trusty-backports otherwise we can use the UCA.
vc = apt_pkg.version_compare(get_pkg_version('haproxy'), '1.5.3')
if ubuntu_rel == 'trusty' and vc == -1:
add_source('deb http://archive.ubuntu.com/ubuntu trusty-backports '
'main')
apt_update(fatal=True)
apt_install('haproxy/trusty-backports', fatal=True)
示例2: apt_cache
# 需要导入模块: from apt import apt_pkg [as 别名]
# 或者: from apt.apt_pkg import init [as 别名]
def apt_cache(in_memory=True):
"""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()
示例3: apt_cache
# 需要导入模块: from apt import apt_pkg [as 别名]
# 或者: from apt.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)
示例4: verify_config
# 需要导入模块: from apt import apt_pkg [as 别名]
# 或者: from apt.apt_pkg import init [as 别名]
def verify_config(self):
apt_pkg.init()
for cfg in self.config:
value = apt_pkg.config.get(cfg['key'], cfg.get('default', ''))
if value and value != cfg['expected']:
log("APT config '%s' has unexpected value '%s' "
"(expected='%s')" %
(cfg['key'], value, cfg['expected']), level=WARNING)