xaal.lib 0.7.8__tar.gz → 0.7.9__tar.gz

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.
Files changed (33) hide show
  1. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/PKG-INFO +1 -1
  2. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/pyproject.toml +1 -1
  3. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/__init__.py +2 -4
  4. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/config.py +19 -6
  5. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/devices.py +3 -3
  6. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/engine.py +2 -4
  7. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/messages.py +3 -2
  8. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal.lib.egg-info/PKG-INFO +1 -1
  9. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/README.rst +0 -0
  10. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/setup.cfg +0 -0
  11. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/tests/test_bindings.py +0 -0
  12. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/tests/test_cbor.py +0 -0
  13. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/tests/test_device.py +0 -0
  14. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/tests/test_engine.py +0 -0
  15. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/tests/test_message.py +0 -0
  16. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/tests/test_tools.py +0 -0
  17. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/__init__.py +0 -0
  18. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/__main__.py +0 -0
  19. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/aioengine.py +0 -0
  20. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/aiohelpers.py +0 -0
  21. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/aionetwork.py +0 -0
  22. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/bindings.py +0 -0
  23. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/cbor.py +0 -0
  24. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/core.py +0 -0
  25. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/exceptions.py +0 -0
  26. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/helpers.py +0 -0
  27. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/network.py +0 -0
  28. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/test.py +0 -0
  29. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal/lib/tools.py +0 -0
  30. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal.lib.egg-info/SOURCES.txt +0 -0
  31. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal.lib.egg-info/dependency_links.txt +0 -0
  32. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal.lib.egg-info/requires.txt +0 -0
  33. {xaal_lib-0.7.8 → xaal_lib-0.7.9}/xaal.lib.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xaal.lib
3
- Version: 0.7.8
3
+ Version: 0.7.9
4
4
  Summary: Official Python stack for xAAL protocol
5
5
  Author-email: Jerome Kerdreux <Jerome.Kerdreux@imt-atlantique.fr>
6
6
  License: GPL License
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "xaal.lib"
3
- version = "0.7.8"
3
+ version = "0.7.9"
4
4
  description = "Official Python stack for xAAL protocol"
5
5
  readme = "README.rst"
6
6
  authors = [
@@ -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 import Timer
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 *
@@ -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 = '224.0.29.200'
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 = 'DEBUG'
17
- DEF_LOG_PATH = '/var/log/xaal'
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('XAAL_CONF_DIR', os.path.expanduser("~/.xaal"))
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='xaal.ini'):
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:
@@ -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: dict[str, MethodT] = {
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) -> dict[str, MethodT]:
228
+ def get_methods(self) -> Dict[str, MethodT]:
229
229
  return self.methods
230
230
 
231
231
  def update_alive(self):
@@ -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 # should not happen, but pyright need this check
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)
@@ -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
- epoch = datetime.datetime.fromtimestamp(0, datetime.UTC)
346
- timestamp = datetime.datetime.now(datetime.UTC) - epoch
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,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xaal.lib
3
- Version: 0.7.8
3
+ Version: 0.7.9
4
4
  Summary: Official Python stack for xAAL protocol
5
5
  Author-email: Jerome Kerdreux <Jerome.Kerdreux@imt-atlantique.fr>
6
6
  License: GPL License
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes