From ffb2eb1c09dc9680c7351351a69636735f3cd9ee Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Tue, 14 Oct 2025 21:10:26 +0200 Subject: [PATCH] OSUpdate: improve failed update feedback --- .../assets/osupdate.py | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets/osupdate.py b/internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets/osupdate.py index 02895435..c14260a6 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets/osupdate.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets/osupdate.py @@ -184,13 +184,23 @@ class OSUpdate(Activity): if total_size: self.progress_callback(bytes_written / total_size * 100) response.close() - if bytes_written >= total_size and not simulate: # if the update was completely installed - next_partition.set_boot() - import machine - machine.reset() - # In case it didn't reset: - lv.async_call(lambda l: self.status_label.set_text("Update finished! Please restart."), None) - # self.install_button stays disabled to prevent the user from downloading an update twice + try: + if bytes_written >= total_size: + if not simulate: # if the update was completely installed + next_partition.set_boot() + import machine + machine.reset() + # In case it didn't reset: + lv.async_call(lambda l: self.status_label.set_text("Update finished! Please restart."), None) + # self.install_button stays disabled to prevent the user from installing the same update twice + else: + print("This is an OSUpdate simulation, not attempting to restart the device.") + else: + lv.async_call(lambda l: self.status_label.set_text(f"Wrote {bytes_written} < {total_size} so not enough!"), None) + self.install_button.remove_state(lv.STATE.DISABLED) # allow retry + except Exception as e: + lv.async_call(lambda l: self.status_label.set_text(f"Update error: {e}"), None) + self.install_button.remove_state(lv.STATE.DISABLED) # allow retry # Non-class functions: