Skip to content

Commit 6a4f6da

Browse files
appstore: better error handling
1 parent dbda2dc commit 6a4f6da

File tree

1 file changed

+10
-5
lines changed
  • internal_filesystem/builtin/apps/com.example.appstore/assets

1 file changed

+10
-5
lines changed

internal_filesystem/builtin/apps/com.example.appstore/assets/appstore.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ def download_and_unzip(zip_url, dest_folder, app_fullname):
194194
time.sleep_ms(500)
195195
response.close()
196196
print("Downloaded .mpk file, size:", os.stat(temp_zip_path)[6], "bytes")
197+
except Exception as e:
198+
print("Download failed:", str(e))
199+
# Would be good to show error message here if it fails...
200+
finally:
201+
if 'response' in locals():
202+
response.close()
203+
try:
197204
# Step 2: Unzip the file
198205
if zipfile is None:
199206
print("WARNING: zipfile module not available in this MicroPython build, unzip will fail!")
@@ -207,11 +214,9 @@ def download_and_unzip(zip_url, dest_folder, app_fullname):
207214
os.remove(temp_zip_path)
208215
print("Removed temporary .mpk file")
209216
except Exception as e:
210-
print("Operation failed:", str(e))
211-
finally:
212-
if 'response' in locals():
213-
response.close()
214-
progress_bar.set_value(80, lv.ANIM.OFF)
217+
print(f"Unzip and cleanup failed: {e}")
218+
# Would be good to show error message here if it fails...
219+
# Success:
215220
progress_bar.set_value(100, lv.ANIM.OFF)
216221
time.sleep(1)
217222
progress_bar.add_flag(lv.obj.FLAG.HIDDEN)

0 commit comments

Comments
 (0)