Is it possible to run some of the calls of the python-apt module as root rather than having to run the whole script as root?
for example
import apt
cache=apt.Cache()
pkg = cache["p7zip-full"]
print "about to install:"+pkg_name
#switch to root
if pkg.is_installed:
print "{pkg_name} already installed".format(pkg_name)
else:
pkg.mark_install()
#back to user
print "install complete"
instead of having to:
sudo .install.py
thanks alexis
For the duplicate question point: I could be wrong but the answers given in that question use the subprocess module which starts a new process to run sudo commands on the OS. I am trying to make calls to the python-apt module/library as sudo or at least give python-apt the rights to be sudo.