moat-kv 0.70.22__py3-none-any.whl → 0.70.24__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.
- build/lib/docs/source/conf.py +201 -0
- build/lib/examples/pathify.py +45 -0
- build/lib/moat/kv/__init__.py +19 -0
- build/lib/moat/kv/_cfg.yaml +97 -0
- build/lib/moat/kv/_main.py +91 -0
- build/lib/moat/kv/actor/__init__.py +98 -0
- build/lib/moat/kv/actor/deletor.py +139 -0
- build/lib/moat/kv/auth/__init__.py +444 -0
- build/lib/moat/kv/auth/_test.py +166 -0
- build/lib/moat/kv/auth/password.py +234 -0
- build/lib/moat/kv/auth/root.py +58 -0
- build/lib/moat/kv/backend/__init__.py +67 -0
- build/lib/moat/kv/backend/mqtt.py +74 -0
- build/lib/moat/kv/backend/serf.py +45 -0
- build/lib/moat/kv/client.py +1025 -0
- build/lib/moat/kv/code.py +236 -0
- build/lib/moat/kv/codec.py +11 -0
- build/lib/moat/kv/command/__init__.py +1 -0
- build/lib/moat/kv/command/acl.py +180 -0
- build/lib/moat/kv/command/auth.py +261 -0
- build/lib/moat/kv/command/code.py +293 -0
- build/lib/moat/kv/command/codec.py +186 -0
- build/lib/moat/kv/command/data.py +265 -0
- build/lib/moat/kv/command/dump/__init__.py +143 -0
- build/lib/moat/kv/command/error.py +149 -0
- build/lib/moat/kv/command/internal.py +248 -0
- build/lib/moat/kv/command/job.py +433 -0
- build/lib/moat/kv/command/log.py +53 -0
- build/lib/moat/kv/command/server.py +114 -0
- build/lib/moat/kv/command/type.py +201 -0
- build/lib/moat/kv/config.py +46 -0
- build/lib/moat/kv/data.py +216 -0
- build/lib/moat/kv/errors.py +561 -0
- build/lib/moat/kv/exceptions.py +126 -0
- build/lib/moat/kv/mock/__init__.py +101 -0
- build/lib/moat/kv/mock/mqtt.py +159 -0
- build/lib/moat/kv/mock/serf.py +250 -0
- build/lib/moat/kv/mock/tracer.py +63 -0
- build/lib/moat/kv/model.py +1069 -0
- build/lib/moat/kv/obj/__init__.py +646 -0
- build/lib/moat/kv/obj/command.py +241 -0
- build/lib/moat/kv/runner.py +1347 -0
- build/lib/moat/kv/server.py +2809 -0
- build/lib/moat/kv/types.py +513 -0
- debian/moat-kv/usr/lib/python3/dist-packages/docs/source/conf.py +201 -0
- debian/moat-kv/usr/lib/python3/dist-packages/examples/pathify.py +45 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/__init__.py +19 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/_cfg.yaml +97 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/_main.py +91 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/actor/__init__.py +98 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/actor/deletor.py +139 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/__init__.py +444 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/_test.py +166 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/password.py +234 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/root.py +58 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/__init__.py +67 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/mqtt.py +74 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/serf.py +45 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/client.py +1025 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/code.py +236 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/codec.py +11 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/__init__.py +1 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/acl.py +180 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/auth.py +261 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/code.py +293 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/codec.py +186 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/data.py +265 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/dump/__init__.py +143 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/error.py +149 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/internal.py +248 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/job.py +433 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/log.py +53 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/server.py +114 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/type.py +201 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/config.py +46 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/data.py +216 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/errors.py +561 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/exceptions.py +126 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/__init__.py +101 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/mqtt.py +159 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/serf.py +250 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/tracer.py +63 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/model.py +1069 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/obj/__init__.py +646 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/obj/command.py +241 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/runner.py +1347 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/server.py +2809 -0
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/types.py +513 -0
- docs/source/conf.py +201 -0
- examples/pathify.py +45 -0
- moat/kv/__init__.py +1 -0
- moat/kv/_cfg.yaml +97 -0
- moat/kv/_main.py +6 -9
- moat/kv/actor/__init__.py +2 -1
- moat/kv/actor/deletor.py +3 -1
- moat/kv/auth/__init__.py +8 -10
- moat/kv/auth/_test.py +6 -12
- moat/kv/auth/password.py +2 -0
- moat/kv/auth/root.py +2 -0
- moat/kv/backend/__init__.py +1 -0
- moat/kv/backend/mqtt.py +3 -3
- moat/kv/backend/serf.py +1 -0
- moat/kv/client.py +34 -50
- moat/kv/code.py +10 -3
- moat/kv/codec.py +1 -0
- moat/kv/command/acl.py +12 -6
- moat/kv/command/auth.py +5 -2
- moat/kv/command/code.py +10 -23
- moat/kv/command/codec.py +10 -14
- moat/kv/command/data.py +12 -21
- moat/kv/command/dump/__init__.py +4 -2
- moat/kv/command/error.py +5 -12
- moat/kv/command/internal.py +6 -15
- moat/kv/command/job.py +26 -31
- moat/kv/command/log.py +1 -0
- moat/kv/command/server.py +2 -3
- moat/kv/command/type.py +26 -28
- moat/kv/config.py +2 -0
- moat/kv/data.py +8 -7
- moat/kv/errors.py +17 -9
- moat/kv/exceptions.py +1 -7
- moat/kv/mock/__init__.py +9 -5
- moat/kv/mock/mqtt.py +7 -12
- moat/kv/mock/serf.py +6 -9
- moat/kv/mock/tracer.py +2 -4
- moat/kv/model.py +16 -24
- moat/kv/obj/__init__.py +30 -20
- moat/kv/obj/command.py +7 -12
- moat/kv/runner.py +38 -35
- moat/kv/server.py +86 -90
- moat/kv/types.py +5 -8
- {moat_kv-0.70.22.dist-info → moat_kv-0.70.24.dist-info}/METADATA +15 -18
- moat_kv-0.70.24.dist-info/RECORD +137 -0
- {moat_kv-0.70.22.dist-info → moat_kv-0.70.24.dist-info}/WHEEL +1 -1
- moat_kv-0.70.24.dist-info/licenses/LICENSE.txt +14 -0
- moat_kv-0.70.24.dist-info/top_level.txt +9 -0
- moat/kv/_config.yaml +0 -98
- moat_kv-0.70.22.dist-info/LICENSE +0 -3
- moat_kv-0.70.22.dist-info/LICENSE.APACHE2 +0 -202
- moat_kv-0.70.22.dist-info/LICENSE.MIT +0 -20
- moat_kv-0.70.22.dist-info/RECORD +0 -49
- moat_kv-0.70.22.dist-info/top_level.txt +0 -1
moat/kv/command/acl.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# command line interface
|
2
|
+
from __future__ import annotations
|
2
3
|
|
3
4
|
import sys
|
4
5
|
|
@@ -22,7 +23,11 @@ async def cli():
|
|
22
23
|
async def list_(obj):
|
23
24
|
"""List ACLs."""
|
24
25
|
res = await obj.client._request(
|
25
|
-
action="enum_internal",
|
26
|
+
action="enum_internal",
|
27
|
+
path=("acl",),
|
28
|
+
iter=False,
|
29
|
+
nchain=obj.meta,
|
30
|
+
empty=True,
|
26
31
|
)
|
27
32
|
yprint(res if obj.meta else res.result, stream=obj.stdout)
|
28
33
|
|
@@ -57,7 +62,10 @@ async def get(obj, name, path):
|
|
57
62
|
if not len(path):
|
58
63
|
raise click.UsageError("You need a non-empty path.")
|
59
64
|
res = await obj.client._request(
|
60
|
-
action="get_internal",
|
65
|
+
action="get_internal",
|
66
|
+
path=("acl", name) + path,
|
67
|
+
iter=False,
|
68
|
+
nchain=obj.meta,
|
61
69
|
)
|
62
70
|
|
63
71
|
if not obj.meta:
|
@@ -94,9 +102,7 @@ async def set_(obj, acl, name, path):
|
|
94
102
|
acl = set(acl)
|
95
103
|
|
96
104
|
if acl - ACL:
|
97
|
-
raise click.UsageError(
|
98
|
-
f"You're trying to set an unknown ACL flag: {acl - ACL !r}"
|
99
|
-
)
|
105
|
+
raise click.UsageError(f"You're trying to set an unknown ACL flag: {acl - ACL!r}")
|
100
106
|
|
101
107
|
res = await obj.client._request(
|
102
108
|
action="get_internal",
|
@@ -106,7 +112,7 @@ async def set_(obj, acl, name, path):
|
|
106
112
|
)
|
107
113
|
ov = set(res.get("value", ""))
|
108
114
|
if ov - ACL:
|
109
|
-
print(f"Warning: original ACL contains unknown: {ov - acl
|
115
|
+
print(f"Warning: original ACL contains unknown: {ov - acl!r}", file=sys.stderr)
|
110
116
|
|
111
117
|
if mode == "-" and not acl:
|
112
118
|
res = await obj.client._request(
|
moat/kv/command/auth.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# command line interface
|
2
|
+
from __future__ import annotations
|
2
3
|
|
3
4
|
import asyncclick as click
|
4
5
|
from moat.util import NotGiven, Path, split_arg, yprint
|
@@ -41,7 +42,6 @@ async def enum_auth(obj):
|
|
41
42
|
for r in res.result:
|
42
43
|
print(r)
|
43
44
|
yield r
|
44
|
-
pass
|
45
45
|
|
46
46
|
|
47
47
|
async def one_auth(obj):
|
@@ -73,7 +73,10 @@ async def enum_typ(obj, kind="user", ident=None, nchain=0):
|
|
73
73
|
yield res
|
74
74
|
else:
|
75
75
|
async with obj.client._stream(
|
76
|
-
action="auth_list",
|
76
|
+
action="auth_list",
|
77
|
+
typ=auth,
|
78
|
+
kind=kind,
|
79
|
+
nchain=nchain,
|
77
80
|
) as res:
|
78
81
|
async for r in res:
|
79
82
|
yield r
|
moat/kv/command/code.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# command line interface
|
2
|
+
from __future__ import annotations
|
2
3
|
|
3
4
|
import sys
|
4
5
|
|
@@ -32,18 +33,14 @@ async def cli(ctx, path):
|
|
32
33
|
|
33
34
|
|
34
35
|
@cli.command()
|
35
|
-
@click.option(
|
36
|
-
"-s", "--script", type=click.File(mode="w", lazy=True), help="Save the code here"
|
37
|
-
)
|
36
|
+
@click.option("-s", "--script", type=click.File(mode="w", lazy=True), help="Save the code here")
|
38
37
|
@click.pass_obj
|
39
38
|
async def get(obj, script):
|
40
39
|
"""Read a code entry"""
|
41
40
|
if not len(obj.codepath):
|
42
41
|
raise click.UsageError("You need a non-empty path.")
|
43
42
|
|
44
|
-
res = await obj.client._request(
|
45
|
-
action="get_value", path=obj.path, iter=False, nchain=obj.meta
|
46
|
-
)
|
43
|
+
res = await obj.client._request(action="get_value", path=obj.path, iter=False, nchain=obj.meta)
|
47
44
|
if "value" not in res:
|
48
45
|
if obj.debug:
|
49
46
|
print("No entry here.", file=sys.stderr)
|
@@ -66,17 +63,13 @@ async def get(obj, script):
|
|
66
63
|
help="The code is async / sync (default: async)",
|
67
64
|
default=True,
|
68
65
|
)
|
69
|
-
@click.option(
|
70
|
-
"-t", "--thread", is_flag=True, help="The code should run in a worker thread"
|
71
|
-
)
|
66
|
+
@click.option("-t", "--thread", is_flag=True, help="The code should run in a worker thread")
|
72
67
|
@click.option("-s", "--script", type=click.File(mode="r"), help="File with the code")
|
73
68
|
@click.option("-i", "--info", type=str, help="one-liner info about the code")
|
74
|
-
@click.option(
|
75
|
-
"-d", "--data", type=click.File(mode="r"), help="load the metadata (YAML)"
|
76
|
-
)
|
69
|
+
@click.option("-d", "--data", type=click.File(mode="r"), help="load the metadata (YAML)")
|
77
70
|
@attr_args
|
78
71
|
@click.pass_obj
|
79
|
-
async def set_(obj, thread, script, data,
|
72
|
+
async def set_(obj, thread, script, data, async_, info, **kw):
|
80
73
|
"""Save Python code.
|
81
74
|
|
82
75
|
The code may have inputs. You specify the inputs and their default
|
@@ -119,7 +112,7 @@ async def set_(obj, thread, script, data, vars_, eval_, path_, async_, info):
|
|
119
112
|
vs = set()
|
120
113
|
vd = msg.setdefault("default", {})
|
121
114
|
|
122
|
-
vd = process_args(vd,
|
115
|
+
vd = process_args(vd, vs=vs, **kw)
|
123
116
|
msg["vars"] = list(vs)
|
124
117
|
msg["default"] = vd
|
125
118
|
|
@@ -141,9 +134,7 @@ async def mod():
|
|
141
134
|
|
142
135
|
|
143
136
|
@mod.command("get")
|
144
|
-
@click.option(
|
145
|
-
"-s", "--script", type=click.File(mode="w", lazy=True), help="Save the code here"
|
146
|
-
)
|
137
|
+
@click.option("-s", "--script", type=click.File(mode="w", lazy=True), help="Save the code here")
|
147
138
|
@click.argument("path", nargs=1)
|
148
139
|
@click.pass_obj # pylint: disable=function-redefined
|
149
140
|
async def get_mod(obj, path, script):
|
@@ -172,12 +163,8 @@ async def get_mod(obj, path, script):
|
|
172
163
|
|
173
164
|
|
174
165
|
@mod.command("set")
|
175
|
-
@click.option(
|
176
|
-
|
177
|
-
)
|
178
|
-
@click.option(
|
179
|
-
"-d", "--data", type=click.File(mode="r"), help="load the metadata (YAML)"
|
180
|
-
)
|
166
|
+
@click.option("-s", "--script", type=click.File(mode="r"), help="File with the module's code")
|
167
|
+
@click.option("-d", "--data", type=click.File(mode="r"), help="load the metadata (YAML)")
|
181
168
|
@click.argument("path", nargs=1) # pylint: disable=function-redefined
|
182
169
|
@click.pass_obj
|
183
170
|
async def set_mod(obj, path, script, data):
|
moat/kv/command/codec.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# command line interface
|
2
|
+
from __future__ import annotations
|
2
3
|
|
3
4
|
import asyncclick as click
|
4
5
|
from moat.util import NotGiven, P, Path, PathLongener, yload, yprint
|
@@ -11,15 +12,9 @@ async def cli():
|
|
11
12
|
|
12
13
|
|
13
14
|
@cli.command()
|
14
|
-
@click.option(
|
15
|
-
|
16
|
-
)
|
17
|
-
@click.option(
|
18
|
-
"-d", "--decode", type=click.File(mode="w", lazy=True), help="Save the decoder here"
|
19
|
-
)
|
20
|
-
@click.option(
|
21
|
-
"-s", "--script", type=click.File(mode="w", lazy=True), help="Save the data here"
|
22
|
-
)
|
15
|
+
@click.option("-e", "--encode", type=click.File(mode="w", lazy=True), help="Save the encoder here")
|
16
|
+
@click.option("-d", "--decode", type=click.File(mode="w", lazy=True), help="Save the decoder here")
|
17
|
+
@click.option("-s", "--script", type=click.File(mode="w", lazy=True), help="Save the data here")
|
23
18
|
@click.argument("path", nargs=1)
|
24
19
|
@click.pass_obj
|
25
20
|
async def get(obj, path, script, encode, decode):
|
@@ -28,7 +23,10 @@ async def get(obj, path, script, encode, decode):
|
|
28
23
|
if not len(path):
|
29
24
|
raise click.UsageError("You need a non-empty path.")
|
30
25
|
res = await obj.client._request(
|
31
|
-
action="get_internal",
|
26
|
+
action="get_internal",
|
27
|
+
path=Path("codec") + path,
|
28
|
+
iter=False,
|
29
|
+
nchain=obj.meta,
|
32
30
|
)
|
33
31
|
if encode and res.get("encode", None) is not None:
|
34
32
|
encode.write(res.pop("encode"))
|
@@ -166,13 +164,11 @@ async def convert(obj, path, codec, name, delete, list_):
|
|
166
164
|
try:
|
167
165
|
print(f"{r.path} : {Path.build(r.value['codec'])}", file=obj.stdout)
|
168
166
|
except Exception as e:
|
169
|
-
print(f"{Path(r.path)} {e
|
167
|
+
print(f"{Path(r.path)} {e!r}", file=obj.stdout)
|
170
168
|
|
171
169
|
return
|
172
170
|
if delete:
|
173
|
-
res = await obj.client._request(
|
174
|
-
action="delete_internal", path=Path("conv", name) + path
|
175
|
-
)
|
171
|
+
res = await obj.client._request(action="delete_internal", path=Path("conv", name) + path)
|
176
172
|
else:
|
177
173
|
msg = {"codec": codec}
|
178
174
|
res = await obj.client._request(
|
moat/kv/command/data.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# command line interface
|
2
|
+
from __future__ import annotations
|
2
3
|
|
3
4
|
import datetime
|
4
5
|
import time
|
@@ -47,9 +48,7 @@ async def cli(ctx, path):
|
|
47
48
|
)
|
48
49
|
@click.option("-r", "--recursive", is_flag=True, help="Read a complete subtree")
|
49
50
|
@click.option("-e", "--empty", is_flag=True, help="Include empty nodes")
|
50
|
-
@click.option(
|
51
|
-
"-R", "--raw", is_flag=True, help="Print string values without quotes etc."
|
52
|
-
)
|
51
|
+
@click.option("-R", "--raw", is_flag=True, help="Print string values without quotes etc.")
|
53
52
|
@click.option("-D", "--add-date", is_flag=True, help="Add *_date entries")
|
54
53
|
@click.pass_obj
|
55
54
|
async def get(obj, **k):
|
@@ -109,7 +108,7 @@ async def list_(obj, **k):
|
|
109
108
|
@click.option("-l", "--last", nargs=2, help="Previous change entry (node serial)")
|
110
109
|
@click.option("-n", "--new", is_flag=True, help="This is a new entry.")
|
111
110
|
@click.pass_obj
|
112
|
-
async def set_(obj,
|
111
|
+
async def set_(obj, last, new, **kw):
|
113
112
|
"""
|
114
113
|
Store a value at some MoaT-KV position.
|
115
114
|
|
@@ -123,16 +122,15 @@ async def set_(obj, vars_, eval_, path_, last, new):
|
|
123
122
|
MoaT-KV entries typically are mappings. Use a colon as the path if you
|
124
123
|
want to replace the top level.
|
125
124
|
"""
|
126
|
-
args = {}
|
127
125
|
if new:
|
128
126
|
if last:
|
129
127
|
raise click.UsageError("'new' and 'last' are mutually exclusive")
|
130
|
-
|
128
|
+
kw["chain"] = None
|
131
129
|
else:
|
132
130
|
if last:
|
133
|
-
|
131
|
+
kw["chain"] = {"node": last[0], "tick": int(last[1])}
|
134
132
|
|
135
|
-
res = await node_attr(obj, obj.path,
|
133
|
+
res = await node_attr(obj, obj.path, **kw)
|
136
134
|
|
137
135
|
if obj.meta:
|
138
136
|
yprint(res, stream=obj.stdout)
|
@@ -156,9 +154,7 @@ class nstr:
|
|
156
154
|
@click.option("-l", "--last", nargs=2, help="Previous change entry (node serial)")
|
157
155
|
@click.option("-r", "--recursive", is_flag=True, help="Delete a complete subtree")
|
158
156
|
@click.option("--internal", is_flag=True, help="Affect the internal tree. DANGER.")
|
159
|
-
@click.option(
|
160
|
-
"-e", "--eval", "eval_", is_flag=True, help="The previous value shall be evaluated."
|
161
|
-
)
|
157
|
+
@click.option("-e", "--eval", "eval_", is_flag=True, help="The previous value shall be evaluated.")
|
162
158
|
@click.pass_obj
|
163
159
|
async def delete(obj, prev, last, recursive, eval_, internal):
|
164
160
|
"""
|
@@ -178,9 +174,7 @@ async def delete(obj, prev, last, recursive, eval_, internal):
|
|
178
174
|
raise click.UsageError("You need to add a value that can be evaluated")
|
179
175
|
if recursive:
|
180
176
|
if prev is not NotGiven or last:
|
181
|
-
raise click.UsageError(
|
182
|
-
"You can't use a prev value when deleting recursively."
|
183
|
-
)
|
177
|
+
raise click.UsageError("You can't use a prev value when deleting recursively.")
|
184
178
|
if internal:
|
185
179
|
raise click.UsageError("'internal' and 'recursive' are mutually exclusive")
|
186
180
|
else:
|
@@ -191,9 +185,7 @@ async def delete(obj, prev, last, recursive, eval_, internal):
|
|
191
185
|
if last:
|
192
186
|
args["chain"] = {"node": last[0], "tick": int(last[1])}
|
193
187
|
|
194
|
-
res = await obj.client.delete(
|
195
|
-
path=obj.path, nchain=obj.meta, recursive=recursive, **args
|
196
|
-
)
|
188
|
+
res = await obj.client.delete(path=obj.path, nchain=obj.meta, recursive=recursive, **args)
|
197
189
|
if isinstance(res, StreamedRequest):
|
198
190
|
pl = PathLongener(obj.path)
|
199
191
|
async for r in res:
|
@@ -221,7 +213,8 @@ async def monitor(obj, state, only, path_only, add_date, ignore):
|
|
221
213
|
async with obj.client.watch(
|
222
214
|
obj.path,
|
223
215
|
nchain=obj.meta,
|
224
|
-
fetch=state,
|
216
|
+
fetch=state,
|
217
|
+
max_depth=0 if only else -1,
|
225
218
|
long_path=False,
|
226
219
|
) as res:
|
227
220
|
pl = PathLongener(() if path_only else obj.path)
|
@@ -252,9 +245,7 @@ async def monitor(obj, state, only, path_only, add_date, ignore):
|
|
252
245
|
continue
|
253
246
|
if flushing:
|
254
247
|
r["time"] = time.time()
|
255
|
-
r["_time"] = datetime.datetime.now().isoformat(
|
256
|
-
sep=" ", timespec="milliseconds"
|
257
|
-
)
|
248
|
+
r["_time"] = datetime.datetime.now().isoformat(sep=" ", timespec="milliseconds")
|
258
249
|
yprint(r, stream=obj.stdout)
|
259
250
|
print("---", file=obj.stdout)
|
260
251
|
if flushing:
|
moat/kv/command/dump/__init__.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# command line interface
|
2
|
+
from __future__ import annotations
|
2
3
|
|
3
4
|
import datetime
|
4
5
|
import sys
|
@@ -49,7 +50,7 @@ async def init(node, file):
|
|
49
50
|
path=[],
|
50
51
|
tock=1,
|
51
52
|
value="Initial data",
|
52
|
-
)
|
53
|
+
),
|
53
54
|
)
|
54
55
|
|
55
56
|
|
@@ -109,7 +110,8 @@ async def msg_(obj, path):
|
|
109
110
|
v["_type"] = type(msg).__name__
|
110
111
|
|
111
112
|
v["_timestamp"] = datetime.datetime.now().isoformat(
|
112
|
-
sep=" ",
|
113
|
+
sep=" ",
|
114
|
+
timespec="milliseconds",
|
113
115
|
)
|
114
116
|
|
115
117
|
yprint(v, stream=obj.stdout)
|
moat/kv/command/error.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# command line interface
|
2
|
+
from __future__ import annotations
|
2
3
|
|
3
4
|
import sys
|
4
5
|
|
@@ -37,17 +38,11 @@ async def resolve(obj, path, subsys):
|
|
37
38
|
|
38
39
|
@cli.command()
|
39
40
|
@click.option("-n", "--node", help="add details from this node")
|
40
|
-
@click.option(
|
41
|
-
"-s", "--subsystem", "subsys", help="only show errors from this subsystem"
|
42
|
-
)
|
41
|
+
@click.option("-s", "--subsystem", "subsys", help="only show errors from this subsystem")
|
43
42
|
@click.option("-r", "--resolved", is_flag=True, help="only resolved errors")
|
44
|
-
@click.option(
|
45
|
-
"-v", "--verbose", count=True, help="add per-node details (-vv for traces)"
|
46
|
-
)
|
43
|
+
@click.option("-v", "--verbose", count=True, help="add per-node details (-vv for traces)")
|
47
44
|
@click.option("-a", "--all-errors", is_flag=True, help="add details from all nodes")
|
48
|
-
@click.option(
|
49
|
-
"-d", "--as-dict", default=None, help="Dump a list of all open (or resolved) error."
|
50
|
-
)
|
45
|
+
@click.option("-d", "--as-dict", default=None, help="Dump a list of all open (or resolved) error.")
|
51
46
|
@click.option("-p", "--path", default=":", help="only show errors below this subpath")
|
52
47
|
@click.pass_obj
|
53
48
|
async def dump(obj, as_dict, path, node, all_errors, verbose, resolved, subsys):
|
@@ -146,9 +141,7 @@ async def dump(obj, as_dict, path, node, all_errors, verbose, resolved, subsys):
|
|
146
141
|
path = ()
|
147
142
|
|
148
143
|
if res is None:
|
149
|
-
res = obj.client.get_tree(
|
150
|
-
path_, min_depth=d, max_depth=d, nchain=3 if obj.meta else 0
|
151
|
-
)
|
144
|
+
res = obj.client.get_tree(path_, min_depth=d, max_depth=d, nchain=3 if obj.meta else 0)
|
152
145
|
async for r in res:
|
153
146
|
await one(r)
|
154
147
|
|
moat/kv/command/internal.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# command line interface
|
2
|
+
from __future__ import annotations
|
2
3
|
|
3
4
|
from collections.abc import Mapping
|
4
5
|
|
@@ -30,9 +31,7 @@ async def cli():
|
|
30
31
|
@click.option("-s", "--superseded", is_flag=True, help="Get superseded-data status.")
|
31
32
|
@click.option("-D", "--debug", is_flag=True, help="Get internal verbosity.")
|
32
33
|
@click.option("--debugger", is_flag=True, help="Start a remote debugger. DO NOT USE.")
|
33
|
-
@click.option(
|
34
|
-
"-k", "--known", hidden=True, is_flag=True, help="Get superseded-data status."
|
35
|
-
)
|
34
|
+
@click.option("-k", "--known", hidden=True, is_flag=True, help="Get superseded-data status.")
|
36
35
|
@click.option("-a", "--all", is_flag=True, help="All available data.")
|
37
36
|
@click.pass_obj
|
38
37
|
async def state(obj, **flags):
|
@@ -56,9 +55,7 @@ async def state(obj, **flags):
|
|
56
55
|
|
57
56
|
|
58
57
|
@cli.command()
|
59
|
-
@click.option(
|
60
|
-
"-d", "--deleted", is_flag=True, help="Mark as deleted. Default: superseded"
|
61
|
-
)
|
58
|
+
@click.option("-d", "--deleted", is_flag=True, help="Mark as deleted. Default: superseded")
|
62
59
|
@click.option(
|
63
60
|
"-n",
|
64
61
|
"--node",
|
@@ -170,9 +167,7 @@ async def dump(obj, path):
|
|
170
167
|
path = P(path)
|
171
168
|
y = {}
|
172
169
|
pl = PathLongener()
|
173
|
-
async for r in await obj.client._request(
|
174
|
-
"get_tree_internal", path=path, iter=True, nchain=0
|
175
|
-
):
|
170
|
+
async for r in await obj.client._request("get_tree_internal", path=path, iter=True, nchain=0):
|
176
171
|
pl(r)
|
177
172
|
path = r["path"]
|
178
173
|
yy = y
|
@@ -227,17 +222,13 @@ async def enum(obj, node, num, current, copy):
|
|
227
222
|
else:
|
228
223
|
for k in res.result:
|
229
224
|
if copy or obj.debug > 1:
|
230
|
-
res = await obj.client._request(
|
231
|
-
"get_value", node=node, tick=k, nchain=3
|
232
|
-
)
|
225
|
+
res = await obj.client._request("get_value", node=node, tick=k, nchain=3)
|
233
226
|
if obj.debug > 1:
|
234
227
|
print(k, res.path)
|
235
228
|
else:
|
236
229
|
print(k)
|
237
230
|
if copy and res.chain.node == node:
|
238
|
-
res = await obj.client.set(
|
239
|
-
res.path, value=res.value, chain=res.chain
|
240
|
-
)
|
231
|
+
res = await obj.client.set(res.path, value=res.value, chain=res.chain)
|
241
232
|
else:
|
242
233
|
print(k)
|
243
234
|
|
moat/kv/command/job.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# command line interface
|
2
|
+
from __future__ import annotations
|
2
3
|
|
3
4
|
import sys
|
4
5
|
import time
|
@@ -14,9 +15,7 @@ from moat.kv.runner import AllRunnerRoot, AnyRunnerRoot, SingleRunnerRoot
|
|
14
15
|
|
15
16
|
|
16
17
|
@click.group() # pylint: disable=undefined-variable
|
17
|
-
@click.option(
|
18
|
-
"-n", "--node", help="node to run this code on. Empty: any one node, '-': all nodes"
|
19
|
-
)
|
18
|
+
@click.option("-n", "--node", help="node to run this code on. Empty: any one node, '-': all nodes")
|
20
19
|
@click.option("-g", "--group", help="group to run this code on. Empty: default")
|
21
20
|
@click.pass_context
|
22
21
|
async def cli(ctx, node, group):
|
@@ -56,9 +55,7 @@ async def cli(ctx, node, group):
|
|
56
55
|
obj.statepath = cfg["state"] + obj.subpath
|
57
56
|
|
58
57
|
|
59
|
-
@cli.group(
|
60
|
-
"at", short_help="path of the job to operate on", invoke_without_command=True
|
61
|
-
)
|
58
|
+
@cli.group("at", short_help="path of the job to operate on", invoke_without_command=True)
|
62
59
|
@click.argument("path", nargs=1, type=P)
|
63
60
|
@click.pass_context
|
64
61
|
async def at_cli(ctx, path):
|
@@ -70,7 +67,10 @@ async def at_cli(ctx, path):
|
|
70
67
|
|
71
68
|
if ctx.invoked_subcommand is None:
|
72
69
|
res = await obj.client.get(obj.path + path, nchain=obj.meta)
|
73
|
-
yprint(
|
70
|
+
yprint(
|
71
|
+
res if obj.meta else res.value if "value" in res else None,
|
72
|
+
stream=obj.stdout,
|
73
|
+
)
|
74
74
|
|
75
75
|
|
76
76
|
@cli.command("info")
|
@@ -141,7 +141,10 @@ async def run(obj, nodes):
|
|
141
141
|
c = obj.client
|
142
142
|
cr = await CodeRoot.as_handler(c)
|
143
143
|
await obj.runner_root.as_handler(
|
144
|
-
c,
|
144
|
+
c,
|
145
|
+
subpath=obj.subpath,
|
146
|
+
code=cr,
|
147
|
+
**({"nodes": nodes} if nodes else {}),
|
145
148
|
)
|
146
149
|
evt.set()
|
147
150
|
await anyio.sleep_forever()
|
@@ -154,7 +157,10 @@ async def _state_fix(obj, state, state_only, path, r):
|
|
154
157
|
return
|
155
158
|
if state:
|
156
159
|
rs = await obj.client._request(
|
157
|
-
action="get_value",
|
160
|
+
action="get_value",
|
161
|
+
path=state + r.path,
|
162
|
+
iter=False,
|
163
|
+
nchain=obj.meta,
|
158
164
|
)
|
159
165
|
if state_only:
|
160
166
|
r.value = rs
|
@@ -235,9 +241,7 @@ async def list_(obj, state, state_only, table, as_dict):
|
|
235
241
|
obj,
|
236
242
|
obj.path + path,
|
237
243
|
as_dict=as_dict,
|
238
|
-
item_mangle=partial(
|
239
|
-
_state_fix, obj, state, state_only, None if as_dict else path
|
240
|
-
),
|
244
|
+
item_mangle=partial(_state_fix, obj, state, state_only, None if as_dict else path),
|
241
245
|
)
|
242
246
|
|
243
247
|
|
@@ -280,7 +284,10 @@ async def get(obj, state):
|
|
280
284
|
raise click.UsageError("You need a non-empty path.")
|
281
285
|
|
282
286
|
res = await obj.client._request(
|
283
|
-
action="get_value",
|
287
|
+
action="get_value",
|
288
|
+
path=obj.path + path,
|
289
|
+
iter=False,
|
290
|
+
nchain=obj.meta,
|
284
291
|
)
|
285
292
|
if "value" not in res:
|
286
293
|
print("Not found.", file=sys.stderr)
|
@@ -316,18 +323,12 @@ async def delete(obj, force):
|
|
316
323
|
val.target = None
|
317
324
|
if val.target is not None:
|
318
325
|
val.target = None
|
319
|
-
res = await obj.client.set(
|
320
|
-
obj.path + path, value=val, nchain=3, chain=res.chain
|
321
|
-
)
|
326
|
+
res = await obj.client.set(obj.path + path, value=val, nchain=3, chain=res.chain)
|
322
327
|
if not force:
|
323
328
|
res.info = "'target' was set: cleared but not deleted."
|
324
329
|
if force or val.target is None:
|
325
330
|
sres = await obj.client.get(obj.statepath + path, nchain=3)
|
326
|
-
if
|
327
|
-
not force
|
328
|
-
and "value" in sres
|
329
|
-
and sres.value.stopped < sres.value.started
|
330
|
-
):
|
331
|
+
if not force and "value" in sres and sres.value.stopped < sres.value.started:
|
331
332
|
res.info = "Still running, not deleted."
|
332
333
|
else:
|
333
334
|
sres = await obj.client.delete(obj.statepath + path, chain=sres.chain)
|
@@ -350,15 +351,11 @@ async def delete(obj, force):
|
|
350
351
|
@click.option("-r", "--repeat", type=int, help="Seconds the code should re-run after")
|
351
352
|
@click.option("-k", "--ok", type=float, help="Code is OK if it ran this many seconds")
|
352
353
|
@click.option("-b", "--backoff", type=float, help="Back-off factor. Default: 1.4")
|
353
|
-
@click.option(
|
354
|
-
"-d", "--delay", type=int, help="Seconds the code should retry after (w/ backoff)"
|
355
|
-
)
|
354
|
+
@click.option("-d", "--delay", type=int, help="Seconds the code should retry after (w/ backoff)")
|
356
355
|
@click.option("-i", "--info", help="Short human-readable information")
|
357
356
|
@attr_args
|
358
357
|
@click.pass_obj
|
359
|
-
async def set_(
|
360
|
-
obj, code, tm, info, ok, repeat, delay, backoff, copy, vars_, eval_, path_
|
361
|
-
):
|
358
|
+
async def set_(obj, code, tm, info, ok, repeat, delay, backoff, copy, **kw):
|
362
359
|
"""Add or modify a runner.
|
363
360
|
|
364
361
|
Code typically requires some input parameters.
|
@@ -377,9 +374,7 @@ async def set_(
|
|
377
374
|
copy = P(copy)
|
378
375
|
path = obj.path + P(path)
|
379
376
|
|
380
|
-
res = await obj.client._request(
|
381
|
-
action="get_value", path=copy or path, iter=False, nchain=3
|
382
|
-
)
|
377
|
+
res = await obj.client._request(action="get_value", path=copy or path, iter=False, nchain=3)
|
383
378
|
if "value" not in res:
|
384
379
|
if copy:
|
385
380
|
raise click.UsageError("--copy: use the complete path to an existing entry")
|
@@ -394,7 +389,7 @@ async def set_(
|
|
394
389
|
raise click.UsageError("'--copy' needs a runner entry")
|
395
390
|
|
396
391
|
vl = attrdict(**res.setdefault("data", {}))
|
397
|
-
vl = process_args(vl,
|
392
|
+
vl = process_args(vl, **kw)
|
398
393
|
res["data"] = vl
|
399
394
|
|
400
395
|
if code is not None:
|
moat/kv/command/log.py
CHANGED
moat/kv/command/server.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# command line interface
|
2
|
+
from __future__ import annotations
|
2
3
|
|
3
4
|
import asyncclick as click
|
4
5
|
|
@@ -99,9 +100,7 @@ async def cli(obj, name, load, save, init, incremental, eval_, auth, force, node
|
|
99
100
|
from moat.util import as_service
|
100
101
|
|
101
102
|
if load and nodes:
|
102
|
-
raise click.UsageError(
|
103
|
-
"Either read from a file or fetch from a node. Not both."
|
104
|
-
)
|
103
|
+
raise click.UsageError("Either read from a file or fetch from a node. Not both.")
|
105
104
|
if auth and force:
|
106
105
|
raise click.UsageError("Using both '-a' and '-f' is redundant. Choose one.")
|
107
106
|
|