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
b21dd3a2
Commit
b21dd3a2
authored
3 months ago
by
KERDREUX Jerome
Browse files
Options
Downloads
Patches
Plain Diff
Remove remote-console
Oups
parent
c71b4a5d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
libs/lib/xaal/lib/aioengine.py
+13
-8
13 additions, 8 deletions
libs/lib/xaal/lib/aioengine.py
libs/lib/xaal/lib/core.py
+2
-2
2 additions, 2 deletions
libs/lib/xaal/lib/core.py
with
15 additions
and
10 deletions
libs/lib/xaal/lib/aioengine.py
+
13
−
8
View file @
b21dd3a2
...
...
@@ -36,7 +36,7 @@ class HookType(Enum):
class
Hook
(
object
):
__slots__
=
[
'
type
'
,
'
func
'
,
'
args
'
,
'
kwargs
'
]
def
__init__
(
self
,
type_
:
HookType
,
func
:
core
.
FuncT
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
type_
:
HookType
,
func
:
core
.
FuncT
,
*
args
,
**
kwargs
):
# func has to be a callable, but it can be a coroutine or a function
self
.
type
=
type_
self
.
func
=
func
...
...
@@ -58,7 +58,8 @@ class AsyncEngine(core.EngineMixin):
]
def
__init__
(
self
,
address
:
str
=
config
.
address
,
port
:
int
=
config
.
port
,
hops
:
int
=
config
.
hops
,
key
:
bytes
=
config
.
key
):
self
,
address
:
str
=
config
.
address
,
port
:
int
=
config
.
port
,
hops
:
int
=
config
.
hops
,
key
:
bytes
=
config
.
key
):
core
.
EngineMixin
.
__init__
(
self
,
address
,
port
,
hops
,
key
)
self
.
__txFifo
=
asyncio
.
Queue
()
# tx msg fifo
...
...
@@ -167,7 +168,7 @@ class AsyncEngine(core.EngineMixin):
async
def
handle_action_request
(
self
,
msg
:
'
Message
'
,
target
:
'
Device
'
):
if
msg
.
action
is
None
:
return
# should not happen, but pyright need this check
return
# should not happen, but pyright need this check
try
:
result
=
await
run_action
(
msg
,
target
)
...
...
@@ -250,7 +251,8 @@ class AsyncEngine(core.EngineMixin):
self
.
new_task
(
self
.
receive_task
(),
name
=
'
RecvQ
'
)
self
.
new_task
(
self
.
send_task
(),
name
=
'
SendQ
'
)
self
.
new_task
(
self
.
timer_task
(),
name
=
'
Timers
'
)
self
.
new_task
(
console
(
locals
()),
name
=
'
Console
'
)
if
config
.
remote_console
:
self
.
new_task
(
console
(
locals
()),
name
=
'
Console
'
)
def
setup_alives_timer
(
self
):
# needed on stop-start sequence
...
...
@@ -259,7 +261,7 @@ class AsyncEngine(core.EngineMixin):
# process alives every 10 seconds
self
.
add_timer
(
self
.
process_alives
,
10
)
async
def
stop
(
self
):
# pyright: ignore
async
def
stop
(
self
):
# pyright: ignore
logger
.
info
(
"
Stopping engine
"
)
await
self
.
run_hooks
(
HookType
.
stop
)
self
.
running_event
.
clear
()
...
...
@@ -340,7 +342,7 @@ class AsyncEngine(core.EngineMixin):
self
.
dump_hooks
()
def
get_device
(
self
,
uuid
:
UUID
)
->
Optional
[
'
Device
'
]:
# TODO:Check if this method is usefull
# TODO:Check if this method is usefull
for
dev
in
self
.
devices
:
if
dev
.
address
==
uuid
:
return
dev
...
...
@@ -391,7 +393,8 @@ async def console(locals=locals(), port: Optional[int] = None):
# let's find a free port if not specified
def
find_free_port
():
import
socketserver
with
socketserver
.
TCPServer
((
'
localhost
'
,
0
),
None
)
as
s
:
# pyright: ignore pyright reject the None here
with
socketserver
.
TCPServer
((
'
localhost
'
,
0
),
None
)
as
s
:
# pyright: ignore pyright reject the None here
return
s
.
server_address
[
1
]
port
=
find_free_port
()
...
...
@@ -407,6 +410,8 @@ async def console(locals=locals(), port: Optional[int] = None):
# start the console
try
:
# debian with ipv6 disabled still state that localhost is ::1, which broke aioconsole
await
aioconsole
.
start_interactive_server
(
host
=
"
127.0.0.1
"
,
port
=
port
,
factory
=
factory
,
banner
=
banner
)
# pyright: ignore
await
aioconsole
.
start_interactive_server
(
host
=
"
127.0.0.1
"
,
port
=
port
,
factory
=
factory
,
banner
=
banner
)
# pyright: ignore
except
OSError
:
logger
.
warning
(
"
Unable to run console
"
)
This diff is collapsed.
Click to expand it.
libs/lib/xaal/lib/core.py
+
2
−
2
View file @
b21dd3a2
...
...
@@ -56,7 +56,7 @@ class EngineMixin(object):
__slots__
=
[
'
devices
'
,
'
timers
'
,
'
subscribers
'
,
'
msg_filter
'
,
'
_attributesChange
'
,
'
network
'
,
'
msg_factory
'
]
def
__init__
(
self
,
address
:
str
,
port
:
int
,
hops
:
int
,
key
:
bytes
):
self
.
devices
:
list
[
Device
]
=
[]
# list of devices / use (un)register_devices()
self
.
devices
:
list
[
Device
]
=
[]
# list of devices / use (un)register_devices()
self
.
timers
:
list
[
Timer
]
=
[]
# functions to call periodic
self
.
subscribers
:
list
[
SubFuncT
]
=
[]
# message receive workflow
self
.
msg_filter
=
None
# message filter
...
...
@@ -134,7 +134,7 @@ class EngineMixin(object):
self
.
queue_msg
(
msg
)
dev
.
update_alive
()
def
send_is_alive
(
self
,
dev
:
'
Device
'
,
targets
:
list
=
[
ALIVE_ADDR
,
],
dev_types
:
list
=
[
"
any.any
"
,
]
):
def
send_is_alive
(
self
,
dev
:
'
Device
'
,
targets
:
list
=
[
ALIVE_ADDR
],
dev_types
:
list
=
[
"
any.any
"
]
):
"""
Send a is_alive message, w/ dev_types filtering
"""
body
=
{
'
dev_types
'
:
dev_types
}
self
.
send_request
(
dev
,
targets
,
MessageAction
.
IS_ALIVE
.
value
,
body
)
...
...
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