Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
flow3r firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
flow3r
flow3r firmware
Commits
1e6b42dc
Commit
1e6b42dc
authored
1 year ago
by
q3k
Committed by
q3k
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
py: show exception if app failed to load
parent
6373baa5
No related branches found
No related tags found
1 merge request
!188
Q3k/fancy 1.2 features
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
python_payload/st3m/application.py
+63
-0
63 additions, 0 deletions
python_payload/st3m/application.py
with
63 additions
and
0 deletions
python_payload/st3m/application.py
+
63
−
0
View file @
1e6b42dc
...
...
@@ -8,12 +8,14 @@ from st3m.ui.menu import MenuItem
from
st3m.input
import
InputState
from
st3m.goose
import
Optional
,
List
,
Enum
,
Dict
from
st3m.logging
import
Log
from
ctx
import
Context
import
toml
import
os
import
os.path
import
stat
import
sys
import
random
log
=
Log
(
__name__
)
...
...
@@ -52,6 +54,7 @@ class BundleLoadException(BaseException):
res
=
self
.
MSG
if
msg
is
not
None
:
res
+=
"
:
"
+
msg
self
.
msg
=
res
super
().
__init__
(
res
)
...
...
@@ -213,6 +216,64 @@ class BundleMetadata:
return
f
"
<BundleMetadata:
{
self
.
id
}
at
{
self
.
path
}
>
"
class
LoadErrorView
(
BaseView
):
def
__init__
(
self
,
e
:
BundleLoadException
)
->
None
:
super
().
__init__
()
self
.
e
=
e
self
.
header
=
"
oh no
"
def
on_enter
(
self
,
vm
:
Optional
[
ViewManager
])
->
None
:
self
.
header
=
random
.
choice
(
[
"
oh no
"
,
"
aw shucks
"
,
"
whoopsie
"
,
"
ruh-roh
"
,
"
aw crud
"
,
]
)
def
think
(
self
,
ins
:
InputState
,
delta_ms
:
int
)
->
None
:
pass
def
draw
(
self
,
ctx
:
Context
)
->
None
:
ctx
.
rgb
(
0.8
,
0.1
,
0.1
)
ctx
.
rectangle
(
-
120
,
-
120
,
240
,
240
)
ctx
.
fill
()
ctx
.
gray
(
1
)
ctx
.
font_size
=
20
ctx
.
font
=
"
Camp Font 1
"
ctx
.
text_align
=
ctx
.
MIDDLE
ctx
.
move_to
(
0
,
-
70
)
ctx
.
text
(
self
.
header
)
lines
:
List
[
List
[
str
]]
=
[]
msg
=
self
.
e
.
msg
for
word
in
msg
.
split
():
if
len
(
lines
)
==
0
:
lines
.
append
([
word
])
continue
lastline
=
lines
[
-
1
][:]
lastline
.
append
(
word
)
if
sum
(
len
(
l
)
for
l
in
lastline
)
+
len
(
lastline
)
-
1
>
30
:
lines
.
append
([
word
])
else
:
lines
[
-
1
].
append
(
word
)
ctx
.
gray
(
0
)
ctx
.
rectangle
(
-
120
,
-
60
,
240
,
240
).
fill
()
y
=
-
40
ctx
.
gray
(
1
)
ctx
.
font_size
=
15
ctx
.
font
=
"
Arimo Regular
"
ctx
.
text_align
=
ctx
.
LEFT
for
line
in
lines
:
ctx
.
move_to
(
-
90
,
y
)
ctx
.
text
(
"
"
.
join
(
line
))
y
+=
15
class
MenuItemAppLaunch
(
MenuItem
):
"""
A MenuItem which launches an app from a BundleMetadata.
...
...
@@ -234,6 +295,8 @@ class MenuItemAppLaunch(MenuItem):
self
.
_instance
=
self
.
_bundle
.
load
()
except
BundleLoadException
as
e
:
log
.
error
(
f
"
Could not load
{
self
.
label
()
}
:
{
e
}
"
)
err
=
LoadErrorView
(
e
)
vm
.
push
(
err
)
return
assert
self
.
_instance
is
not
None
vm
.
push
(
self
.
_instance
,
ViewTransitionSwipeLeft
())
...
...
This diff is collapsed.
Click to expand it.
q3k
@q3k
mentioned in issue
#61 (closed)
·
1 year ago
mentioned in issue
#61 (closed)
mentioned in issue #61
Toggle commit list
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment