xaal.lib 0.7.2__py3-none-any.whl → 0.7.4__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/cbor.py +4 -5
- {xaal.lib-0.7.2.dist-info → xaal.lib-0.7.4.dist-info}/METADATA +25 -22
- {xaal.lib-0.7.2.dist-info → xaal.lib-0.7.4.dist-info}/RECORD +5 -5
- {xaal.lib-0.7.2.dist-info → xaal.lib-0.7.4.dist-info}/WHEEL +0 -0
- {xaal.lib-0.7.2.dist-info → xaal.lib-0.7.4.dist-info}/top_level.txt +0 -0
xaal/lib/cbor.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
from io import BytesIO
|
|
2
2
|
import cbor2
|
|
3
3
|
from cbor2 import CBORTag
|
|
4
|
-
# from cbor2 import CBORDecoder
|
|
5
4
|
from cbor2.decoder import CBORDecoder
|
|
6
5
|
|
|
7
6
|
from . import bindings
|
|
@@ -39,16 +38,16 @@ def _loads(s, **kwargs):
|
|
|
39
38
|
|
|
40
39
|
|
|
41
40
|
def cleanup(obj):
|
|
42
|
-
"""
|
|
41
|
+
"""
|
|
43
42
|
recursive walk a object to search for un-wanted CBOR tags.
|
|
44
43
|
Transform this tag in string format, this can be UUID, URL..
|
|
45
|
-
Should be Ok, with list, dicts..
|
|
46
|
-
Warning: This operate in-place changes.
|
|
44
|
+
Should be Ok, with list, dicts..
|
|
45
|
+
Warning: This operate in-place changes.
|
|
47
46
|
Warning: This won't work for tags in dict keys.
|
|
48
47
|
"""
|
|
49
48
|
if isinstance(obj,list):
|
|
50
49
|
for i in range(0,len(obj)):
|
|
51
|
-
obj[i] = cleanup(obj[i])
|
|
50
|
+
obj[i] = cleanup(obj[i])
|
|
52
51
|
return obj
|
|
53
52
|
|
|
54
53
|
if isinstance(obj,dict):
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: xaal.lib
|
|
3
|
-
Version: 0.7.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 0.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
|
|
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
10
|
Keywords: xaal,home-automation
|
|
8
11
|
Classifier: Programming Language :: Python
|
|
9
12
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
13
|
+
Classifier: Topic :: Home Automation
|
|
10
14
|
Description-Content-Type: text/x-rst
|
|
11
15
|
Requires-Dist: cbor2 ==5.4.2
|
|
12
16
|
Requires-Dist: pysodium
|
|
@@ -20,7 +24,7 @@ Requires-Dist: aioconsole
|
|
|
20
24
|
xaal.lib
|
|
21
25
|
========
|
|
22
26
|
**xaal.lib** is the official Python stack to develop home-automation devices and gateways
|
|
23
|
-
with the xAAL protocol. For a full description of the protocol check out
|
|
27
|
+
with the xAAL protocol. For a full description of the protocol check out
|
|
24
28
|
http://recherche.imt-atlantique.fr/xaal/
|
|
25
29
|
|
|
26
30
|
|
|
@@ -38,8 +42,8 @@ xaal.lib depends on :
|
|
|
38
42
|
|
|
39
43
|
Install
|
|
40
44
|
~~~~~~~
|
|
41
|
-
Please refer to the official `full documentation to install the lib in a virtualenv
|
|
42
|
-
<https://redmine.
|
|
45
|
+
Please refer to the official `full documentation to install the lib in a virtualenv
|
|
46
|
+
<https://redmine.imt-atlantique.fr/svn/xaal/code/Python/branches/0.7/README.html>`_
|
|
43
47
|
|
|
44
48
|
|
|
45
49
|
Usage
|
|
@@ -52,7 +56,7 @@ To receive / parse / display incoming xAAL messages, you can simply try somethin
|
|
|
52
56
|
this:
|
|
53
57
|
|
|
54
58
|
.. code-block:: python
|
|
55
|
-
|
|
59
|
+
|
|
56
60
|
from xaal.lib import Engine
|
|
57
61
|
|
|
58
62
|
def display(msg):
|
|
@@ -61,31 +65,31 @@ this:
|
|
|
61
65
|
eng = Engine()
|
|
62
66
|
eng.subscribe(display)
|
|
63
67
|
eng.run()
|
|
64
|
-
|
|
68
|
+
|
|
65
69
|
The Engine will call the display function every time it receive a xAAL message.
|
|
66
70
|
|
|
67
|
-
Let's take a look at a simple lamp device :
|
|
71
|
+
Let's take a look at a simple lamp device :
|
|
68
72
|
|
|
69
73
|
.. code-block:: python
|
|
70
|
-
|
|
74
|
+
|
|
71
75
|
from xaal.lib import Device,Engine,tools
|
|
72
|
-
|
|
76
|
+
|
|
73
77
|
# create and configure the lamp device, with a random address
|
|
74
|
-
dev = Device("lamp.basic", tools.get_random_uuid())
|
|
78
|
+
dev = Device("lamp.basic", tools.get_random_uuid())
|
|
75
79
|
dev.product_id = 'Dummy Lamp'
|
|
76
80
|
dev.url = 'http://www.acme.org'
|
|
77
81
|
dev.info = 'My fake lamp'
|
|
78
82
|
|
|
79
83
|
# add an xAAL attribute 'light'
|
|
80
84
|
light = dev.new_attribute('light')
|
|
81
|
-
|
|
85
|
+
|
|
82
86
|
# declare two device methods ON & OFF
|
|
83
87
|
def on():
|
|
84
88
|
light.value = True
|
|
85
89
|
|
|
86
90
|
def off():
|
|
87
91
|
light.value = False
|
|
88
|
-
|
|
92
|
+
|
|
89
93
|
dev.add_method('turn_on',on)
|
|
90
94
|
dev.add_method('turn_off',off)
|
|
91
95
|
|
|
@@ -93,8 +97,8 @@ Let's take a look at a simple lamp device :
|
|
|
93
97
|
eng = Engine()
|
|
94
98
|
eng.add_device(dev)
|
|
95
99
|
eng.run()
|
|
96
|
-
|
|
97
|
-
|
|
100
|
+
|
|
101
|
+
|
|
98
102
|
FAQ
|
|
99
103
|
~~~
|
|
100
104
|
The core engine run forever so how can I use it in webserver, GUI or to develop device
|
|
@@ -103,17 +107,17 @@ exactly know what's going on. Anyways, you have several options to fix this issu
|
|
|
103
107
|
|
|
104
108
|
* You can use you own loop and periodically call *eng.loop()*
|
|
105
109
|
for example, you can do something like this:
|
|
106
|
-
|
|
110
|
+
|
|
107
111
|
.. code:: python
|
|
108
|
-
|
|
112
|
+
|
|
109
113
|
while 1:
|
|
110
114
|
do_some_stuff()
|
|
111
115
|
eng.loop()
|
|
112
116
|
|
|
113
117
|
* You can use a engine timer, to perform some stuff.
|
|
114
|
-
|
|
118
|
+
|
|
115
119
|
.. code:: python
|
|
116
|
-
|
|
120
|
+
|
|
117
121
|
def read_io():
|
|
118
122
|
pass
|
|
119
123
|
|
|
@@ -126,6 +130,5 @@ exactly know what's going on. Anyways, you have several options to fix this issu
|
|
|
126
130
|
*coroutines* in device methods, timers functions and callbacks. It provides additionals features
|
|
127
131
|
like the *on_start* and *on_stop* callbacks.
|
|
128
132
|
|
|
129
|
-
* Use an alternate coroutine lib, you can use **gevent** or **greenlet** for example. Look at
|
|
130
|
-
apps/rest for a simple greenlet example.
|
|
131
|
-
|
|
133
|
+
* Use an alternate coroutine lib, you can use **gevent** or **greenlet** for example. Look at
|
|
134
|
+
apps/rest for a simple greenlet example.
|
|
@@ -5,7 +5,7 @@ xaal/lib/aioengine.py,sha256=3MTG9aGKekVvsWhYaehZqZem6YmPng4UqGfDoRTaC2E,13100
|
|
|
5
5
|
xaal/lib/aiohelpers.py,sha256=2a310wSXzbg9SGYzrTfcHbaZ8PWEe9rLteDmS2i62kU,1007
|
|
6
6
|
xaal/lib/aionetwork.py,sha256=pH-5kf8o4FHsbvs-oFf5guAgYaEu0aosyTuI3k8xt2M,2484
|
|
7
7
|
xaal/lib/bindings.py,sha256=EkDJJ_iBQbC7UzsjHfoXAjpGSwC613hrIm5ubrkcw4k,1994
|
|
8
|
-
xaal/lib/cbor.py,sha256=
|
|
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
11
|
xaal/lib/devices.py,sha256=ZDNVNVmJ26W2atuNkzB7xtYZQAT3dWTrQCvMCDMSVWA,9574
|
|
@@ -16,7 +16,7 @@ xaal/lib/messages.py,sha256=cLwplLp_0qmlgZi6ByohvLEcmuxpWK7liE5dpqyV9AM,11552
|
|
|
16
16
|
xaal/lib/network.py,sha256=3HWuQ0afQ-X6_-En2rFeqYJ0Scy5IEHfd0qTldxxCFo,3130
|
|
17
17
|
xaal/lib/test.py,sha256=laVbgG4HtQquxDzixAG-Cka-HO4kpb7YUsLL267mGPU,3006
|
|
18
18
|
xaal/lib/tools.py,sha256=SnXmOkeTd4eTN8yWn-GyCkV5mYiG-MX4hkF39KnogLE,3841
|
|
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.4.dist-info/METADATA,sha256=098sqex95_VX7JbzNloGStwbBHI3D1Nvd6y3l3pKcv8,3809
|
|
20
|
+
xaal.lib-0.7.4.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
|
|
21
|
+
xaal.lib-0.7.4.dist-info/top_level.txt,sha256=UZ2WDkN02ztkh1OrsjrW8Kmj4n3WqC0BQxaEYOYfWa0,5
|
|
22
|
+
xaal.lib-0.7.4.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|