本文整理汇总了Python中apt.debfile.DebPackage.install方法的典型用法代码示例。如果您正苦于以下问题:Python DebPackage.install方法的具体用法?Python DebPackage.install怎么用?Python DebPackage.install使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apt.debfile.DebPackage
的用法示例。
在下文中一共展示了DebPackage.install方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DebFile
# 需要导入模块: from apt.debfile import DebPackage [as 别名]
# 或者: from apt.debfile.DebPackage import install [as 别名]
class DebFile():
# the deb file which user selected
debfile = ''
path = ''
name = ''
version = ''
installedsize = -1
description = ''
def __init__(self, path):
self.debfile = DebPackage(path)
self.get_deb_info()
self.path = path
# check if the deb file is installable
def is_installable(self):
return self.debfile.check()
# get missing dependencies
def get_missing_deps(self):
return self.debfile.missing_deps
# get deb file name, version, installedsize, description
def get_deb_info(self):
self.name = self.debfile._sections["Package"]
self.version = self.debfile._sections["Version"]
self.installedsize = int(self.debfile._sections["Installed-Size"])
self.description = self.debfile._sections["Description"]
# install the deb file
def install_deb(self):
self.debfile.install(AptProcess(self.debfile.pkgname))
示例2: _test
# 需要导入模块: from apt.debfile import DebPackage [as 别名]
# 或者: from apt.debfile.DebPackage import install [as 别名]
def _test():
"""Test function"""
import sys
import apt
from apt.debfile import DebPackage
win = gtk.Window()
apt_progress = GtkAptProgress()
win.set_title("GtkAptProgress Demo")
win.add(apt_progress)
apt_progress.show()
win.show()
cache = apt.cache.Cache(apt_progress.open)
pkg = cache["xterm"]
if pkg.is_installed:
pkg.mark_delete()
else:
pkg.mark_install()
apt_progress.show_terminal(True)
try:
cache.commit(apt_progress.acquire, apt_progress.install)
except Exception as exc:
print >> sys.stderr, "Exception happened:", exc
if len(sys.argv) > 1:
deb = DebPackage(sys.argv[1], cache)
deb.install(apt_progress.dpkg_install)
win.connect("destroy", gtk.main_quit)
gtk.main()
示例3: install_debfile
# 需要导入模块: from apt.debfile import DebPackage [as 别名]
# 或者: from apt.debfile.DebPackage import install [as 别名]
def install_debfile(self, path, kwargs=None):
debfile = DebPackage(path)
pkgName = debfile._sections["Package"]
try:
debfile.install(AptProcess(self.dbus_service,pkgName,AppActions.INSTALLDEBFILE))
except Exception, e:
print e
print "install debfile err"
示例4: installdeb
# 需要导入模块: from apt.debfile import DebPackage [as 别名]
# 或者: from apt.debfile.DebPackage import install [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))
示例5: GtkAptProgress
# 需要导入模块: from apt.debfile import DebPackage [as 别名]
# 或者: from apt.debfile.DebPackage import install [as 别名]
from apt.debfile import DebPackage
win = gtk.Window()
apt_progress = GtkAptProgress()
win.set_title("GtkAptProgress Demo")
win.add(apt_progress)
apt_progress.show()
win.show()
cache = apt.cache.Cache(apt_progress.open)
pkg = cache["xterm"]
if pkg.is_installed:
pkg.mark_delete()
else:
pkg.mark_install()
apt_progress.show_terminal(True)
try:
cache.commit(apt_progress.acquire, apt_progress.install)
except Exception, exc:
print >> sys.stderr, "Exception happened:", exc
if len(sys.argv) > 1:
deb = DebPackage(sys.argv[1], cache)
deb.install(apt_progress.dpkg_install)
win.connect("destroy", gtk.main_quit)
gtk.main()
if __name__ == "__main__":
_test()
# vim: ts=4 et sts=4