python apt manager

Solutions on MaxInterview for python apt manager by the best coders in the world

showing results for - "python apt manager"
Greta
08 Jan 2020
1#!/usr/bin/env python
2# aptinstall.py
3
4import apt
5import sys
6
7pkg_name = "libjs-yui-doc"
8
9cache = apt.cache.Cache()
10cache.update()
11cache.open()
12
13pkg = cache[pkg_name]
14if pkg.is_installed:
15    print "{pkg_name} already installed".format(pkg_name=pkg_name)
16else:
17    pkg.mark_install()
18
19    try:
20        cache.commit()
21    except Exception, arg:
22        print >> sys.stderr, "Sorry, package installation failed [{err}]".format(err=str(arg))
23
queries leading to this page
21apt in pythonpython apt manager