xaal.lib 0.7.8__py3-none-any.whl → 0.7.9__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/__init__.py +2 -4
- xaal/lib/config.py +19 -6
- xaal/lib/devices.py +3 -3
- xaal/lib/engine.py +2 -4
- xaal/lib/messages.py +3 -2
- {xaal.lib-0.7.8.dist-info → xaal.lib-0.7.9.dist-info}/METADATA +1 -1
- {xaal.lib-0.7.8.dist-info → xaal.lib-0.7.9.dist-info}/RECORD +9 -9
- {xaal.lib-0.7.8.dist-info → xaal.lib-0.7.9.dist-info}/WHEEL +0 -0
- {xaal.lib-0.7.8.dist-info → xaal.lib-0.7.9.dist-info}/top_level.txt +0 -0
xaal/lib/__init__.py
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
# Load main class & modules.
|
|
4
2
|
|
|
5
3
|
|
|
@@ -8,7 +6,7 @@ from . import tools
|
|
|
8
6
|
from . import bindings
|
|
9
7
|
from . import aiohelpers as helpers
|
|
10
8
|
|
|
11
|
-
from .core
|
|
9
|
+
from .core import Timer
|
|
12
10
|
|
|
13
11
|
# sync engine
|
|
14
12
|
from .engine import Engine
|
|
@@ -19,5 +17,5 @@ from .aioengine import AsyncEngine
|
|
|
19
17
|
from .aionetwork import AsyncNetworkConnector
|
|
20
18
|
|
|
21
19
|
from .devices import Device, Attribute, Attributes
|
|
22
|
-
from .messages import Message,MessageFactory,MessageType
|
|
20
|
+
from .messages import Message, MessageFactory, MessageType, MessageAction
|
|
23
21
|
from .exceptions import *
|
xaal/lib/config.py
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
# Default configuration
|
|
3
2
|
|
|
4
3
|
import os
|
|
@@ -7,20 +6,23 @@ import binascii
|
|
|
7
6
|
from configobj import ConfigObj
|
|
8
7
|
|
|
9
8
|
# Default settings
|
|
10
|
-
DEF_ADDR =
|
|
9
|
+
DEF_ADDR = "224.0.29.200"
|
|
11
10
|
DEF_PORT = 1236
|
|
12
11
|
DEF_HOPS = 10
|
|
13
12
|
DEF_ALIVE_TIMER = 100
|
|
14
13
|
DEF_CIPHER_WINDOW = 60 * 2
|
|
15
14
|
DEF_QUEUE_SIZE = 10
|
|
16
|
-
DEF_LOG_LEVEL =
|
|
17
|
-
DEF_LOG_PATH =
|
|
15
|
+
DEF_LOG_LEVEL = "DEBUG"
|
|
16
|
+
DEF_LOG_PATH = "/var/log/xaal"
|
|
17
|
+
DEF_REMOTE_CONSOLE = False
|
|
18
|
+
|
|
18
19
|
|
|
19
20
|
STACK_VERSION = 7
|
|
20
21
|
|
|
22
|
+
|
|
21
23
|
class Config:
|
|
22
24
|
def __init__(self):
|
|
23
|
-
self.conf_dir = os.environ.get(
|
|
25
|
+
self.conf_dir = os.environ.get("XAAL_CONF_DIR", os.path.expanduser("~/.xaal"))
|
|
24
26
|
self.address = DEF_ADDR
|
|
25
27
|
self.port = DEF_PORT
|
|
26
28
|
self.hops = DEF_HOPS
|
|
@@ -29,10 +31,11 @@ class Config:
|
|
|
29
31
|
self.queue_size = DEF_QUEUE_SIZE
|
|
30
32
|
self.log_level = DEF_LOG_LEVEL
|
|
31
33
|
self.log_path = DEF_LOG_PATH
|
|
34
|
+
self.remote_console = DEF_REMOTE_CONSOLE
|
|
32
35
|
self.key = b''
|
|
33
36
|
self.STACK_VERSION = STACK_VERSION
|
|
34
37
|
|
|
35
|
-
def load(self, name=
|
|
38
|
+
def load(self, name="xaal.ini"):
|
|
36
39
|
filename = os.path.join(self.conf_dir, name)
|
|
37
40
|
if not os.path.isfile(filename):
|
|
38
41
|
raise FileNotFoundError(f"Unable to load xAAL config file [{filename}]")
|
|
@@ -46,6 +49,8 @@ class Config:
|
|
|
46
49
|
self.queue_size = self.safe_int(cfg.get('queue_size'), DEF_QUEUE_SIZE)
|
|
47
50
|
self.log_level = self.safe_string(cfg.get('log_level'), DEF_LOG_LEVEL)
|
|
48
51
|
self.log_path = self.safe_string(cfg.get('log_path'), DEF_LOG_PATH)
|
|
52
|
+
self.remote_console = self.safe_bool(cfg.get('remote_console'), DEF_REMOTE_CONSOLE)
|
|
53
|
+
|
|
49
54
|
key = cfg.get('key', None)
|
|
50
55
|
if key and type(key) is str:
|
|
51
56
|
self.key = binascii.unhexlify(key.encode('utf-8'))
|
|
@@ -73,6 +78,14 @@ class Config:
|
|
|
73
78
|
except (ValueError, TypeError):
|
|
74
79
|
return default
|
|
75
80
|
|
|
81
|
+
@staticmethod
|
|
82
|
+
def safe_bool(value, default):
|
|
83
|
+
if value is None:
|
|
84
|
+
return default
|
|
85
|
+
if value.lower() == "true":
|
|
86
|
+
return True
|
|
87
|
+
return False
|
|
88
|
+
|
|
76
89
|
|
|
77
90
|
config = Config()
|
|
78
91
|
try:
|
xaal/lib/devices.py
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
import logging
|
|
22
22
|
import time
|
|
23
23
|
import typing
|
|
24
|
-
from typing import Any, Optional, Union, Callable, Awaitable
|
|
24
|
+
from typing import Any, Optional, Union, Callable, Awaitable, Dict
|
|
25
25
|
|
|
26
26
|
from tabulate import tabulate
|
|
27
27
|
|
|
@@ -133,7 +133,7 @@ class Device(object):
|
|
|
133
133
|
self.next_alive = 0
|
|
134
134
|
# Default attributes & methods
|
|
135
135
|
self.__attributes = Attributes()
|
|
136
|
-
self.methods:
|
|
136
|
+
self.methods: Dict[str, MethodT] = {
|
|
137
137
|
'get_attributes': self._get_attributes,
|
|
138
138
|
'get_description': self._get_description,
|
|
139
139
|
}
|
|
@@ -225,7 +225,7 @@ class Device(object):
|
|
|
225
225
|
if name in self.methods:
|
|
226
226
|
del self.methods[name]
|
|
227
227
|
|
|
228
|
-
def get_methods(self) ->
|
|
228
|
+
def get_methods(self) -> Dict[str, MethodT]:
|
|
229
229
|
return self.methods
|
|
230
230
|
|
|
231
231
|
def update_alive(self):
|
xaal/lib/engine.py
CHANGED
|
@@ -25,8 +25,6 @@ import typing
|
|
|
25
25
|
from enum import Enum
|
|
26
26
|
from typing import Optional
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
|
|
30
28
|
from .config import config
|
|
31
29
|
from . import core
|
|
32
30
|
from .exceptions import CallbackError, MessageParserError, XAALError
|
|
@@ -135,11 +133,11 @@ class Engine(core.EngineMixin):
|
|
|
135
133
|
* error returned on the xAAL bus
|
|
136
134
|
"""
|
|
137
135
|
if msg.action is None:
|
|
138
|
-
return
|
|
136
|
+
return # should not happen, but pyright need this check
|
|
139
137
|
|
|
140
138
|
try:
|
|
141
139
|
result = run_action(msg, target)
|
|
142
|
-
if result:
|
|
140
|
+
if result is not None:
|
|
143
141
|
self.send_reply(dev=target, targets=[msg.source], action=msg.action, body=result)
|
|
144
142
|
except CallbackError as e:
|
|
145
143
|
self.send_error(target, e.code, e.description)
|
xaal/lib/messages.py
CHANGED
|
@@ -342,8 +342,9 @@ def build_nonce(data: tuple) -> bytes:
|
|
|
342
342
|
|
|
343
343
|
def build_timestamp() -> tuple:
|
|
344
344
|
"""Return array [seconds since epoch, microseconds since last seconds] Time = UTC+0000"""
|
|
345
|
-
|
|
346
|
-
|
|
345
|
+
utc = datetime.timezone.utc
|
|
346
|
+
epoch = datetime.datetime.fromtimestamp(0, utc)
|
|
347
|
+
timestamp = datetime.datetime.now(utc) - epoch
|
|
347
348
|
return (int(timestamp.total_seconds()), int(timestamp.microseconds))
|
|
348
349
|
|
|
349
350
|
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
xaal/__init__.py,sha256=jv2YF__bseklT3OWEzlqJ5qE24c4aWd5F4r0TTjOrWQ,65
|
|
2
|
-
xaal/lib/__init__.py,sha256=
|
|
2
|
+
xaal/lib/__init__.py,sha256=yI2lG7uSbedjp1h2FCdcAUGzkyuJxYyNbK13SHvwNew,491
|
|
3
3
|
xaal/lib/__main__.py,sha256=xsVqqoIh3UeJIXxeexSfmGSUP4YxUcibdZExjEzk4lE,30
|
|
4
4
|
xaal/lib/aioengine.py,sha256=3l5wCRV9ZySfJOpKxDD_yO81NtL1v246mMveR28q9ms,13959
|
|
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
|
-
xaal/lib/config.py,sha256=
|
|
9
|
+
xaal/lib/config.py,sha256=KR28xC8NGyGjvFD9QcAoWfwyf7xcXDEP7aSenNmaRzM,3019
|
|
10
10
|
xaal/lib/core.py,sha256=WUdG1k7H589FpVbTkotHX574KiSYISZ622eWy3Af3B0,11985
|
|
11
|
-
xaal/lib/devices.py,sha256=
|
|
12
|
-
xaal/lib/engine.py,sha256=
|
|
11
|
+
xaal/lib/devices.py,sha256=CaUH3i_xTQD0W63fW93glI-Ck2_YVvMpdn8y7BqQqzw,10696
|
|
12
|
+
xaal/lib/engine.py,sha256=oFiBIma5M6Qv0W2wMmWdyCRuu7BwqR-DRUvqWfajh-A,8141
|
|
13
13
|
xaal/lib/exceptions.py,sha256=4cKKkDDcZIPyVrLv3Q19apbn_pIqDGqXb1s1d2sZnpI,573
|
|
14
14
|
xaal/lib/helpers.py,sha256=lPtEwP82Ssd9igmxJGq2UzmPVCyRBMHULBBVyAH4Blg,2827
|
|
15
|
-
xaal/lib/messages.py,sha256=
|
|
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.9.dist-info/METADATA,sha256=sqdfCDzjK0rQ-rmIYzAoK3-e62injIc0HOgpapB0Fe4,4350
|
|
20
|
+
xaal.lib-0.7.9.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
|
|
21
|
+
xaal.lib-0.7.9.dist-info/top_level.txt,sha256=UZ2WDkN02ztkh1OrsjrW8Kmj4n3WqC0BQxaEYOYfWa0,5
|
|
22
|
+
xaal.lib-0.7.9.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|