xaal.lib 0.7.10__tar.gz → 0.7.12__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.10 → xaal_lib-0.7.12}/PKG-INFO +5 -5
  2. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/pyproject.toml +4 -4
  3. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/tests/test_message.py +28 -28
  4. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/aioengine.py +1 -2
  5. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/config.py +8 -5
  6. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/devices.py +3 -3
  7. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/helpers.py +5 -4
  8. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal.lib.egg-info/PKG-INFO +5 -5
  9. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/README.rst +0 -0
  10. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/setup.cfg +0 -0
  11. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/tests/test_bindings.py +0 -0
  12. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/tests/test_cbor.py +0 -0
  13. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/tests/test_device.py +0 -0
  14. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/tests/test_engine.py +0 -0
  15. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/tests/test_tools.py +0 -0
  16. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/__init__.py +0 -0
  17. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/__init__.py +0 -0
  18. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/__main__.py +0 -0
  19. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/aiohelpers.py +0 -0
  20. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/aionetwork.py +0 -0
  21. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/bindings.py +0 -0
  22. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/cbor.py +0 -0
  23. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/core.py +0 -0
  24. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/engine.py +0 -0
  25. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/exceptions.py +0 -0
  26. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/messages.py +0 -0
  27. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/network.py +0 -0
  28. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/test.py +0 -0
  29. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal/lib/tools.py +0 -0
  30. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal.lib.egg-info/SOURCES.txt +0 -0
  31. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal.lib.egg-info/dependency_links.txt +0 -0
  32. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal.lib.egg-info/requires.txt +0 -0
  33. {xaal_lib-0.7.10 → xaal_lib-0.7.12}/xaal.lib.egg-info/top_level.txt +0 -0
@@ -1,12 +1,12 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: xaal.lib
3
- Version: 0.7.10
3
+ Version: 0.7.12
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
7
- Project-URL: Homepage, https://recherche.imt-atlantique.fr/xaal/
8
- Project-URL: Documentation, https://redmine.imt-atlantique.fr/projects/xaal/repository/xaal/entry/code/Python/branches/0.7/libs/lib/README.rst
9
- Project-URL: Source, https://redmine.imt-atlantique.fr/projects/xaal/repository/xaal/show/code/Python/branches/0.7/libs/lib
7
+ Project-URL: Homepage, https://gitlab.imt-atlantique.fr/xaal/code/python/-/blob/main/packages.rst
8
+ Project-URL: Documentation, https://gitlab.imt-atlantique.fr/xaal/code/python/-/blob/main/libs/lib/README.rst
9
+ Project-URL: Source, https://gitlab.imt-atlantique.fr/xaal/code/python/-/tree/main/libs/lib
10
10
  Keywords: xaal,home-automation
11
11
  Classifier: Programming Language :: Python
12
12
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "xaal.lib"
3
- version = "0.7.10"
3
+ version = "0.7.12"
4
4
  description = "Official Python stack for xAAL protocol"
5
5
  readme = "README.rst"
6
6
  authors = [
@@ -26,9 +26,9 @@ dependencies = [
26
26
 
27
27
 
28
28
  [project.urls]
29
- Homepage = "https://recherche.imt-atlantique.fr/xaal/"
30
- Documentation = "https://redmine.imt-atlantique.fr/projects/xaal/repository/xaal/entry/code/Python/branches/0.7/libs/lib/README.rst"
31
- Source = "https://redmine.imt-atlantique.fr/projects/xaal/repository/xaal/show/code/Python/branches/0.7/libs/lib"
29
+ Homepage = "https://gitlab.imt-atlantique.fr/xaal/code/python/-/blob/main/packages.rst"
30
+ Documentation = "https://gitlab.imt-atlantique.fr/xaal/code/python/-/blob/main/libs/lib/README.rst"
31
+ Source = "https://gitlab.imt-atlantique.fr/xaal/code/python/-/tree/main/libs/lib"
32
32
 
33
33
 
34
34
  [tool.ruff]
@@ -6,7 +6,7 @@ from xaal.lib import tools,cbor
6
6
  from xaal.lib.exceptions import MessageParserError
7
7
 
8
8
 
9
- def test_message():
9
+ def fake_message():
10
10
  msg = Message()
11
11
  msg.msg_type = MessageType.REQUEST
12
12
  msg.source = tools.get_random_uuid()
@@ -16,7 +16,7 @@ def test_message():
16
16
  msg.timestamp = messages.build_timestamp()
17
17
  return msg
18
18
 
19
- def test_factory():
19
+ def fake_factory():
20
20
  # create the factory
21
21
  cypher = tools.pass2key('test')
22
22
  mf = MessageFactory(cypher)
@@ -39,20 +39,20 @@ class TestMessage(unittest.TestCase):
39
39
  msg.targets = ["foo"]
40
40
 
41
41
  def test_display(self):
42
- msg = test_message()
42
+ msg = fake_message()
43
43
  print()
44
44
  # dump
45
45
  msg.dump()
46
46
  print(msg)
47
47
 
48
48
  def test_targets_as_string(self):
49
- msg = test_message()
49
+ msg = fake_message()
50
50
  addr = tools.get_random_uuid()
51
51
  msg.targets = [addr]
52
52
  self.assertEqual(msg.targets_as_string(), [str(addr),] )
53
53
 
54
54
  def test_is_request(self):
55
- msg = test_message()
55
+ msg = fake_message()
56
56
  msg.msg_type = 1
57
57
  self.assertTrue(msg.is_request())
58
58
  msg.msg_type = 2
@@ -60,21 +60,21 @@ class TestMessage(unittest.TestCase):
60
60
 
61
61
 
62
62
  def test_is_reply(self):
63
- msg = test_message()
63
+ msg = fake_message()
64
64
  msg.msg_type = 2
65
65
  self.assertTrue(msg.is_reply())
66
66
  msg.msg_type = 1
67
67
  self.assertFalse(msg.is_reply())
68
68
 
69
69
  def test_is_notify(self):
70
- msg = test_message()
70
+ msg = fake_message()
71
71
  msg.msg_type = 0
72
72
  self.assertTrue(msg.is_notify())
73
73
  msg.msg_type = 1
74
74
  self.assertFalse(msg.is_notify())
75
75
 
76
76
  def test_is_alive(self):
77
- msg = test_message()
77
+ msg = fake_message()
78
78
  msg.msg_type = 0
79
79
  msg.action = 'alive'
80
80
  self.assertTrue(msg.is_alive())
@@ -82,7 +82,7 @@ class TestMessage(unittest.TestCase):
82
82
  self.assertFalse(msg.is_alive())
83
83
 
84
84
  def test_is_request_isalive(self):
85
- msg = test_message()
85
+ msg = fake_message()
86
86
  msg.msg_type = 1
87
87
  msg.action = 'is_alive'
88
88
  self.assertTrue(msg.is_request_isalive())
@@ -90,7 +90,7 @@ class TestMessage(unittest.TestCase):
90
90
  self.assertFalse(msg.is_request_isalive())
91
91
 
92
92
  def test_is_attributes_change(self):
93
- msg = test_message()
93
+ msg = fake_message()
94
94
  msg.msg_type = 0
95
95
  msg.action = 'attributes_change'
96
96
  self.assertTrue(msg.is_attributes_change())
@@ -98,7 +98,7 @@ class TestMessage(unittest.TestCase):
98
98
  self.assertFalse(msg.is_attributes_change())
99
99
 
100
100
  def test_is_get_attribute_reply(self):
101
- msg = test_message()
101
+ msg = fake_message()
102
102
  msg.msg_type = 2
103
103
  msg.action = 'get_attributes'
104
104
  self.assertTrue(msg.is_get_attribute_reply())
@@ -106,7 +106,7 @@ class TestMessage(unittest.TestCase):
106
106
  self.assertFalse(msg.is_get_attribute_reply())
107
107
 
108
108
  def test_is_get_description_reply(self):
109
- msg = test_message()
109
+ msg = fake_message()
110
110
  msg.msg_type = 2
111
111
  msg.action = 'get_description'
112
112
  self.assertTrue(msg.is_get_description_reply())
@@ -117,9 +117,9 @@ class TestMessage(unittest.TestCase):
117
117
  class TestMessageFactory(unittest.TestCase):
118
118
 
119
119
  def test_encode_decode(self):
120
- msg1 = test_message()
120
+ msg1 = fake_message()
121
121
 
122
- mf = test_factory()
122
+ mf = fake_factory()
123
123
  data = mf.encode_msg(msg1)
124
124
  msg2 = mf.decode_msg(data)
125
125
 
@@ -134,14 +134,14 @@ class TestMessageFactory(unittest.TestCase):
134
134
 
135
135
  def test_build_alive_for(self):
136
136
  dev = Device("test.basic",tools.get_random_uuid())
137
- mf = test_factory()
137
+ mf = fake_factory()
138
138
  data = mf.build_alive_for(dev)
139
139
  msg = mf.decode_msg(data)
140
140
  self.assertTrue(msg.is_alive())
141
141
 
142
142
  def test_build_error_msg(self):
143
143
  dev = Device("test.basic",tools.get_random_uuid())
144
- mf = test_factory()
144
+ mf = fake_factory()
145
145
  data = mf.build_error_msg(dev, 500,"Internal Error")
146
146
  msg = mf.decode_msg(data)
147
147
  self.assertTrue(msg.is_notify())
@@ -149,13 +149,13 @@ class TestMessageFactory(unittest.TestCase):
149
149
  self.assertEqual(msg.body['code'], 500)
150
150
 
151
151
  def test_decode_cbor_parse_error(self):
152
- mf = test_factory()
152
+ mf = fake_factory()
153
153
  with self.assertRaises(MessageParserError):
154
154
  mf.decode_msg("not_cbor")
155
155
 
156
156
  def test_decode_cbor_fields(self):
157
157
  # test missing fields
158
- mf = test_factory()
158
+ mf = fake_factory()
159
159
  l = [7,12346.5,[]]
160
160
  data=cbor.dumps(l)
161
161
  # IndexError
@@ -163,17 +163,17 @@ class TestMessageFactory(unittest.TestCase):
163
163
  mf.decode_msg(data)
164
164
 
165
165
  def test_decode_filter_func(self):
166
- msg1 = test_message()
166
+ msg1 = fake_message()
167
167
  filter = lambda msg: False
168
- mf = test_factory()
168
+ mf = fake_factory()
169
169
  data = mf.encode_msg(msg1)
170
170
  msg2 = mf.decode_msg(data,filter_func=filter)
171
171
  self.assertEqual(msg2, None)
172
172
 
173
173
  def test_replay_error(self):
174
- mf = test_factory()
174
+ mf = fake_factory()
175
175
  # too young
176
- msg = test_message()
176
+ msg = fake_message()
177
177
  target = (msg.timestamp[0] + 60*5, msg.timestamp[1])
178
178
  msg.timestamp = target
179
179
  data = mf.encode_msg(msg)
@@ -188,8 +188,8 @@ class TestMessageFactory(unittest.TestCase):
188
188
  mf.decode_msg(data)
189
189
 
190
190
  def test_decode_sanity_check(self):
191
- mf = test_factory()
192
- msg = test_message()
191
+ mf = fake_factory()
192
+ msg = fake_message()
193
193
  # WARNING: Only testing dev_type because alterring source is impossible
194
194
  # without rewriting a big chunk of encoding here
195
195
  msg.dev_type = "test"
@@ -198,8 +198,8 @@ class TestMessageFactory(unittest.TestCase):
198
198
  mf.decode_msg(data)
199
199
 
200
200
  def test_decode_nopayload(self):
201
- mf = test_factory()
202
- msg = test_message()
201
+ mf = fake_factory()
202
+ msg = fake_message()
203
203
  data = mf.encode_msg(msg)
204
204
  l=cbor.loads(data)
205
205
  l.pop()
@@ -208,8 +208,8 @@ class TestMessageFactory(unittest.TestCase):
208
208
  mf.decode_msg(data)
209
209
 
210
210
  def test_decode_decrypt_error(self):
211
- mf = test_factory()
212
- msg = test_message()
211
+ mf = fake_factory()
212
+ msg = fake_message()
213
213
  data = mf.encode_msg(msg)
214
214
  mf.cipher_key = tools.pass2key('bar')
215
215
  with self.assertRaises(MessageParserError):
@@ -268,9 +268,8 @@ class AsyncEngine(core.EngineMixin):
268
268
  self.started_event.clear()
269
269
  # cancel all tasks
270
270
  for task in self.all_tasks():
271
- if task != self._watchdog_task:
271
+ if task != self._watchdog_task and not task.cancelled():
272
272
  task.cancel()
273
- await asyncio.sleep(0.1)
274
273
 
275
274
  def sigkill_handler(self, signal, frame):
276
275
  print("", end="\r") # remove the uggly ^C
@@ -87,9 +87,12 @@ class Config:
87
87
  return False
88
88
 
89
89
 
90
+ config_dir = os.environ.get("XAAL_CONF_DIR", None)
90
91
  config = Config()
91
- try:
92
- config.load()
93
- except Exception as e:
94
- print(e)
95
- sys.exit(-1)
92
+
93
+ if config_dir is None or config_dir != '':
94
+ try:
95
+ config.load()
96
+ except Exception as e:
97
+ print(e)
98
+ sys.exit(-1)
@@ -247,21 +247,21 @@ class Device(object):
247
247
  r.append(['address', self.address])
248
248
  for k, v in self._get_description().items():
249
249
  r.append([k, v])
250
- print(tabulate(r, tablefmt='fancy_grid'))
250
+ print(tabulate(r, tablefmt='psql'))
251
251
 
252
252
  # attributes
253
253
  if len(self._get_attributes()) > 0:
254
254
  r = []
255
255
  for k, v in self._get_attributes().items():
256
256
  r.append([k, str(v)])
257
- print(tabulate(r, tablefmt='fancy_grid'))
257
+ print(tabulate(r, tablefmt='psql'))
258
258
 
259
259
  # methods
260
260
  if len(self.methods) > 0:
261
261
  r = []
262
262
  for k, v in self.methods.items():
263
263
  r.append([k, v.__name__])
264
- print(tabulate(r, tablefmt='fancy_grid'))
264
+ print(tabulate(r, tablefmt='psql'))
265
265
 
266
266
  def __repr__(self) -> str:
267
267
  return f"<xaal.Device {id(self):x} {self.address} {self.dev_type}>"
@@ -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
@@ -41,13 +41,14 @@ def set_console_title(value: str):
41
41
  print("\x1b]0;xAAL => %s\x07" % value, end="\r")
42
42
 
43
43
 
44
- def setup_console_logger(level: str = config.log_level):
45
- fmt = "%(asctime)s %(name)-25s %(funcName)-18s %(levelname)-8s %(message)s"
44
+ def setup_console_logger(level: Union[str, int] = config.log_level):
45
+ # fmt = "%(asctime)s %(name)-25s %(funcName)-18s %(levelname)-8s %(message)s"
46
+ fmt = "%(asctime)s %(name)-25s %(funcName)-18s %(message)s"
46
47
  # fmt = '[%(name)s] %(funcName)s %(levelname)s: %(message)s'
47
48
  coloredlogs.install(level=level, fmt=fmt)
48
49
 
49
50
 
50
- def setup_file_logger(name: str, level: str = config.log_level, filename: Optional[str] = None):
51
+ def setup_file_logger(name: str, level: Union[str, int] = config.log_level, filename: Optional[str] = None):
51
52
  filename = filename or os.path.join(config.log_path, "%s.log" % name)
52
53
  formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(name)s - %(message)s")
53
54
  handler = logging.handlers.RotatingFileHandler(filename, "a", 10000, 1, "utf8")
@@ -1,12 +1,12 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: xaal.lib
3
- Version: 0.7.10
3
+ Version: 0.7.12
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
7
- Project-URL: Homepage, https://recherche.imt-atlantique.fr/xaal/
8
- Project-URL: Documentation, https://redmine.imt-atlantique.fr/projects/xaal/repository/xaal/entry/code/Python/branches/0.7/libs/lib/README.rst
9
- Project-URL: Source, https://redmine.imt-atlantique.fr/projects/xaal/repository/xaal/show/code/Python/branches/0.7/libs/lib
7
+ Project-URL: Homepage, https://gitlab.imt-atlantique.fr/xaal/code/python/-/blob/main/packages.rst
8
+ Project-URL: Documentation, https://gitlab.imt-atlantique.fr/xaal/code/python/-/blob/main/libs/lib/README.rst
9
+ Project-URL: Source, https://gitlab.imt-atlantique.fr/xaal/code/python/-/tree/main/libs/lib
10
10
  Keywords: xaal,home-automation
11
11
  Classifier: Programming Language :: Python
12
12
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
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