From e27227c734265e1b02e4af37aae5834a50bec125 Mon Sep 17 00:00:00 2001 From: Matthew Wilkes Date: Fri, 31 May 2024 11:44:33 +0100 Subject: [PATCH 1/2] Revert "Fix launch bug" This reverts commit efd1975358ab0b4c26cd3ec8964bbea37aa2761d. --- modules/system/launcher/app.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/system/launcher/app.py b/modules/system/launcher/app.py index 3af26b4..51e19ab 100644 --- a/modules/system/launcher/app.py +++ b/modules/system/launcher/app.py @@ -138,12 +138,12 @@ def update_menu(self): def launch(self, item): module_name = item["path"] fn = item["callable"] - app_id = f"apps.{module_name}.app" + app_id = f"{module_name}.{fn}" app = self._apps.get(app_id) print(self._apps) if app is None: print(f"Creating app {app_id}...") - module = __import__(app_id, None, None, (fn,)) + module = __import__(module_name, None, None, (fn,)) app = getattr(module, fn)() self._apps[app_id] = app eventbus.emit(RequestStartAppEvent(app, foreground=True)) From e8d716ad249e77833d2ef2865fb29c304a85203c Mon Sep 17 00:00:00 2001 From: Matthew Wilkes Date: Fri, 31 May 2024 12:14:46 +0100 Subject: [PATCH 2/2] Fixes for on-app launching This may not be working on the simulator, can someone check before merging? --- modules/firmware_apps/app_store.py | 9 ++++----- modules/system/launcher/app.py | 22 +++++++++------------- 2 files changed, 13 insertions(+), 18 deletions(-) diff --git a/modules/firmware_apps/app_store.py b/modules/firmware_apps/app_store.py index 58c794b..0f9775f 100644 --- a/modules/firmware_apps/app_store.py +++ b/modules/firmware_apps/app_store.py @@ -335,13 +335,11 @@ def install_app(app): file.write(data) internal_manifest = { - "path": prefix + ".app", - "callable": "__app_export__", "name": app["manifest"]["app"]["name"], "hidden": False, } with open( - os.path.join(APP_DIR, prefix, "__internal__metadata.json"), "w+" + os.path.join(APP_DIR, prefix, "app_data.json"), "w+" ) as internal_manifest_file_handler: json.dump(internal_manifest, internal_manifest_file_handler) @@ -383,5 +381,6 @@ def connect_wifi(): while True: print("Connecting to") print(f"{ssid}...") - if wifi.wait(): - break + + # if wifi.wait(): + # break diff --git a/modules/system/launcher/app.py b/modules/system/launcher/app.py index 51e19ab..39ec815 100644 --- a/modules/system/launcher/app.py +++ b/modules/system/launcher/app.py @@ -41,12 +41,9 @@ def recursive_delete(path): os.rmdir(path) -def load_info(folder, name, sim): +def load_info(folder, name): try: - if sim: - info_file = "{}/{}/metadata.json".format(folder, name) - else: - info_file = "{}/{}/__internal__metadata.json".format(folder, name) + info_file = "{}/{}/metadata.json".format(folder, name) with open(info_file) as f: information = f.read() return json.loads(information) @@ -61,21 +58,20 @@ def list_user_apps(): contents = os.listdir(APP_DIR) except OSError: # No apps dir full stop + try: + os.mkdir(APP_DIR) + except OSError: + pass return [] for name in contents: - sim = path_isfile(f"{APP_DIR}/{name}/__init__.py") - store = path_isfile(f"{APP_DIR}/{name}/app.py") - if not sim and not store: - continue - app = { - "path": name, - "callable": "main", + "path": f"apps.{name}.app", + "callable": "__app_export__", "name": name, "hidden": False, } - metadata = load_info(APP_DIR, name, sim) + metadata = load_info(APP_DIR, name) app.update(metadata) if not app["hidden"]: apps.append(app)