Skip to content

Commit 1f66f13

Browse files
Launcher app: improve error handling
Previously, a dead symlink would throw an error and prevent the other apps from showing up.
1 parent 2932f37 commit 1f66f13

File tree

1 file changed

+19
-14
lines changed
  • internal_filesystem/builtin/apps/com.micropythonos.launcher/assets

1 file changed

+19
-14
lines changed

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

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,26 @@ def onResume(self, screen):
4646
for dir_path in [apps_dir, apps_dir_builtin]:
4747
try:
4848
if uos.stat(dir_path)[0] & 0x4000: # Verify directory exists
49-
for d in uos.listdir(dir_path):
50-
full_path = f"{dir_path}/{d}"
51-
#print(f"full_path: {full_path}")
52-
if uos.stat(full_path)[0] & 0x4000: # Check if it's a directory
53-
base_name = d
54-
if base_name not in seen_base_names: # Avoid duplicates
55-
seen_base_names.add(base_name)
56-
app = mpos.apps.parse_manifest(f"{full_path}/META-INF/MANIFEST.JSON")
57-
if app.category != "launcher": # Skip launchers
58-
main_launcher = mpos.apps.find_main_launcher_activity(app)
59-
if main_launcher:
60-
app_list.append((app.name, full_path))
49+
try:
50+
for d in uos.listdir(dir_path):
51+
full_path = f"{dir_path}/{d}"
52+
#print(f"full_path: {full_path}")
53+
try:
54+
if uos.stat(full_path)[0] & 0x4000: # Check if it's a directory
55+
base_name = d
56+
if base_name not in seen_base_names: # Avoid duplicates
57+
seen_base_names.add(base_name)
58+
app = mpos.apps.parse_manifest(f"{full_path}/META-INF/MANIFEST.JSON")
59+
if app.category != "launcher": # Skip launchers
60+
main_launcher = mpos.apps.find_main_launcher_activity(app)
61+
if main_launcher:
62+
app_list.append((app.name, full_path))
63+
except OSError:
64+
print(f"launcher.py stat of {full_path} got OSError: {e}")
65+
except OSError:
66+
print(f"launcher.py listdir of {dir_path} got OSError: {e}")
6167
except OSError:
62-
print(f"launcher.py got OSError: {e}")
63-
pass
68+
print(f"launcher.py stat of {dir_path} got OSError: {e}")
6469

6570
import time
6671
start = time.ticks_ms()

0 commit comments

Comments
 (0)