From 1f66f13018cc6d6a61763b347b58c6258367841b Mon Sep 17 00:00:00 2001 From: Thomas Farstrike Date: Mon, 20 Oct 2025 15:27:31 +0200 Subject: [PATCH] Launcher app: improve error handling Previously, a dead symlink would throw an error and prevent the other apps from showing up. --- .../assets/launcher.py | 33 +++++++++++-------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py b/internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py index 2d12f10c..376ec1f0 100644 --- a/internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py +++ b/internal_filesystem/builtin/apps/com.micropythonos.launcher/assets/launcher.py @@ -46,21 +46,26 @@ class Launcher(mpos.apps.Activity): for dir_path in [apps_dir, apps_dir_builtin]: try: if uos.stat(dir_path)[0] & 0x4000: # Verify directory exists - for d in uos.listdir(dir_path): - full_path = f"{dir_path}/{d}" - #print(f"full_path: {full_path}") - if uos.stat(full_path)[0] & 0x4000: # Check if it's a directory - base_name = d - if base_name not in seen_base_names: # Avoid duplicates - seen_base_names.add(base_name) - app = mpos.apps.parse_manifest(f"{full_path}/META-INF/MANIFEST.JSON") - if app.category != "launcher": # Skip launchers - main_launcher = mpos.apps.find_main_launcher_activity(app) - if main_launcher: - app_list.append((app.name, full_path)) + try: + for d in uos.listdir(dir_path): + full_path = f"{dir_path}/{d}" + #print(f"full_path: {full_path}") + try: + if uos.stat(full_path)[0] & 0x4000: # Check if it's a directory + base_name = d + if base_name not in seen_base_names: # Avoid duplicates + seen_base_names.add(base_name) + app = mpos.apps.parse_manifest(f"{full_path}/META-INF/MANIFEST.JSON") + if app.category != "launcher": # Skip launchers + main_launcher = mpos.apps.find_main_launcher_activity(app) + if main_launcher: + app_list.append((app.name, full_path)) + except OSError: + print(f"launcher.py stat of {full_path} got OSError: {e}") + except OSError: + print(f"launcher.py listdir of {dir_path} got OSError: {e}") except OSError: - print(f"launcher.py got OSError: {e}") - pass + print(f"launcher.py stat of {dir_path} got OSError: {e}") import time start = time.ticks_ms()