def runTransaction(self, mainwin): def transactionErrors(errs): d = PirutDetailsDialog(mainwin, gtk.MESSAGE_ERROR, buttons=[('gtk-ok', 0)], text=_("Error updating software")) d.format_secondary_text( _("There were errors encountered in " "trying to update the software " "you selected")) d.set_details("%s" % '\n'.join(map(lambda x: x[0], errs.value))) d.run() d.destroy() def blacklistRemoveWarning(pkgs): d = PirutDetailsDialog(mainwin, gtk.MESSAGE_WARNING, buttons=[('gtk-cancel', gtk.RESPONSE_CANCEL), (_("_Remove anyway"), gtk.RESPONSE_OK, 'gtk-ok')], text=_("Removing critical software")) d.format_secondary_text( _("Some of the software which you are " "removing is either critical software " "for system functionality or required " "by such software. Are you sure you " "want to continue?")) txt = "" for po in pkgs: txt += "%s\n" % (po, ) d.set_details(txt) rc = d.run() d.destroy() return rc def kernelRemoveWarning(pkgs): d = PirutDetailsDialog(mainwin, gtk.MESSAGE_WARNING, buttons=[('gtk-cancel', gtk.RESPONSE_CANCEL), (_("_Remove anyway"), gtk.RESPONSE_OK, 'gtk-ok')], text=_("Removing critical software")) d.format_secondary_text( _("Removing this could leave you with " "no kernels and thus lead to a " "non-bootable system. Are you sure " "you want to continue?")) rc = d.run() d.destroy() return rc # FIXME: does this belong here? blacked = [] for txmbr in self.tsInfo.removed: if (txmbr.po.returnSimple('name') in remove_blacklist and len( self.tsInfo.matchNaevr(name=txmbr.po.returnSimple('name'))) == 1): blacked.append(txmbr.po) if len(blacked) > 0: rc = blacklistRemoveWarning(blacked) if rc != gtk.RESPONSE_OK: raise PirutError del self.ts self.initActionTs() # make a new, blank ts to populate self.populateTs(keepold=0) self.ts.check() #required for ordering self.ts.order() # order # set up the transaction to record output from scriptlets # this is pretty ugly... rpm.setVerbosity(rpm.RPMLOG_INFO) (r, w) = os.pipe() rf = os.fdopen(r, 'r') wf = os.fdopen(w, 'w') self.ts.ts.scriptFd = wf.fileno() rpm.setLogFile(wf) tsprog = Progress.PirutTransactionCallback(_("Updating software"), mainwin) tsprog.setReadPipe(rf) tsprog.show() tsprog.set_markup("<i>%s</i>" % (_("Preparing transaction"))) try: tserrors = yum.YumBase.runTransaction( self, yum.rpmtrans.RPMTransaction(self, display=tsprog)) except (yum.Errors.YumBaseError, PirutError), err: rpm.setLogFile(sys.stderr) rpm.setVerbosity(rpm.RPMLOG_NOTICE) wf.close() tsprog.destroy() # FIXME: these errors are actually pretty bad and should be # formatted better transactionErrors(err) raise PirutError