Skip to content

Commit

Permalink
Merge branch 'main' into imu
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisDick committed May 31, 2024
2 parents aecc042 + e8d716a commit ce22944
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 20 deletions.
9 changes: 4 additions & 5 deletions modules/firmware_apps/app_store.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -383,5 +381,6 @@ def connect_wifi():
while True:
print("Connecting to")
print(f"{ssid}...")
if wifi.wait():
break

# if wifi.wait():
# break
26 changes: 11 additions & 15 deletions modules/system/launcher/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -138,12 +134,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))
Expand Down

0 comments on commit ce22944

Please sign in to comment.