如何处理使用pythonapt生成多个配置对话框屏幕的apt安装?

2024-04-26 13:28:53 发布

您现在位置:Python中文网/ 问答频道 /正文

例如,当安装lirc包时,它会显示配置对话框屏幕。如何自动选择默认值(或可能提供特定值)并继续?你知道吗

现在我有一个简单的脚本:

  #!/usr/bin/env python
  import apt
  import sys

  pkg_name = "lirc"

  cache = apt.cache.Cache()
  cache.update()

  pkg = cache[pkg_name]
  if pkg.is_installed:
      print "{pkg_name} already installed".format(pkg_name=pkg_name)
  else:
      pkg.mark_install()

      try:
          cache.commit()
      except Exception, arg:
          print >> sys.stderr, "Sorry, package installation failed [{err}]".format(err=str(arg))

配置窗口如下链接所示 http://cdn.avsforum.com/d/db/db48d778_vbattach158986.jpeg


Tags: installednameimport脚本formatcache屏幕sys