patch: Tried to patch weird updater bug

This commit is contained in:
Mr Finchum 2025-02-03 15:27:53 +00:00
parent b1d9d3fa5e
commit 630985d70c
5 changed files with 154 additions and 38 deletions

View file

@ -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.

View file

@ -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",
]

View file

@ -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)

View file

@ -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

View file

@ -9,32 +9,27 @@
<rect>
<x>0</x>
<y>0</y>
<width>372</width>
<height>196</height>
<width>336</width>
<height>200</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>336</width>
<height>200</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>340</width>
<height>300</height>
</size>
</property>
<property name="windowTitle">
<string>Updater</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QLabel" name="label_last_check">
<property name="text">
<string>Last update check:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_last_check_2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>TextLabel</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QWidget" name="widget_2" native="true">
<layout class="QGridLayout" name="gridLayout">
@ -139,9 +134,43 @@
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="check_local_Button">
<property name="text">
<string>Check local</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="update_local_Button">
<property name="text">
<string>Update local</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_last_check">
<property name="text">
<string>Last update check:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label_last_check_2">
<property name="enabled">
<bool>true</bool>
</property>
<property name="text">
<string>TextLabel</string>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</widget>
</widget>