Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Python
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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
xAAL
Code
Python
Commits
f50ee7ec
Commit
f50ee7ec
authored
4 months ago
by
KERDREUX Jerome
Browse files
Options
Downloads
Patches
Plain Diff
Remove most pyright errors
Should be ok
parent
92731288
No related branches found
No related tags found
1 merge request
!1
First try of type hints
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
apps/tools/xaal/tools/toolbox.py
+9
-23
9 additions, 23 deletions
apps/tools/xaal/tools/toolbox.py
with
9 additions
and
23 deletions
apps/tools/xaal/tools/toolbox.py
+
9
−
23
View file @
f50ee7ec
...
...
@@ -43,18 +43,7 @@ DB_DEV_TYPE = "metadatadb.basic"
class
Colors
(
enum
.
Enum
):
DEFAULT
=
fore
.
WHITE
# ALIVE = fore.LIGHT_GRAY
# ATTRIBUTS = fore.LIGHT_YELLOW
# REQUEST = fore.LIGHT_RED
# IS_ALIVE = fore.LIGHT_MAGENTA
# REPLY = fore.LIGHT_CYAN
# NOTIFY = fore.LIGHT_GREEN
# DEV_TYPE = fore.LIGHT_BLUE
# ADDR = fore.LIGHT_RED
# INFO = fore.CYAN
# DB = fore.SPRING_GREEN_1
ALIVE
=
fore
.
LIGHT_GRAY
ALIVE
=
fore
.
LIGHT_GRAY
ATTRIBUTS
=
fore
.
YELLOW
REQUEST
=
fore
.
RED
IS_ALIVE
=
fore
.
MAGENTA
...
...
@@ -148,7 +137,7 @@ class DeviceInfo(object):
r
.
append
([
k
,
v
])
# attributes
if
len
(
self
.
attributes
)
>
0
:
if
self
.
attributes
and
len
(
self
.
attributes
)
>
0
:
# tabulate has no minimal width so used this trick
r
.
append
([
'
-
'
*
22
,
'
-
'
*
46
])
r
.
append
([
'
Attributes
'
,
''
])
...
...
@@ -172,9 +161,6 @@ class DeviceInfo(object):
class
ToolboxHelper
(
object
):
def
__init__
(
self
)
->
None
:
self
.
name
=
None
# cmdline name
self
.
parser
=
None
self
.
engine
=
None
# toolbox engine
self
.
device
=
None
# current device
self
.
devices
=
[]
# devices list (alive / walker)
# idle detector / force exit
self
.
exit_event
=
asyncio
.
Event
()
...
...
@@ -311,7 +297,7 @@ class ToolboxHelper(object):
print
(
color_value
,
end
=
''
)
msg
.
dump
()
if
color
:
print
(
style
.
RESET
,
end
=
''
)
print
(
style
.
RESET
,
end
=
''
)
# pyright: ignore
def
color_for_msg
(
self
,
msg
):
color_value
=
Colors
.
DEFAULT
...
...
@@ -420,8 +406,9 @@ class ToolboxHelper(object):
def
run_until_timeout
(
self
,
timeout
=
3
):
"""
run the engine until timeout
"""
self
.
engine
.
add_timer
(
self
.
quit
,
timeout
)
self
.
engine
.
run
()
if
self
.
engine
:
self
.
engine
.
add_timer
(
self
.
quit
,
timeout
)
self
.
engine
.
run
()
def
run_until_idle
(
self
):
self
.
engine
.
new_task
(
self
.
idle_detector
())
...
...
@@ -448,7 +435,7 @@ class ToolboxHelper(object):
def
colorize
(
color
,
text
):
return
f
"
{
color
}{
text
}{
style
.
RESET
}
"
return
f
"
{
color
}{
text
}{
style
.
RESET
}
"
# pyright: ignore
def
now
():
...
...
@@ -671,7 +658,7 @@ def log():
color_value
=
Colors
.
REPLY
if
color
:
dump
=
f
"
{
Colors
.
DEFAULT
}{
time
.
ctime
()
}
{
Colors
.
ADDR
}{
msg
.
source
}
{
Colors
.
DEV_TYPE
}{
msg
.
dev_type
}
\t
{
color_value
}{
msg
.
action
}
{
msg
.
body
}{
style
.
RESET
}
"
dump
=
f
"
{
Colors
.
DEFAULT
}{
time
.
ctime
()
}
{
Colors
.
ADDR
}{
msg
.
source
}
{
Colors
.
DEV_TYPE
}{
msg
.
dev_type
}
\t
{
color_value
}{
msg
.
action
}
{
msg
.
body
}{
style
.
RESET
}
"
# pyright: ignore
else
:
dump
=
f
"
{
time
.
ctime
()
}
{
msg
.
source
}
{
msg
.
dev_type
}
\t
{
msg
.
action
}
{
msg
.
body
}
"
print
(
dump
)
...
...
@@ -979,7 +966,7 @@ def shell():
print
(
"
$ pip install ipython
\n
"
)
exit
(
1
)
# for a unknown reason, watchdog_task raise a RuntimeError:
# for a unknown reason, watchdog_task raise a RuntimeError:
# "Event loop is closed" on the shell exit. To avoid issue
# we need to stop all tasks.
async
def
on_stop
():
...
...
@@ -1012,4 +999,3 @@ def shell():
print
(
"
* Ending Engine
"
)
eng
.
shutdown
()
print
(
"
* Bye bye
"
)
This diff is collapsed.
Click to expand it.
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