本文整理汇总了Python中apt.debfile.DebPackage.check_conflicts方法的典型用法代码示例。如果您正苦于以下问题:Python DebPackage.check_conflicts方法的具体用法?Python DebPackage.check_conflicts怎么用?Python DebPackage.check_conflicts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apt.debfile.DebPackage
的用法示例。
在下文中一共展示了DebPackage.check_conflicts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: installdeb
# 需要导入模块: from apt.debfile import DebPackage [as 别名]
# 或者: from apt.debfile.DebPackage import check_conflicts [as 别名]
def installdeb(self, pkg):
"""
Install the Debian package.
:param pkg: The path to the package to install
:type pkg: str
"""
# Get the DebPackage object and the filename
dpkg = DebPackage(filename=pkg, cache=self.cache)
pkg_name = basename(pkg)
# Look for package conflicts
if not dpkg.check_conflicts():
self.feedback.block(dpkg.conflicts, 'CONFLICT')
self.feedback.error('Cannot install package <{0}>, conflicts with:'.format(pkg_name))
return False
# Get any version in cache
cache_version = dpkg.compare_to_version_in_cache()
action = 'Installed'
# Not installed
if cache_version == dpkg.VERSION_NONE:
self.feedback.info('Package <{0}> not installed'.format(pkg_name))
# Upgrading
if cache_version == dpkg.VERSION_OUTDATED:
self.feedback.info('Package <{0}> outdated, upgrading'.format(pkg_name))
action = 'Updated'
# Same version
if cache_version == dpkg.VERSION_SAME:
return self.feedback.info('Package <{0}> already installed'.format(pkg_name))
# Installed is newer
if cache_version == dpkg.VERSION_NEWER:
return self.feedback.info('Package <{0}> has newer version installed'.format(pkg_name))
# Install the package
dpkg.install()
self.feedback.success('{0}: {1}'.format(action, pkg_name))