List apps on sd
This commit is contained in:
parent
35583bf004
commit
35427b0db6
1 changed files with 36 additions and 29 deletions
65
src/code.py
65
src/code.py
|
|
@ -175,46 +175,53 @@ scaled_group.append(menu_title_txt)
|
||||||
|
|
||||||
app_titles = []
|
app_titles = []
|
||||||
apps = []
|
apps = []
|
||||||
app_path = pathlib.Path("/apps")
|
app_paths = (
|
||||||
|
pathlib.Path("/apps"),
|
||||||
|
pathlib.Path("/sd/apps")
|
||||||
|
)
|
||||||
|
|
||||||
pages = [{}]
|
pages = [{}]
|
||||||
|
|
||||||
cur_file_index = 0
|
cur_file_index = 0
|
||||||
|
|
||||||
for path in app_path.iterdir():
|
for app_path in app_paths:
|
||||||
print(path)
|
if not app_path.exists():
|
||||||
|
|
||||||
code_file = path / "code.py"
|
|
||||||
if not code_file.exists():
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
for path in app_path.iterdir():
|
||||||
|
print(path)
|
||||||
|
|
||||||
metadata_file = path / "metadata.json"
|
code_file = path / "code.py"
|
||||||
if not metadata_file.exists():
|
if not code_file.exists():
|
||||||
metadata_file = None
|
continue
|
||||||
metadata = None
|
|
||||||
if metadata_file is not None:
|
|
||||||
with open(metadata_file.absolute(), "r") as f:
|
|
||||||
metadata = json.load(f)
|
|
||||||
|
|
||||||
if metadata is not None and "icon" in metadata:
|
metadata_file = path / "metadata.json"
|
||||||
icon_file = path / metadata["icon"]
|
if not metadata_file.exists():
|
||||||
else:
|
metadata_file = None
|
||||||
icon_file = path / "icon.bmp"
|
metadata = None
|
||||||
|
if metadata_file is not None:
|
||||||
|
with open(metadata_file.absolute(), "r") as f:
|
||||||
|
metadata = json.load(f)
|
||||||
|
|
||||||
if not icon_file.exists():
|
if metadata is not None and "icon" in metadata:
|
||||||
icon_file = None
|
icon_file = path / metadata["icon"]
|
||||||
|
else:
|
||||||
|
icon_file = path / "icon.bmp"
|
||||||
|
|
||||||
if metadata is not None and "title" in metadata:
|
if not icon_file.exists():
|
||||||
title = metadata["title"]
|
icon_file = None
|
||||||
else:
|
|
||||||
title = path.name
|
|
||||||
|
|
||||||
apps.append({
|
if metadata is not None and "title" in metadata:
|
||||||
"title": title,
|
title = metadata["title"]
|
||||||
"icon": str(icon_file.absolute()) if icon_file is not None else None,
|
else:
|
||||||
"file": str(code_file.absolute()),
|
title = path.name
|
||||||
"dir": path
|
|
||||||
})
|
apps.append({
|
||||||
|
"title": title,
|
||||||
|
"icon": str(icon_file.absolute()) if icon_file is not None else None,
|
||||||
|
"file": str(code_file.absolute()),
|
||||||
|
"dir": path
|
||||||
|
})
|
||||||
|
|
||||||
apps = sorted(apps, key=lambda app: app["title"].lower())
|
apps = sorted(apps, key=lambda app: app["title"].lower())
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue