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