I check this code provided by python_apt , but it is a bit outdated:
https://github.com/jolicloud/python-apt/blob/master/doc/examples/inst.py
All I'm trying to do is keep track of the progress of the commit() method; currently, when we call commit() and switch to fprogress and iprogress , I can see on the console that all packages in pkg_list loaded correctly, the problem arises after that.
The program continues to run, and it does not run dpkg_status_change() , I believe it should?
I donβt have the opportunity to know if the installation of several packages was successful
import apt from apt.progress.base import InstallProgress class InstallStatusUpdate(InstallProgress): def conffile(self, current, new): print "conffile prompt: %s %s" % (current, new) def processing(self, pkg, stage): print "Processing ", pkg, " stage: ", stage def error(self, pkg, errormsg): print "Package ", pkg, " error: ", errormsg def finish_update(self): print "Installation is complete" def status_change(self, pkg, percent, status): print "Package: ", pkg, " at ", percent, " -> ", status def dpkg_status_change(self, pkg, status): print "Package ", pkg, ", Status: ", status def install_updates(self, pkg_list): fprogress = apt.progress.TextFetchProgress() iprogress = InstallStatusUpdate() cache_tmp = apt.Cache() cache_tmp.update() cache_tmp.open(None) for pkg in pkg_list: try: self.pkgname = cache_tmp[pkg.name] if self.pkgname.is_installed and self.pkgname.is_upgradable: self.pkgname.mark_upgrade() else: self.pkgname.mark_install() except Exception as e: print e.message result = self.pkgname.commit(fprogress, iprogress)