Skip to content

Commit c7c668a

Browse files
AppStore app: improve exception handling
1 parent b54a58a commit c7c668a

File tree

1 file changed

+15
-11
lines changed
  • internal_filesystem/builtin/apps/com.micropythonos.appstore/assets

1 file changed

+15
-11
lines changed

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -61,20 +61,20 @@ def download_app_index(self, json_url):
6161
self.apps.append(App(app["name"], app["publisher"], app["short_description"], app["long_description"], app["icon_url"], app["download_url"], app["fullname"], app["version"], app["category"], app["activities"]))
6262
except Exception as e:
6363
print(f"Warning: could not add app from {json_url} to apps list: {e}")
64-
# Remove duplicates based on app.name
65-
seen = set()
66-
self.apps = [app for app in self.apps if not (app.fullname in seen or seen.add(app.fullname))]
67-
# Sort apps by app.name
68-
self.apps.sort(key=lambda x: x.name.lower()) # Use .lower() for case-insensitive sorting
69-
time.sleep_ms(200)
70-
self.update_ui_threadsafe_if_foreground(self.please_wait_label.add_flag, lv.obj.FLAG.HIDDEN)
71-
self.update_ui_threadsafe_if_foreground(self.create_apps_list)
72-
time.sleep(0.1) # give the UI time to display the app list before starting to download
73-
self.download_icons()
7464
except Exception as e:
7565
print(f"ERROR: could not parse reponse.text JSON: {e}")
7666
finally:
7767
response.close()
68+
# Remove duplicates based on app.name
69+
seen = set()
70+
self.apps = [app for app in self.apps if not (app.fullname in seen or seen.add(app.fullname))]
71+
# Sort apps by app.name
72+
self.apps.sort(key=lambda x: x.name.lower()) # Use .lower() for case-insensitive sorting
73+
time.sleep_ms(200)
74+
self.update_ui_threadsafe_if_foreground(self.please_wait_label.add_flag, lv.obj.FLAG.HIDDEN)
75+
self.update_ui_threadsafe_if_foreground(self.create_apps_list)
76+
time.sleep(0.1) # give the UI time to display the app list before starting to download
77+
self.download_icons()
7878

7979
def create_apps_list(self):
8080
print("create_apps_list")
@@ -129,7 +129,11 @@ def download_icons(self):
129129
app.icon_data = self.download_icon_data(app.icon_url)
130130
if app.icon_data:
131131
print("download_icons has icon_data, showing it...")
132-
image_icon_widget = app.image_icon_widget
132+
image_icon_widget = None
133+
try:
134+
image_icon_widget = app.image_icon_widget
135+
except Exception as e:
136+
print(f"app.image_icon_widget got exception {e}")
133137
if image_icon_widget:
134138
image_dsc = lv.image_dsc_t({
135139
'data_size': len(app.icon_data),

0 commit comments

Comments
 (0)