xaal.lib 0.7.9__py3-none-any.whl → 0.7.11__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- xaal/lib/aioengine.py +13 -9
- xaal/lib/core.py +2 -2
- xaal/lib/helpers.py +3 -4
- {xaal.lib-0.7.9.dist-info → xaal.lib-0.7.11.dist-info}/METADATA +2 -2
- {xaal.lib-0.7.9.dist-info → xaal.lib-0.7.11.dist-info}/RECORD +7 -7
- {xaal.lib-0.7.9.dist-info → xaal.lib-0.7.11.dist-info}/WHEEL +1 -1
- {xaal.lib-0.7.9.dist-info → xaal.lib-0.7.11.dist-info}/top_level.txt +0 -0
xaal/lib/aioengine.py
CHANGED
|
@@ -36,7 +36,7 @@ class HookType(Enum):
|
|
|
36
36
|
class Hook(object):
|
|
37
37
|
__slots__ = ['type', 'func', 'args', 'kwargs']
|
|
38
38
|
|
|
39
|
-
def __init__(self, type_:HookType, func: core.FuncT, *args, **kwargs):
|
|
39
|
+
def __init__(self, type_: HookType, func: core.FuncT, *args, **kwargs):
|
|
40
40
|
# func has to be a callable, but it can be a coroutine or a function
|
|
41
41
|
self.type = type_
|
|
42
42
|
self.func = func
|
|
@@ -58,7 +58,8 @@ class AsyncEngine(core.EngineMixin):
|
|
|
58
58
|
]
|
|
59
59
|
|
|
60
60
|
def __init__(
|
|
61
|
-
self, address: str = config.address, port: int = config.port, hops: int = config.hops, key: bytes = config.key
|
|
61
|
+
self, address: str = config.address, port: int = config.port, hops: int = config.hops, key: bytes = config.key
|
|
62
|
+
):
|
|
62
63
|
core.EngineMixin.__init__(self, address, port, hops, key)
|
|
63
64
|
|
|
64
65
|
self.__txFifo = asyncio.Queue() # tx msg fifo
|
|
@@ -167,7 +168,7 @@ class AsyncEngine(core.EngineMixin):
|
|
|
167
168
|
|
|
168
169
|
async def handle_action_request(self, msg: 'Message', target: 'Device'):
|
|
169
170
|
if msg.action is None:
|
|
170
|
-
return
|
|
171
|
+
return # should not happen, but pyright need this check
|
|
171
172
|
|
|
172
173
|
try:
|
|
173
174
|
result = await run_action(msg, target)
|
|
@@ -250,7 +251,8 @@ class AsyncEngine(core.EngineMixin):
|
|
|
250
251
|
self.new_task(self.receive_task(), name='RecvQ')
|
|
251
252
|
self.new_task(self.send_task(), name='SendQ')
|
|
252
253
|
self.new_task(self.timer_task(), name='Timers')
|
|
253
|
-
|
|
254
|
+
if config.remote_console:
|
|
255
|
+
self.new_task(console(locals()), name='Console')
|
|
254
256
|
|
|
255
257
|
def setup_alives_timer(self):
|
|
256
258
|
# needed on stop-start sequence
|
|
@@ -259,7 +261,7 @@ class AsyncEngine(core.EngineMixin):
|
|
|
259
261
|
# process alives every 10 seconds
|
|
260
262
|
self.add_timer(self.process_alives, 10)
|
|
261
263
|
|
|
262
|
-
async def stop(self):
|
|
264
|
+
async def stop(self): # pyright: ignore
|
|
263
265
|
logger.info("Stopping engine")
|
|
264
266
|
await self.run_hooks(HookType.stop)
|
|
265
267
|
self.running_event.clear()
|
|
@@ -268,7 +270,6 @@ class AsyncEngine(core.EngineMixin):
|
|
|
268
270
|
for task in self.all_tasks():
|
|
269
271
|
if task != self._watchdog_task:
|
|
270
272
|
task.cancel()
|
|
271
|
-
await asyncio.sleep(0.1)
|
|
272
273
|
|
|
273
274
|
def sigkill_handler(self, signal, frame):
|
|
274
275
|
print("", end="\r") # remove the uggly ^C
|
|
@@ -340,7 +341,7 @@ class AsyncEngine(core.EngineMixin):
|
|
|
340
341
|
self.dump_hooks()
|
|
341
342
|
|
|
342
343
|
def get_device(self, uuid: UUID) -> Optional['Device']:
|
|
343
|
-
# TODO:Check if this method is usefull
|
|
344
|
+
# TODO:Check if this method is usefull
|
|
344
345
|
for dev in self.devices:
|
|
345
346
|
if dev.address == uuid:
|
|
346
347
|
return dev
|
|
@@ -391,7 +392,8 @@ async def console(locals=locals(), port: Optional[int] = None):
|
|
|
391
392
|
# let's find a free port if not specified
|
|
392
393
|
def find_free_port():
|
|
393
394
|
import socketserver
|
|
394
|
-
|
|
395
|
+
|
|
396
|
+
with socketserver.TCPServer(('localhost', 0), None) as s: # pyright: ignore pyright reject the None here
|
|
395
397
|
return s.server_address[1]
|
|
396
398
|
|
|
397
399
|
port = find_free_port()
|
|
@@ -407,6 +409,8 @@ async def console(locals=locals(), port: Optional[int] = None):
|
|
|
407
409
|
# start the console
|
|
408
410
|
try:
|
|
409
411
|
# debian with ipv6 disabled still state that localhost is ::1, which broke aioconsole
|
|
410
|
-
await aioconsole.start_interactive_server(
|
|
412
|
+
await aioconsole.start_interactive_server(
|
|
413
|
+
host="127.0.0.1", port=port, factory=factory, banner=banner
|
|
414
|
+
) # pyright: ignore
|
|
411
415
|
except OSError:
|
|
412
416
|
logger.warning("Unable to run console")
|
xaal/lib/core.py
CHANGED
|
@@ -56,7 +56,7 @@ class EngineMixin(object):
|
|
|
56
56
|
__slots__ = ['devices', 'timers', 'subscribers', 'msg_filter', '_attributesChange', 'network', 'msg_factory']
|
|
57
57
|
|
|
58
58
|
def __init__(self, address: str, port: int, hops: int, key: bytes):
|
|
59
|
-
self.devices:list[Device] = [] # list of devices / use (un)register_devices()
|
|
59
|
+
self.devices: list[Device] = [] # list of devices / use (un)register_devices()
|
|
60
60
|
self.timers: list[Timer] = [] # functions to call periodic
|
|
61
61
|
self.subscribers: list[SubFuncT] = [] # message receive workflow
|
|
62
62
|
self.msg_filter = None # message filter
|
|
@@ -134,7 +134,7 @@ class EngineMixin(object):
|
|
|
134
134
|
self.queue_msg(msg)
|
|
135
135
|
dev.update_alive()
|
|
136
136
|
|
|
137
|
-
def send_is_alive(self, dev: 'Device', targets: list = [ALIVE_ADDR
|
|
137
|
+
def send_is_alive(self, dev: 'Device', targets: list = [ALIVE_ADDR], dev_types: list = ["any.any"]):
|
|
138
138
|
"""Send a is_alive message, w/ dev_types filtering"""
|
|
139
139
|
body = {'dev_types': dev_types}
|
|
140
140
|
self.send_request(dev, targets, MessageAction.IS_ALIVE.value, body)
|
xaal/lib/helpers.py
CHANGED
|
@@ -7,7 +7,7 @@ import logging
|
|
|
7
7
|
import logging.handlers
|
|
8
8
|
import os
|
|
9
9
|
import time
|
|
10
|
-
from typing import Any, Optional
|
|
10
|
+
from typing import Any, Optional, Union
|
|
11
11
|
|
|
12
12
|
import coloredlogs
|
|
13
13
|
from decorator import decorator
|
|
@@ -40,14 +40,13 @@ def set_console_title(value: str):
|
|
|
40
40
|
# set xterm title
|
|
41
41
|
print("\x1b]0;xAAL => %s\x07" % value, end="\r")
|
|
42
42
|
|
|
43
|
-
|
|
44
|
-
def setup_console_logger(level: str = config.log_level):
|
|
43
|
+
def setup_console_logger(level: Union[str, int] = config.log_level):
|
|
45
44
|
fmt = "%(asctime)s %(name)-25s %(funcName)-18s %(levelname)-8s %(message)s"
|
|
46
45
|
# fmt = '[%(name)s] %(funcName)s %(levelname)s: %(message)s'
|
|
47
46
|
coloredlogs.install(level=level, fmt=fmt)
|
|
48
47
|
|
|
49
48
|
|
|
50
|
-
def setup_file_logger(name: str, level: str = config.log_level, filename: Optional[str] = None):
|
|
49
|
+
def setup_file_logger(name: str, level: Union[str, int] = config.log_level, filename: Optional[str] = None):
|
|
51
50
|
filename = filename or os.path.join(config.log_path, "%s.log" % name)
|
|
52
51
|
formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s")
|
|
53
52
|
handler = logging.handlers.RotatingFileHandler(filename, "a", 10000, 1, "utf8")
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
xaal/__init__.py,sha256=jv2YF__bseklT3OWEzlqJ5qE24c4aWd5F4r0TTjOrWQ,65
|
|
2
2
|
xaal/lib/__init__.py,sha256=yI2lG7uSbedjp1h2FCdcAUGzkyuJxYyNbK13SHvwNew,491
|
|
3
3
|
xaal/lib/__main__.py,sha256=xsVqqoIh3UeJIXxeexSfmGSUP4YxUcibdZExjEzk4lE,30
|
|
4
|
-
xaal/lib/aioengine.py,sha256=
|
|
4
|
+
xaal/lib/aioengine.py,sha256=u7P7tlSYg1X4TlfprgtMGtvLudIqWNPDMbn7NZoq7yA,13988
|
|
5
5
|
xaal/lib/aiohelpers.py,sha256=O1oQX8XHxuvCL1ual509chjoR52AwV_ZGqeAbSlvFrE,1010
|
|
6
6
|
xaal/lib/aionetwork.py,sha256=WSYwxwEHJaQDlfVocX8ow2tAtssWcH9LxPAazx4Qx_o,2547
|
|
7
7
|
xaal/lib/bindings.py,sha256=V77bFfeVFj0GyGuwH8b4k7qSyA7zApZYJ8QTjq_3DwI,2140
|
|
8
8
|
xaal/lib/cbor.py,sha256=XX0zgTU0uwQD9QXctGLT4lEISohi1whMUdyWKMevH8c,1647
|
|
9
9
|
xaal/lib/config.py,sha256=KR28xC8NGyGjvFD9QcAoWfwyf7xcXDEP7aSenNmaRzM,3019
|
|
10
|
-
xaal/lib/core.py,sha256=
|
|
10
|
+
xaal/lib/core.py,sha256=IBTrCCZhBKKYOuZWImxETbLZ5_upH5MRoIKKBXYEXvU,11982
|
|
11
11
|
xaal/lib/devices.py,sha256=CaUH3i_xTQD0W63fW93glI-Ck2_YVvMpdn8y7BqQqzw,10696
|
|
12
12
|
xaal/lib/engine.py,sha256=oFiBIma5M6Qv0W2wMmWdyCRuu7BwqR-DRUvqWfajh-A,8141
|
|
13
13
|
xaal/lib/exceptions.py,sha256=4cKKkDDcZIPyVrLv3Q19apbn_pIqDGqXb1s1d2sZnpI,573
|
|
14
|
-
xaal/lib/helpers.py,sha256=
|
|
14
|
+
xaal/lib/helpers.py,sha256=Qw7EMk7ssF85KvOuPJYzjtjavlqBi-ZUoSZH5iY0ts4,2857
|
|
15
15
|
xaal/lib/messages.py,sha256=FpdIZ5flzUfgXaVVptv_tirvq5jL__mjUGimExwK9Z0,12388
|
|
16
16
|
xaal/lib/network.py,sha256=oHpyHXkFT31RS6UKMZstC33dgC_sTtYKzfpgugY26oU,3277
|
|
17
17
|
xaal/lib/test.py,sha256=GTjIwdqRupdqO4lNhAnc4iH0azfCCMN9BEpJpgAUors,2944
|
|
18
18
|
xaal/lib/tools.py,sha256=Py_RUmLcOVjYDcm7muQ6jZPJLdOKzBfOKstX73K4Jqg,4157
|
|
19
|
-
xaal.lib-0.7.
|
|
20
|
-
xaal.lib-0.7.
|
|
21
|
-
xaal.lib-0.7.
|
|
22
|
-
xaal.lib-0.7.
|
|
19
|
+
xaal.lib-0.7.11.dist-info/METADATA,sha256=btOq5w5CNlRbMZ_-5zkMm9H94Epvp9DvhRTrRuhI6Ds,4351
|
|
20
|
+
xaal.lib-0.7.11.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
21
|
+
xaal.lib-0.7.11.dist-info/top_level.txt,sha256=UZ2WDkN02ztkh1OrsjrW8Kmj4n3WqC0BQxaEYOYfWa0,5
|
|
22
|
+
xaal.lib-0.7.11.dist-info/RECORD,,
|
|
File without changes
|