Skip to content

Commit bd536ef

Browse files
Fix appstore
1 parent 2ddecee commit bd536ef

1 file changed

Lines changed: 19 additions & 10 deletions

File tree

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

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

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,24 @@ def download_app_index(self, json_url):
6060
return
6161
if response and response.status_code == 200:
6262
print(f"Got response text: {response.text}")
63-
self.apps = [mpos.apps.App(**app) for app in json.loads(response.text)]
64-
response.close()
65-
# Remove duplicates based on app.name
66-
seen = set()
67-
self.apps = [app for app in self.apps if not (app.name in seen or seen.add(app.name))]
68-
# Sort apps by app.name
69-
self.apps.sort(key=lambda x: x.name.lower()) # Use .lower() for case-insensitive sorting
70-
self.please_wait_label.add_flag(lv.obj.FLAG.HIDDEN)
71-
lv.async_call(lambda l: self.create_apps_list(), None)
63+
try:
64+
applist = json.loads(response.text)
65+
for app in json.loads(response.text):
66+
try:
67+
self.apps.append(mpos.apps.App(**app))
68+
except Exception as e:
69+
print(f"Warning: could not add app from {json_url} to apps list: {e}")
70+
# Remove duplicates based on app.name
71+
seen = set()
72+
self.apps = [app for app in self.apps if not (app.name in seen or seen.add(app.name))]
73+
# Sort apps by app.name
74+
self.apps.sort(key=lambda x: x.name.lower()) # Use .lower() for case-insensitive sorting
75+
self.please_wait_label.add_flag(lv.obj.FLAG.HIDDEN)
76+
lv.async_call(lambda l: self.create_apps_list(), None)
77+
except Exception as e:
78+
print(f"ERROR: could not parse reponse.text JSON: {e}")
79+
finally:
80+
response.close()
7281

7382
def create_apps_list(self):
7483
print("create_apps_list")
@@ -112,7 +121,7 @@ def create_apps_list(self):
112121
except Exception as e:
113122
print("Could not start thread to download icons: ", e)
114123

115-
def download_icons():
124+
def download_icons(self):
116125
for app in self.apps:
117126
print(f"Downloading icon for {app.name}")
118127
image_dsc = download_icon(app.icon_url)

0 commit comments

Comments
 (0)