xaal.lib 0.7.5__py3-none-any.whl → 0.7.7__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/devices.py +7 -7
- xaal/lib/tools.py +3 -4
- {xaal.lib-0.7.5.dist-info → xaal.lib-0.7.7.dist-info}/METADATA +19 -2
- {xaal.lib-0.7.5.dist-info → xaal.lib-0.7.7.dist-info}/RECORD +6 -6
- {xaal.lib-0.7.5.dist-info → xaal.lib-0.7.7.dist-info}/WHEEL +1 -1
- {xaal.lib-0.7.5.dist-info → xaal.lib-0.7.7.dist-info}/top_level.txt +0 -0
xaal/lib/devices.py
CHANGED
|
@@ -44,7 +44,7 @@ class Attribute(object):
|
|
|
44
44
|
|
|
45
45
|
@value.setter
|
|
46
46
|
def value(self, value):
|
|
47
|
-
if value != self.__value:
|
|
47
|
+
if value != self.__value and self.device:
|
|
48
48
|
eng = self.device.engine
|
|
49
49
|
if eng:
|
|
50
50
|
eng.add_attributes_change(self)
|
|
@@ -53,7 +53,7 @@ class Attribute(object):
|
|
|
53
53
|
|
|
54
54
|
def __repr__(self): # pragma: no cover
|
|
55
55
|
return f"<{self.__module__}.Attribute {self.name} at 0x{id(self):x}>"
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
|
|
58
58
|
class Attributes(list):
|
|
59
59
|
"""Devices owns a attributes list. This list also have dict-like access"""
|
|
@@ -65,7 +65,7 @@ class Attributes(list):
|
|
|
65
65
|
if (value == k.name):
|
|
66
66
|
return k.value
|
|
67
67
|
raise KeyError(value)
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
def __setitem__(self,name,value):
|
|
70
70
|
if isinstance(name,int):
|
|
71
71
|
return list.__setitem__(self,name,value)
|
|
@@ -74,7 +74,7 @@ class Attributes(list):
|
|
|
74
74
|
k.value = value
|
|
75
75
|
return
|
|
76
76
|
raise KeyError(name)
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
class Device(object):
|
|
79
79
|
|
|
80
80
|
__slots__ = ['__dev_type','__address','group_id',
|
|
@@ -96,7 +96,7 @@ class Device(object):
|
|
|
96
96
|
self.__url = None # product URL
|
|
97
97
|
self.schema = None # schema URL
|
|
98
98
|
self.info = None # additionnal info
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
# Unsupported stuffs
|
|
101
101
|
self.unsupported_attributes = []
|
|
102
102
|
self.unsupported_methods = []
|
|
@@ -166,7 +166,7 @@ class Device(object):
|
|
|
166
166
|
if attr:
|
|
167
167
|
self.__attributes.append(attr)
|
|
168
168
|
attr.device = self
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
def del_attribute(self,attr):
|
|
171
171
|
if attr:
|
|
172
172
|
attr.device = None
|
|
@@ -215,7 +215,7 @@ class Device(object):
|
|
|
215
215
|
for k,v in self._get_description().items():
|
|
216
216
|
r.append([k,v])
|
|
217
217
|
print(tabulate(r,tablefmt="fancy_grid"))
|
|
218
|
-
|
|
218
|
+
|
|
219
219
|
# attributes
|
|
220
220
|
if len(self._get_attributes()) > 0:
|
|
221
221
|
r = []
|
xaal/lib/tools.py
CHANGED
|
@@ -30,7 +30,7 @@ from configobj import ConfigObj
|
|
|
30
30
|
from . import config
|
|
31
31
|
from .bindings import UUID
|
|
32
32
|
|
|
33
|
-
XAAL_DEVTYPE_PATTERN = '^[a-zA-Z][a-zA-Z0-9_-]
|
|
33
|
+
XAAL_DEVTYPE_PATTERN = '^[a-zA-Z][a-zA-Z0-9_-]*\\.[a-zA-Z][a-zA-Z0-9_-]*$'
|
|
34
34
|
|
|
35
35
|
def get_cfg_filename(name, cfg_dir=config.conf_dir):
|
|
36
36
|
if name.startswith('xaal.'):
|
|
@@ -39,7 +39,7 @@ def get_cfg_filename(name, cfg_dir=config.conf_dir):
|
|
|
39
39
|
if not os.path.isdir(cfg_dir):
|
|
40
40
|
print("Your configuration directory doesn't exist: [%s]" % cfg_dir)
|
|
41
41
|
return os.path.join(cfg_dir, filename)
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
def load_cfg_file(filename):
|
|
44
44
|
""" load .ini file and return it as dict"""
|
|
45
45
|
if os.path.isfile(filename):
|
|
@@ -112,7 +112,7 @@ def pass2key(passphrase):
|
|
|
112
112
|
memlimit: crypto_pwhash_scryptsalsa208sha256_MEMLIMIT_INTERACTIVE
|
|
113
113
|
"""
|
|
114
114
|
buf = passphrase.encode('utf-8')
|
|
115
|
-
KEY_BYTES = pysodium.crypto_pwhash_scryptsalsa208sha256_SALTBYTES #32
|
|
115
|
+
KEY_BYTES = pysodium.crypto_pwhash_scryptsalsa208sha256_SALTBYTES #32
|
|
116
116
|
# this should be:
|
|
117
117
|
# salt = bytes(KEY_BYTES)
|
|
118
118
|
# but due to bytes() stupid stuff in py2 we need this awfull stuff
|
|
@@ -127,4 +127,3 @@ def reduce_addr(addr):
|
|
|
127
127
|
"""return a string based addred without all digits"""
|
|
128
128
|
tmp = addr.str
|
|
129
129
|
return tmp[:5] + '..' + tmp[-5:]
|
|
130
|
-
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: xaal.lib
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.7
|
|
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
|
|
@@ -43,7 +43,7 @@ xaal.lib depends on :
|
|
|
43
43
|
Install
|
|
44
44
|
~~~~~~~
|
|
45
45
|
Please refer to the official `full documentation to install the lib in a virtualenv
|
|
46
|
-
<https://
|
|
46
|
+
<https://gitlab.imt-atlantique.fr/xaal/code/python/-/blob/main/README.rst>`_
|
|
47
47
|
|
|
48
48
|
|
|
49
49
|
Usage
|
|
@@ -99,6 +99,23 @@ Let's take a look at a simple lamp device :
|
|
|
99
99
|
eng.run()
|
|
100
100
|
|
|
101
101
|
|
|
102
|
+
To avoid to rewrite the same code for each device, you can use the `xaal.schemas package <https://gitlab.imt-atlantique.fr/xaal/code/python/-/tree/main/libs/schemas>`_.
|
|
103
|
+
This package provides a set of predefined devices, you can use them as a template to create your own device.
|
|
104
|
+
|
|
105
|
+
.. code-block:: python
|
|
106
|
+
|
|
107
|
+
from xaal.schemas import devices
|
|
108
|
+
from xaal.lib import Engine
|
|
109
|
+
|
|
110
|
+
# create and configure the lamp device
|
|
111
|
+
dev = devices.lamp()
|
|
112
|
+
|
|
113
|
+
# last step, create an engine and register the lamp
|
|
114
|
+
eng = Engine()
|
|
115
|
+
eng.add_device(dev)
|
|
116
|
+
eng.run()
|
|
117
|
+
|
|
118
|
+
|
|
102
119
|
FAQ
|
|
103
120
|
~~~
|
|
104
121
|
The core engine run forever so how can I use it in webserver, GUI or to develop device
|
|
@@ -8,15 +8,15 @@ xaal/lib/bindings.py,sha256=EkDJJ_iBQbC7UzsjHfoXAjpGSwC613hrIm5ubrkcw4k,1994
|
|
|
8
8
|
xaal/lib/cbor.py,sha256=yOTAo3TBO7m8KU_ffccJdOZmiJF5tfY7H8nC1XfMIS8,1630
|
|
9
9
|
xaal/lib/config.py,sha256=jNAEXCswWsKrVab3hycupQn4aYt4c61eq628ow_I2ZI,1736
|
|
10
10
|
xaal/lib/core.py,sha256=VfaisNREUse-zMrilJuKf6NLVO9HugL1U_I4M7BFzKQ,10806
|
|
11
|
-
xaal/lib/devices.py,sha256=
|
|
11
|
+
xaal/lib/devices.py,sha256=TXj7qk6raa8aU1wkMeA5HYsWF0MFFjs0_JTxN_r6_MQ,9558
|
|
12
12
|
xaal/lib/engine.py,sha256=p2of6IPQB0It0RNu5fkJHHp615K_2rgzHfuWOpvJ6Is,7539
|
|
13
13
|
xaal/lib/exceptions.py,sha256=ZKDKGlm_F48K_0NlaV1fa0Z-a4ZnOxT7NU8c8MKSJAc,504
|
|
14
14
|
xaal/lib/helpers.py,sha256=mXxVxv7fTV9O9xO1BROhVYBTmdviMl6qx3Il8q1ox8w,2679
|
|
15
15
|
xaal/lib/messages.py,sha256=W7RdHOtX_DT0bCeJAzs0p4KkU5KXofZUCMQYQsOuFF8,11571
|
|
16
16
|
xaal/lib/network.py,sha256=3HWuQ0afQ-X6_-En2rFeqYJ0Scy5IEHfd0qTldxxCFo,3130
|
|
17
17
|
xaal/lib/test.py,sha256=laVbgG4HtQquxDzixAG-Cka-HO4kpb7YUsLL267mGPU,3006
|
|
18
|
-
xaal/lib/tools.py,sha256=
|
|
19
|
-
xaal.lib-0.7.
|
|
20
|
-
xaal.lib-0.7.
|
|
21
|
-
xaal.lib-0.7.
|
|
22
|
-
xaal.lib-0.7.
|
|
18
|
+
xaal/lib/tools.py,sha256=qLZZOfA1VvQWJjGR46JWdAwWzv8Uog2TUTw7lK34CZg,3832
|
|
19
|
+
xaal.lib-0.7.7.dist-info/METADATA,sha256=LJ4Ry8elEPVz7ONsef6BEEzpofShCqsgurcs8yiKLBQ,4351
|
|
20
|
+
xaal.lib-0.7.7.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
|
|
21
|
+
xaal.lib-0.7.7.dist-info/top_level.txt,sha256=UZ2WDkN02ztkh1OrsjrW8Kmj4n3WqC0BQxaEYOYfWa0,5
|
|
22
|
+
xaal.lib-0.7.7.dist-info/RECORD,,
|
|
File without changes
|