diff --git a/debian/changelog b/debian/changelog index a14ee10..8dfdb4f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,5 +1,6 @@ lubuntu-update-notifier (0.5.1) lunar; urgency=medium + * Added functionality for repairing an interrupted upgrade. * Fixed an assumption in the config-file-conflict frontend. -- Aaron Rainbolt Wed, 14 Dec 2022 12:32:48 -0600 diff --git a/lubuntu-upgrader b/lubuntu-upgrader index 5a6f387..a95ff2f 100755 --- a/lubuntu-upgrader +++ b/lubuntu-upgrader @@ -65,6 +65,8 @@ class DialogUpg(QWidget): #stderr=subprocess.PIPE stderr=self.slave)''' + self.trans3 = self.apt_client.fix_incomplete_install() + self.repair_install() if options.fullUpgrade: self.trans2 = self.apt_client.upgrade_system(safe_mode=False) self.setWindowTitle('Full Upgrade') @@ -129,6 +131,12 @@ class DialogUpg(QWidget): self.progressBar.setValue(progress) self.label.setText(_("Updating cache...")) + def repair_progress(self, transaction, progress): + '''upgrade progressbar during update''' + self.progressBar.setVisible(True) + self.progressBar.setValue(progress) + self.label.setText(_("Repairing interrupted upgrade if necessary...")) + def update_progress_download(self, transaction, uri, status, short_desc, total_size, current_size, msg): '''print update info''' @@ -373,6 +381,36 @@ class DialogUpg(QWidget): '''when close button is pushed, quit''' app.quit() + def repair_install(self): + self.closeBtn.setVisible(False) + try: + self.trans3.connect('progress-changed', self.repair_progress) + self.trans3.connect('status-changed', self.status_changed) + self.trans3.connect('status-details-changed', + self.status_details_changed) + self.trans3.connect('config-file-conflict', + self.config_file_conflict) + self.trans3.connect('finished', self.repair_finish) + self.trans3.connect('error', self.upgrade_error) + self.trans3.run() + + except (NotAuthorizedError, TransactionFailed) as e: + print("Warning: install transaction not completed successfully:" + + "{}".format(e)) + + def repair_finish(self, transaction, exit_state): + '''when repair finish''' + self.label.setText(_("Repair Finished (if repair was needed)")) + if exit_state == EXIT_FAILED: + error_string = get_error_string_from_enum(transaction.error.code) + error_desc = get_error_description_from_enum( + transaction.error.code) + self.plainTextEdit.setEnabled(False) + self.plainTextEdit.moveCursor(QTextCursor.End) + self.plainTextEdit.insertPlainText(error_string + "\n") + self.plainTextEdit.insertPlainText(error_desc + "\n") + self.plainTextEdit.moveCursor(QTextCursor.End) + self.plainTextEdit.setEnabled(True) class App(QApplication): '''app'''