Skip to content

Commit ffb2eb1

Browse files
OSUpdate: improve failed update feedback
1 parent 29f316f commit ffb2eb1

File tree

1 file changed

+17
-7
lines changed
  • internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets

1 file changed

+17
-7
lines changed

internal_filesystem/builtin/apps/com.micropythonos.osupdate/assets/osupdate.py

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,23 @@ def update_with_lvgl(self, url):
184184
if total_size:
185185
self.progress_callback(bytes_written / total_size * 100)
186186
response.close()
187-
if bytes_written >= total_size and not simulate: # if the update was completely installed
188-
next_partition.set_boot()
189-
import machine
190-
machine.reset()
191-
# In case it didn't reset:
192-
lv.async_call(lambda l: self.status_label.set_text("Update finished! Please restart."), None)
193-
# self.install_button stays disabled to prevent the user from downloading an update twice
187+
try:
188+
if bytes_written >= total_size:
189+
if not simulate: # if the update was completely installed
190+
next_partition.set_boot()
191+
import machine
192+
machine.reset()
193+
# In case it didn't reset:
194+
lv.async_call(lambda l: self.status_label.set_text("Update finished! Please restart."), None)
195+
# self.install_button stays disabled to prevent the user from installing the same update twice
196+
else:
197+
print("This is an OSUpdate simulation, not attempting to restart the device.")
198+
else:
199+
lv.async_call(lambda l: self.status_label.set_text(f"Wrote {bytes_written} < {total_size} so not enough!"), None)
200+
self.install_button.remove_state(lv.STATE.DISABLED) # allow retry
201+
except Exception as e:
202+
lv.async_call(lambda l: self.status_label.set_text(f"Update error: {e}"), None)
203+
self.install_button.remove_state(lv.STATE.DISABLED) # allow retry
194204

195205
# Non-class functions:
196206

0 commit comments

Comments
 (0)