diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e37b19..50ef93c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Changelog ## 0.9.x +### 0.9.1: Patch for Unsuccessful Successful Update +- Addressed a rare issue where the package did not update correctly using the updater. + - Unable to reproduce, but it may have been related to an older version and the restart process. +- Added developer functions to test the updater without requiring a published release. + ### 0.9.0: UI Enhancements and Language Refinements - Changed text, labels, buttons, and checkboxes for clearer understanding. - Improved UI language to make the interface easier to navigate. diff --git a/pyproject.toml b/pyproject.toml index b54eeb2..57042c5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -11,7 +11,7 @@ readme = "pip_README.md" requires-python = ">=3.8" dependencies = [ "optima35>=1.0.0, <2.0.0", - "PyPiUpdater>=0.5.0, <1.0.0", + "PyPiUpdater>=0.6.0, <1.0.0", "pyside6", "PyYAML", ] diff --git a/src/OptimaLab35/gui.py b/src/OptimaLab35/gui.py index 838222b..51c9fee 100644 --- a/src/OptimaLab35/gui.py +++ b/src/OptimaLab35/gui.py @@ -480,6 +480,7 @@ class UpdaterWindow(QMainWindow, Ui_Updater_Window): self.ui = Ui_Updater_Window() self.ui.setupUi(self) self.dev_mode = True if optimalab35_localversion == "0.0.1" else False + self.set_dev_ui() from PyPiUpdater import PyPiUpdater # Update log file location self.update_log_file = os.path.expanduser("~/.config/OptimaLab35/update_log.json") @@ -515,10 +516,76 @@ class UpdaterWindow(QMainWindow, Ui_Updater_Window): self.ui.update_and_restart_Button.clicked.connect(self.update_and_restart) self.ui.label_last_check_2.setText(self.time_to_string(self.ol35_last_state[0])) - def dev_mode(self): - self.ui.update_and_restart_Button.setEnabled(False) - self.ui.check_for_update_Button.setEnabled(False) - self.ui.label_dev.setStyleSheet("QLabel { background-color : red; color : black; }") + def set_dev_ui(self): + self.ui.check_local_Button.setVisible(self.dev_mode) + self.ui.update_local_Button.setVisible(self.dev_mode) + self.ui.check_for_update_Button.setVisible(not self.dev_mode) + self.ui.update_and_restart_Button.setVisible(not self.dev_mode) + + if self.dev_mode: + self.ui.check_local_Button.clicked.connect(self.local_check_for_updates) + self.ui.update_local_Button.clicked.connect(self.local_update) + + def local_check_for_updates(self): + dist_folder = os.path.expanduser("~/git/gitlab_public/OptimaLab35/dist/") + self.ui.check_local_Button.setEnabled(False) + self.ui.label_optimalab35_latestversion.setText("Checking...") + self.ui.label_optima35_latestversion.setText("Checking...") + + # Check OptimaLab35 update + ol35_pkg_info = self.ppu_ol35.check_update_local(dist_folder) + if ol35_pkg_info[0] is None: + self.ui.label_optimalab35_latestversion.setText(ol35_pkg_info[1][0:13]) + else: + self.ui.label_optimalab35_latestversion.setText(ol35_pkg_info[1]) + self.updates_available["OptimaLab35"] = ol35_pkg_info[0] + + # Check optima35 update + o35_pkg_info = self.ppu_o35.check_update_local(dist_folder) + if o35_pkg_info[0] is None: + self.ui.label_optima35_latestversion.setText(o35_pkg_info[1][0:13]) + else: + self.ui.label_optima35_latestversion.setText(o35_pkg_info[1]) + self.updates_available["optima35"] = o35_pkg_info[0] + + + def local_update(self): + dist_folder = os.path.expanduser("~/git/gitlab_public/OptimaLab35/dist/") + packages_to_update = [pkg for pkg, update in self.updates_available.items() if update] + + if not packages_to_update: + QMessageBox.information(self, "Update", "No updates available.") + return + + # Confirm update + msg = QMessageBox() + msg.setWindowTitle("Update Available") + msg.setText(f"Updating: {', '.join(packages_to_update)}\nUpdate and restart app?") + msg.setStandardButtons(QMessageBox.Yes | QMessageBox.No) + result = msg.exec() + + if result == QMessageBox.Yes: + update_results = [] # Store results + + for package in packages_to_update: + if package == "OptimaLab35": + pkg_info = self.ppu_ol35.update_from_local(dist_folder) + elif package == "optima35": + pkg_info = self.ppu_o35.update_from_local(dist_folder) + + update_results.append(f"{package}: {'Success' if pkg_info[0] else 'Failed'}\n{pkg_info[1]}") + + # Show summary of updates + # Show update completion message + msg = QMessageBox() + msg.setWindowTitle("Update Complete") + msg.setText("\n\n".join(update_results)) + msg.setStandardButtons(QMessageBox.Ok) + msg.exec() + + # Restart the application after user clicks "OK" + #self.ppu_ol35.restart_program() + self.restart_program() def time_to_string(self, time_time): dt_obj = datetime.fromtimestamp(time_time) diff --git a/src/OptimaLab35/ui/updater_window.py b/src/OptimaLab35/ui/updater_window.py index ce1de3c..205fc62 100644 --- a/src/OptimaLab35/ui/updater_window.py +++ b/src/OptimaLab35/ui/updater_window.py @@ -23,22 +23,13 @@ class Ui_Updater_Window(object): if not Updater_Window.objectName(): Updater_Window.setObjectName(u"Updater_Window") Updater_Window.setEnabled(True) - Updater_Window.resize(372, 196) + Updater_Window.resize(336, 200) + Updater_Window.setMinimumSize(QSize(336, 200)) + Updater_Window.setMaximumSize(QSize(340, 300)) self.centralwidget = QWidget(Updater_Window) self.centralwidget.setObjectName(u"centralwidget") self.gridLayout_2 = QGridLayout(self.centralwidget) self.gridLayout_2.setObjectName(u"gridLayout_2") - self.label_last_check = QLabel(self.centralwidget) - self.label_last_check.setObjectName(u"label_last_check") - - self.gridLayout_2.addWidget(self.label_last_check, 0, 0, 1, 1) - - self.label_last_check_2 = QLabel(self.centralwidget) - self.label_last_check_2.setObjectName(u"label_last_check_2") - self.label_last_check_2.setEnabled(True) - - self.gridLayout_2.addWidget(self.label_last_check_2, 0, 1, 1, 1) - self.widget_2 = QWidget(self.centralwidget) self.widget_2.setObjectName(u"widget_2") self.gridLayout = QGridLayout(self.widget_2) @@ -111,9 +102,31 @@ class Ui_Updater_Window(object): self.horizontalLayout.addWidget(self.update_and_restart_Button) + self.check_local_Button = QPushButton(self.widget) + self.check_local_Button.setObjectName(u"check_local_Button") + + self.horizontalLayout.addWidget(self.check_local_Button) + + self.update_local_Button = QPushButton(self.widget) + self.update_local_Button.setObjectName(u"update_local_Button") + + self.horizontalLayout.addWidget(self.update_local_Button) + self.gridLayout_2.addWidget(self.widget, 2, 0, 1, 2) + self.label_last_check = QLabel(self.centralwidget) + self.label_last_check.setObjectName(u"label_last_check") + + self.gridLayout_2.addWidget(self.label_last_check, 0, 0, 1, 1) + + self.label_last_check_2 = QLabel(self.centralwidget) + self.label_last_check_2.setObjectName(u"label_last_check_2") + self.label_last_check_2.setEnabled(True) + self.label_last_check_2.setAlignment(Qt.AlignRight|Qt.AlignTrailing|Qt.AlignVCenter) + + self.gridLayout_2.addWidget(self.label_last_check_2, 0, 1, 1, 1) + Updater_Window.setCentralWidget(self.centralwidget) self.retranslateUi(Updater_Window) @@ -123,8 +136,6 @@ class Ui_Updater_Window(object): def retranslateUi(self, Updater_Window): Updater_Window.setWindowTitle(QCoreApplication.translate("Updater_Window", u"Updater", None)) - self.label_last_check.setText(QCoreApplication.translate("Updater_Window", u"Last update check:", None)) - self.label_last_check_2.setText(QCoreApplication.translate("Updater_Window", u"TextLabel", None)) self.label.setText(QCoreApplication.translate("Updater_Window", u"OptimaLab35", None)) self.label_optima35_localversion.setText(QCoreApplication.translate("Updater_Window", u"0.0.0", None)) self.label_9.setText(QCoreApplication.translate("Updater_Window", u"Package", None)) @@ -136,5 +147,9 @@ class Ui_Updater_Window(object): self.label_2.setText(QCoreApplication.translate("Updater_Window", u"optima35", None)) self.check_for_update_Button.setText(QCoreApplication.translate("Updater_Window", u"Check for update", None)) self.update_and_restart_Button.setText(QCoreApplication.translate("Updater_Window", u"Update and restart", None)) + self.check_local_Button.setText(QCoreApplication.translate("Updater_Window", u"Check local", None)) + self.update_local_Button.setText(QCoreApplication.translate("Updater_Window", u"Update local", None)) + self.label_last_check.setText(QCoreApplication.translate("Updater_Window", u"Last update check:", None)) + self.label_last_check_2.setText(QCoreApplication.translate("Updater_Window", u"TextLabel", None)) # retranslateUi diff --git a/src/OptimaLab35/ui/updater_window.ui b/src/OptimaLab35/ui/updater_window.ui index 9a8d2de..803d2f8 100644 --- a/src/OptimaLab35/ui/updater_window.ui +++ b/src/OptimaLab35/ui/updater_window.ui @@ -9,32 +9,27 @@ 0 0 - 372 - 196 + 336 + 200 + + + 336 + 200 + + + + + 340 + 300 + + Updater - - - - Last update check: - - - - - - - true - - - TextLabel - - - @@ -139,9 +134,43 @@ + + + + Check local + + + + + + + Update local + + + + + + + Last update check: + + + + + + + true + + + TextLabel + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + +