From 13a3b1fe306d9a959148edbeda836b11aad916a5 Mon Sep 17 00:00:00 2001 From: Max Gaukler Date: Thu, 28 Dec 2023 23:43:37 +0100 Subject: [PATCH] FIX auto reboot: only ask user if a restart is needed, not always --- FabLabKasse/gui.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/FabLabKasse/gui.py b/FabLabKasse/gui.py index 198c40e..a00bf81 100755 --- a/FabLabKasse/gui.py +++ b/FabLabKasse/gui.py @@ -333,6 +333,18 @@ def autoRebootOnUpdates(self): Assumption: This function is only called directly after a successful payment, before the user has any chance to add new things to the cart or even start a new payment. """ + + # Determine if reboot/restart is needed + if os.path.isfile("/var/run/reboot-required"): + restart_type = "reboot" + elif time.monotonic() > self.startup_time + 48 * 3600: + restart_type = "restart" + else: + restart_type = None + + if restart_type is None: + return + dialog = QtWidgets.QMessageBox(self) dialog.setWindowModality(QtCore.Qt.WindowModal) dialog.setText( @@ -344,10 +356,8 @@ def autoRebootOnUpdates(self): dialog.setEscapeButton(QtWidgets.QMessageBox.Cancel) if dialog.exec_() != QtWidgets.QMessageBox.Ok: return - if os.path.isfile("/var/run/reboot-required"): - self.do_restart("reboot") - elif time.monotonic() > self.startup_time + 48 * 3600: - self.do_restart("restart") + + self.do_restart(restart_type) def serviceMode(self): """was the service mode enabled recently? check and disable again"""