moat-kv-ow 0.9.4__py3-none-any.whl → 0.9.5__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.
- moat/kv/ow/__init__.py +2 -0
- moat/kv/ow/_cfg.yaml +2 -0
- moat/kv/ow/_main.py +17 -8
- moat/kv/ow/mock.py +9 -3
- moat/kv/ow/model.py +32 -11
- moat/kv/ow/task.py +6 -2
- {moat_kv_ow-0.9.4.dist-info → moat_kv_ow-0.9.5.dist-info}/METADATA +6 -6
- moat_kv_ow-0.9.5.dist-info/RECORD +11 -0
- {moat_kv_ow-0.9.4.dist-info → moat_kv_ow-0.9.5.dist-info}/WHEEL +1 -1
- moat_kv_ow-0.9.5.dist-info/licenses/LICENSE.txt +14 -0
- moat/kv/ow/_config.yaml +0 -4
- moat_kv_ow-0.9.4.dist-info/RECORD +0 -10
- {moat_kv_ow-0.9.4.dist-info → moat_kv_ow-0.9.5.dist-info}/top_level.txt +0 -0
moat/kv/ow/__init__.py
CHANGED
moat/kv/ow/_cfg.yaml
ADDED
moat/kv/ow/_main.py
CHANGED
@@ -1,7 +1,17 @@
|
|
1
1
|
# command line interface
|
2
|
+
from __future__ import annotations
|
2
3
|
|
3
4
|
import asyncclick as click
|
4
|
-
from moat.util import
|
5
|
+
from moat.util import (
|
6
|
+
yprint,
|
7
|
+
attrdict,
|
8
|
+
NotGiven,
|
9
|
+
P,
|
10
|
+
Path,
|
11
|
+
as_service,
|
12
|
+
attr_args,
|
13
|
+
ensure_cfg,
|
14
|
+
)
|
5
15
|
from moat.kv.data import data_get, node_attr
|
6
16
|
from .model import OWFSroot
|
7
17
|
|
@@ -17,6 +27,7 @@ async def cli(obj):
|
|
17
27
|
List Onewire devices, modify device handling …
|
18
28
|
"""
|
19
29
|
obj.data = await OWFSroot.as_handler(obj.client)
|
30
|
+
ensure_cfg("moat.kv.ow", obj.cfg)
|
20
31
|
|
21
32
|
|
22
33
|
@cli.command("list")
|
@@ -59,6 +70,7 @@ async def list_(obj, device, family):
|
|
59
70
|
return Path("%02x.%12x" % (p[0], p[1])) + p[2:]
|
60
71
|
|
61
72
|
if obj.meta:
|
73
|
+
|
62
74
|
def pm(p):
|
63
75
|
return Path(str(prefix + path)) + p
|
64
76
|
|
@@ -127,7 +139,7 @@ async def attr__(obj, device, family, write, attr, interval, path, attr_):
|
|
127
139
|
@attr_args
|
128
140
|
@click.argument("subpath", nargs=1, type=P, default=P(":"))
|
129
141
|
@click.pass_obj
|
130
|
-
async def set_(obj, device, family, subpath,
|
142
|
+
async def set_(obj, device, family, subpath, **kw):
|
131
143
|
"""Set or delete some random attribute.
|
132
144
|
|
133
145
|
For deletion, use '-e ATTR -'.
|
@@ -143,7 +155,7 @@ async def set_(obj, device, family, subpath, vars_, eval_, path_):
|
|
143
155
|
f, d = device.split(".", 2)[0:2]
|
144
156
|
fd = (int(f, 16), int(d, 16))
|
145
157
|
|
146
|
-
res = await node_attr(obj, obj.cfg.kv.ow.prefix + fd + subpath,
|
158
|
+
res = await node_attr(obj, obj.cfg.kv.ow.prefix + fd + subpath, **kw)
|
147
159
|
if res and obj.meta:
|
148
160
|
yprint(res, stream=obj.stdout)
|
149
161
|
|
@@ -164,9 +176,7 @@ async def server_(obj, name, host, port, delete):
|
|
164
176
|
if not name:
|
165
177
|
if host or port or delete:
|
166
178
|
raise click.UsageError("Use a server name to set parameters")
|
167
|
-
async for r in obj.client.get_tree(
|
168
|
-
prefix | "server", min_depth=1, max_depth=1
|
169
|
-
):
|
179
|
+
async for r in obj.client.get_tree(prefix | "server", min_depth=1, max_depth=1):
|
170
180
|
print(r.path[-1], file=obj.stdout)
|
171
181
|
return
|
172
182
|
elif len(name) > 1:
|
@@ -190,8 +200,7 @@ async def server_(obj, name, host, port, delete):
|
|
190
200
|
return
|
191
201
|
else:
|
192
202
|
value = None
|
193
|
-
res = await node_attr(
|
194
|
-
obj, prefix | "server" | name, ((P("server"), value),),(),())
|
203
|
+
res = await node_attr(obj, prefix | "server" | name, ((P("server"), value),), (), ())
|
195
204
|
if res and obj.meta:
|
196
205
|
yprint(res, stream=obj.stdout)
|
197
206
|
|
moat/kv/ow/mock.py
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
from __future__ import annotations
|
1
2
|
import os
|
2
3
|
import anyio
|
3
4
|
from functools import partial
|
4
5
|
from asyncowfs.mock import some_server
|
6
|
+
from moat.util import ensure_cfg
|
5
7
|
|
6
8
|
from .task import task
|
7
9
|
|
@@ -9,10 +11,11 @@ PORT = ((os.getpid() + 101) % 9999) + 40000
|
|
9
11
|
|
10
12
|
|
11
13
|
async def server(client, tree={}, options={}, evt=None): # pylint: disable=dangerous-default-value
|
12
|
-
|
13
14
|
async with anyio.create_task_group() as tg:
|
14
15
|
listener = await anyio.create_tcp_listener(
|
15
|
-
local_host="127.0.0.1",
|
16
|
+
local_host="127.0.0.1",
|
17
|
+
local_port=PORT,
|
18
|
+
reuse_port=True,
|
16
19
|
)
|
17
20
|
|
18
21
|
async def may_close():
|
@@ -24,8 +27,11 @@ async def server(client, tree={}, options={}, evt=None): # pylint: disable=dang
|
|
24
27
|
addr = listener.extra(anyio.abc.SocketAttribute.raw_socket).getsockname()
|
25
28
|
tg.start_soon(may_close)
|
26
29
|
|
30
|
+
cfg = {"kv": client._cfg}
|
31
|
+
ensure_cfg("moat.kv.ow", cfg)
|
32
|
+
|
27
33
|
await client.set(
|
28
|
-
client._cfg.
|
34
|
+
client._cfg.ow.prefix + ("server", "127.0.0.1"),
|
29
35
|
value=dict(server=dict(host="127.0.0.1", port=addr[1])),
|
30
36
|
)
|
31
37
|
|
moat/kv/ow/model.py
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
"""
|
2
2
|
Moat-KV client data model for 1wire
|
3
3
|
"""
|
4
|
+
|
5
|
+
from __future__ import annotations
|
6
|
+
|
4
7
|
import anyio
|
5
8
|
|
6
9
|
from moat.util import combine_dict, attrdict
|
@@ -67,7 +70,9 @@ class OWFSattr(ClientEntry):
|
|
67
70
|
await self.root._tg.start(self._watch_src)
|
68
71
|
else:
|
69
72
|
await self.root.err.record_working(
|
70
|
-
"owfs",
|
73
|
+
"owfs",
|
74
|
+
self.subpath + ("write",),
|
75
|
+
comment="dropped",
|
71
76
|
)
|
72
77
|
|
73
78
|
# poll OWFS
|
@@ -88,7 +93,9 @@ class OWFSattr(ClientEntry):
|
|
88
93
|
await dev.set_polling_interval(self.attr, intv)
|
89
94
|
else:
|
90
95
|
await self.root.err.record_working(
|
91
|
-
"owfs",
|
96
|
+
"owfs",
|
97
|
+
self.subpath + ("read",),
|
98
|
+
comment="dropped",
|
92
99
|
)
|
93
100
|
except RuntimeError as exc:
|
94
101
|
await self.root.err.record_error("owfs", self.subpath + ("read",), exc=exc)
|
@@ -136,7 +143,10 @@ class OWFSattr(ClientEntry):
|
|
136
143
|
with anyio.CancelScope() as sc:
|
137
144
|
try:
|
138
145
|
async with self.client.watch(
|
139
|
-
self.watch_src,
|
146
|
+
self.watch_src,
|
147
|
+
min_depth=0,
|
148
|
+
max_depth=0,
|
149
|
+
fetch=True,
|
140
150
|
) as wp:
|
141
151
|
if self.watch_src_scope is not None:
|
142
152
|
self.watch_src_scope.cancel()
|
@@ -157,19 +167,27 @@ class OWFSattr(ClientEntry):
|
|
157
167
|
"owfs",
|
158
168
|
self.subpath + ("write",),
|
159
169
|
comment="Attribute missing",
|
160
|
-
data={
|
170
|
+
data={
|
171
|
+
"key": k,
|
172
|
+
"attr": self.watch_src_attr,
|
173
|
+
"msg": msg,
|
174
|
+
},
|
161
175
|
)
|
162
176
|
return
|
163
177
|
else:
|
164
178
|
dev = self.node.dev
|
165
179
|
if dev is None:
|
166
180
|
await self.root.err.record_error(
|
167
|
-
"owfs",
|
181
|
+
"owfs",
|
182
|
+
self.subpath + ("write",),
|
183
|
+
comment="device missing",
|
168
184
|
)
|
169
185
|
return
|
170
186
|
await dev.set(*self.attr, value=val)
|
171
187
|
await self.root.err.record_working(
|
172
|
-
"owfs",
|
188
|
+
"owfs",
|
189
|
+
self.subpath + ("write",),
|
190
|
+
comment="write OK",
|
173
191
|
)
|
174
192
|
|
175
193
|
except Exception as exc:
|
@@ -237,7 +255,7 @@ class OWFSfamily(ClientEntry):
|
|
237
255
|
def child_type(cls, name):
|
238
256
|
if not isinstance(name, int):
|
239
257
|
return ClientEntry
|
240
|
-
if name <= 0 or name > 16
|
258
|
+
if name <= 0 or name > 16**12:
|
241
259
|
return ClientEntry
|
242
260
|
return cls.cls
|
243
261
|
|
@@ -301,15 +319,18 @@ class OWFSroot(ClientRoot):
|
|
301
319
|
kls.cls[name] = FamilyX
|
302
320
|
return FamilyX
|
303
321
|
|
322
|
+
|
304
323
|
class BrokenDict:
|
305
324
|
def __getattr__(self, k, v=None):
|
306
|
-
import pdb
|
307
|
-
|
308
|
-
|
325
|
+
import pdb
|
326
|
+
|
327
|
+
pdb.set_trace()
|
328
|
+
return object.__getattribute__(self, k, v)
|
329
|
+
|
309
330
|
|
310
331
|
@OWFSroot.register(0x10)
|
311
332
|
class TempNode(OWFSnode):
|
312
|
-
CFG = BrokenDict()
|
333
|
+
CFG = BrokenDict() # {"temperature": 30}
|
313
334
|
|
314
335
|
@classmethod
|
315
336
|
def child_type(cls, name):
|
moat/kv/ow/task.py
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
OWFS task for DistKV
|
3
3
|
"""
|
4
4
|
|
5
|
+
from __future__ import annotations
|
6
|
+
|
5
7
|
import anyio
|
6
8
|
from asyncowfs import OWFS
|
7
9
|
from asyncowfs.event import (
|
@@ -51,7 +53,9 @@ async def mon(ow, hd):
|
|
51
53
|
if isinstance(msg.attribute, str):
|
52
54
|
attr = (attr,)
|
53
55
|
await node.root.err.record_error(
|
54
|
-
"onewire",
|
56
|
+
"onewire",
|
57
|
+
Path.build(node.subpath) + attr,
|
58
|
+
exc=msg.exception,
|
55
59
|
)
|
56
60
|
|
57
61
|
elif isinstance(msg, DeviceValue):
|
@@ -70,7 +74,7 @@ async def task(client, cfg, server=None, evt=None):
|
|
70
74
|
async with OWFS() as ow:
|
71
75
|
hd = await OWFSroot.as_handler(client)
|
72
76
|
await ow.add_task(mon, ow, hd)
|
73
|
-
port = cfg.
|
77
|
+
port = cfg.ow.port
|
74
78
|
if not server:
|
75
79
|
si = ((s._name, s) for s in hd.server)
|
76
80
|
elif isinstance(server, str):
|
@@ -1,21 +1,21 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: moat-kv-ow
|
3
|
-
Version: 0.9.
|
3
|
+
Version: 0.9.5
|
4
4
|
Summary: 1wire connector for MoaT-KV
|
5
5
|
Author-email: Matthias Urlichs <matthias@urlichs.de>
|
6
6
|
Project-URL: homepage, https://m-o-a-t.org
|
7
|
-
Project-URL: repository, https://github.com/M-o-a-T/moat
|
7
|
+
Project-URL: repository, https://github.com/M-o-a-T/moat
|
8
8
|
Keywords: MoaT
|
9
9
|
Classifier: Development Status :: 4 - Beta
|
10
10
|
Classifier: Intended Audience :: Information Technology
|
11
|
-
Classifier: License :: OSI Approved :: MIT License
|
12
|
-
Classifier: License :: OSI Approved :: Apache Software License
|
13
11
|
Classifier: Programming Language :: Python :: 3
|
14
12
|
Classifier: Topic :: Database
|
15
13
|
Classifier: Topic :: Home Automation
|
16
14
|
Requires-Python: >=3.8
|
17
15
|
Description-Content-Type: text/x-rst
|
18
|
-
|
16
|
+
License-File: LICENSE.txt
|
17
|
+
Requires-Dist: moat-kv~=0.70.23
|
18
|
+
Dynamic: license-file
|
19
19
|
|
20
20
|
==========
|
21
21
|
MoaT-KV-OW
|
@@ -0,0 +1,11 @@
|
|
1
|
+
moat/kv/ow/__init__.py,sha256=ZBoFcXbv35djD599Vo_PKTqDjvQXYYXTcPUs5RcQZrs,101
|
2
|
+
moat/kv/ow/_cfg.yaml,sha256=dzidXt6m_1zw2fPaYGRjvV5aJ8rasBXeTXFpH1ZAMMk,40
|
3
|
+
moat/kv/ow/_main.py,sha256=aoOHqJu5Y2vAcRm_xBbqqi6m7Svx1xniKKkD276g8fg,6469
|
4
|
+
moat/kv/ow/mock.py,sha256=qBUiwOpeB096EXaBfT-yZ74Q9uzsAQ4_5nDgWMm64tM,1169
|
5
|
+
moat/kv/ow/model.py,sha256=yQpnxtyjVuuRKkUSw8rLGlzQkfyy3jy6tvLLr9JwlYc,10407
|
6
|
+
moat/kv/ow/task.py,sha256=tZjkFRhF4WjEHr_zZVy8eFabGOCWO_Cx2vMrn6Q6rGo,2686
|
7
|
+
moat_kv_ow-0.9.5.dist-info/licenses/LICENSE.txt,sha256=L5vKJLVOg5t0CEEPpW9-O_0vzbP0PEjEF06tLvnIDuk,541
|
8
|
+
moat_kv_ow-0.9.5.dist-info/METADATA,sha256=X3IT-9KMjTTgSuSjOBWjGFczkgplwzwGcsZ1sUIsmFA,961
|
9
|
+
moat_kv_ow-0.9.5.dist-info/WHEEL,sha256=xcaH6rP_nCxh1LBIPM7Q0uOnzSGjsIye-Q44j_zbzw8,104
|
10
|
+
moat_kv_ow-0.9.5.dist-info/top_level.txt,sha256=pcs9fl5w5AB5GVi4SvBqIVmFrkRwQkVw_dEvW0Q0cSA,5
|
11
|
+
moat_kv_ow-0.9.5.dist-info/RECORD,,
|
@@ -0,0 +1,14 @@
|
|
1
|
+
The code in this repository, and all MoaT submodules it refers to,
|
2
|
+
is part of the MoaT project.
|
3
|
+
|
4
|
+
Unless a submodule's LICENSE.txt states otherwise, all included files are
|
5
|
+
licensed under the LGPL V3, as published by the FSF at
|
6
|
+
https://www.gnu.org/licenses/lgpl-3.0.html .
|
7
|
+
|
8
|
+
In addition to the LGPL's terms, the author(s) respectfully ask all users of
|
9
|
+
this code to contribute any bug fixes or enhancements. Also, please link back to
|
10
|
+
https://M-o-a-T.org.
|
11
|
+
|
12
|
+
Thank you.
|
13
|
+
|
14
|
+
Copyright © 2021 ff.: the MoaT contributor(s), as per the git changelog(s).
|
moat/kv/ow/_config.yaml
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
moat/kv/ow/__init__.py,sha256=ED6jHcYiuYpr_0vjGz0zx2lrrmJT9sDJCzIljoDfmlM,65
|
2
|
-
moat/kv/ow/_config.yaml,sha256=-F0QC6JyNBQX0X0sXzJrMsUu5s_Nzb3cYA9NzYL-gmI,58
|
3
|
-
moat/kv/ow/_main.py,sha256=SEAbqVlTW8hSFKMUSphsQR-MeaJDd5dSz9pm__m4AWw,6405
|
4
|
-
moat/kv/ow/mock.py,sha256=VxT1gxVi74qHe8-jfvzeY0oWcixNSY9zbLeybW-COFM,1009
|
5
|
-
moat/kv/ow/model.py,sha256=rb3pPrlC22G1PtriFEccGYmmIBFcOfZlkQTe6elCFTM,9935
|
6
|
-
moat/kv/ow/task.py,sha256=K_wgmxw4Hqcc8dnRiupne8e2bAsBb3WHND8GBSacV1E,2612
|
7
|
-
moat_kv_ow-0.9.4.dist-info/METADATA,sha256=JkRTJXx0nAXxt29fUfsnZ7LWLtSpceCwZqaS16l17Q4,1035
|
8
|
-
moat_kv_ow-0.9.4.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
9
|
-
moat_kv_ow-0.9.4.dist-info/top_level.txt,sha256=pcs9fl5w5AB5GVi4SvBqIVmFrkRwQkVw_dEvW0Q0cSA,5
|
10
|
-
moat_kv_ow-0.9.4.dist-info/RECORD,,
|
File without changes
|