Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
PetePriority
firmware
Commits
eca5177f
Commit
eca5177f
authored
Aug 21, 2019
by
Renze
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add listing of ELF files
parent
8c0200dd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
3 deletions
+17
-3
preload/menu.py
preload/menu.py
+17
-3
No files found.
preload/menu.py
View file @
eca5177f
...
...
@@ -12,6 +12,16 @@ import os
import
ujson
import
sys
def
create_folders
():
try
:
os
.
mkdir
(
"/apps"
)
except
:
pass
try
:
os
.
mkdir
(
"/elf"
)
except
:
pass
def
read_metadata
(
app_folder
):
try
:
info_file
=
"/apps/%s/metadata.json"
%
(
app_folder
)
...
...
@@ -28,11 +38,14 @@ def list_apps():
apps
=
[]
for
appFolder
in
appFolders
:
apps
.
append
([
appFolder
,
read_metadata
(
appFolder
)])
apps
.
append
([
"/apps/%s/__init__.py"
%
appFolder
,
read_metadata
(
appFolder
)])
for
elfFile
in
sorted
(
os
.
listdir
(
"/elf"
)):
if
elfFile
.
endswith
(
".elf"
):
apps
.
append
([
"/elf/%s"
%
elfFile
,
{
'author'
:
''
,
'name'
:
"ELF: "
+
elfFile
[:
-
4
],
'description'
:
''
,
'category'
:
''
,
'revision'
:
0
}])
return
apps
def
button_events
():
"""Iterate over button presses (event-loop)."""
yield
0
...
...
@@ -75,6 +88,7 @@ def draw_menu(disp, applist, idx, offset):
def
main
():
create_folders
()
disp
=
display
.
open
()
applist
=
list_apps
()
numapps
=
len
(
applist
)
...
...
@@ -112,7 +126,7 @@ def main():
disp
.
clear
().
update
()
disp
.
close
()
try
:
os
.
exec
(
"/apps/%s/__init__.py"
%
applist
[
current
][
0
])
os
.
exec
(
applist
[
current
][
0
])
except
OSError
as
e
:
print
(
"Loading failed: "
,
e
)
os
.
exit
(
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment