moat-kv 0.71.0__py3-none-any.whl → 0.71.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.
- moat/kv/__init__.py +6 -7
- moat/kv/_cfg.yaml +3 -2
- moat/kv/actor/__init__.py +2 -1
- moat/kv/actor/deletor.py +4 -1
- moat/kv/auth/__init__.py +12 -13
- moat/kv/auth/_test.py +4 -1
- moat/kv/auth/password.py +11 -7
- moat/kv/backend/mqtt.py +4 -5
- moat/kv/client.py +20 -39
- moat/kv/code.py +3 -3
- moat/kv/command/data.py +4 -3
- moat/kv/command/dump/__init__.py +36 -34
- moat/kv/command/internal.py +2 -3
- moat/kv/command/job.py +1 -2
- moat/kv/command/type.py +3 -6
- moat/kv/data.py +9 -8
- moat/kv/errors.py +16 -8
- moat/kv/mock/__init__.py +2 -12
- moat/kv/model.py +29 -33
- moat/kv/obj/__init__.py +3 -3
- moat/kv/obj/command.py +3 -3
- moat/kv/runner.py +4 -5
- moat/kv/server.py +106 -126
- moat/kv/types.py +10 -12
- {moat_kv-0.71.0.dist-info → moat_kv-0.71.7.dist-info}/METADATA +6 -2
- moat_kv-0.71.7.dist-info/RECORD +47 -0
- {moat_kv-0.71.0.dist-info → moat_kv-0.71.7.dist-info}/WHEEL +1 -1
- moat_kv-0.71.7.dist-info/licenses/LICENSE +3 -0
- moat_kv-0.71.7.dist-info/licenses/LICENSE.APACHE2 +202 -0
- moat_kv-0.71.7.dist-info/licenses/LICENSE.MIT +20 -0
- moat_kv-0.71.7.dist-info/top_level.txt +1 -0
- build/lib/docs/source/conf.py +0 -201
- build/lib/examples/pathify.py +0 -45
- build/lib/moat/kv/__init__.py +0 -19
- build/lib/moat/kv/_cfg.yaml +0 -93
- build/lib/moat/kv/_main.py +0 -91
- build/lib/moat/kv/actor/__init__.py +0 -98
- build/lib/moat/kv/actor/deletor.py +0 -139
- build/lib/moat/kv/auth/__init__.py +0 -444
- build/lib/moat/kv/auth/_test.py +0 -166
- build/lib/moat/kv/auth/password.py +0 -234
- build/lib/moat/kv/auth/root.py +0 -58
- build/lib/moat/kv/backend/__init__.py +0 -67
- build/lib/moat/kv/backend/mqtt.py +0 -71
- build/lib/moat/kv/client.py +0 -1025
- build/lib/moat/kv/code.py +0 -236
- build/lib/moat/kv/codec.py +0 -11
- build/lib/moat/kv/command/__init__.py +0 -1
- build/lib/moat/kv/command/acl.py +0 -180
- build/lib/moat/kv/command/auth.py +0 -261
- build/lib/moat/kv/command/code.py +0 -293
- build/lib/moat/kv/command/codec.py +0 -186
- build/lib/moat/kv/command/data.py +0 -265
- build/lib/moat/kv/command/dump/__init__.py +0 -143
- build/lib/moat/kv/command/error.py +0 -149
- build/lib/moat/kv/command/internal.py +0 -248
- build/lib/moat/kv/command/job.py +0 -433
- build/lib/moat/kv/command/log.py +0 -53
- build/lib/moat/kv/command/server.py +0 -114
- build/lib/moat/kv/command/type.py +0 -201
- build/lib/moat/kv/config.py +0 -46
- build/lib/moat/kv/data.py +0 -216
- build/lib/moat/kv/errors.py +0 -561
- build/lib/moat/kv/exceptions.py +0 -126
- build/lib/moat/kv/mock/__init__.py +0 -101
- build/lib/moat/kv/mock/mqtt.py +0 -159
- build/lib/moat/kv/mock/tracer.py +0 -63
- build/lib/moat/kv/model.py +0 -1069
- build/lib/moat/kv/obj/__init__.py +0 -646
- build/lib/moat/kv/obj/command.py +0 -241
- build/lib/moat/kv/runner.py +0 -1347
- build/lib/moat/kv/server.py +0 -2809
- build/lib/moat/kv/types.py +0 -513
- ci/rtd-requirements.txt +0 -4
- ci/test-requirements.txt +0 -7
- ci/travis.sh +0 -96
- debian/.gitignore +0 -7
- debian/changelog +0 -1435
- debian/control +0 -43
- debian/moat-kv/usr/lib/python3/dist-packages/docs/source/conf.py +0 -201
- debian/moat-kv/usr/lib/python3/dist-packages/examples/pathify.py +0 -45
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/__init__.py +0 -19
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/_cfg.yaml +0 -93
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/_main.py +0 -91
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/actor/__init__.py +0 -98
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/actor/deletor.py +0 -139
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/__init__.py +0 -444
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/_test.py +0 -166
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/password.py +0 -234
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/auth/root.py +0 -58
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/__init__.py +0 -67
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/backend/mqtt.py +0 -71
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/client.py +0 -1025
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/code.py +0 -236
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/codec.py +0 -11
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/__init__.py +0 -1
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/acl.py +0 -180
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/auth.py +0 -261
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/code.py +0 -293
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/codec.py +0 -186
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/data.py +0 -265
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/dump/__init__.py +0 -143
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/error.py +0 -149
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/internal.py +0 -248
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/job.py +0 -433
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/log.py +0 -53
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/server.py +0 -114
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/command/type.py +0 -201
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/config.py +0 -46
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/data.py +0 -216
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/errors.py +0 -561
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/exceptions.py +0 -126
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/__init__.py +0 -101
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/mqtt.py +0 -159
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/mock/tracer.py +0 -63
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/model.py +0 -1069
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/obj/__init__.py +0 -646
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/obj/command.py +0 -241
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/runner.py +0 -1347
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/server.py +0 -2809
- debian/moat-kv/usr/lib/python3/dist-packages/moat/kv/types.py +0 -513
- debian/moat-kv.postinst +0 -3
- debian/rules +0 -20
- debian/source/format +0 -1
- debian/watch +0 -4
- docs/Makefile +0 -20
- docs/make.bat +0 -36
- docs/source/TODO.rst +0 -61
- docs/source/_static/.gitkeep +0 -0
- docs/source/acls.rst +0 -80
- docs/source/auth.rst +0 -84
- docs/source/client_protocol.rst +0 -456
- docs/source/code.rst +0 -341
- docs/source/command_line.rst +0 -1187
- docs/source/common_protocol.rst +0 -47
- docs/source/conf.py +0 -201
- docs/source/debugging.rst +0 -70
- docs/source/extend.rst +0 -37
- docs/source/history.rst +0 -36
- docs/source/index.rst +0 -75
- docs/source/model.rst +0 -54
- docs/source/overview.rst +0 -83
- docs/source/related.rst +0 -89
- docs/source/server_protocol.rst +0 -450
- docs/source/startup.rst +0 -31
- docs/source/translator.rst +0 -244
- docs/source/tutorial.rst +0 -711
- docs/source/v3.rst +0 -168
- examples/code/transform.scale.yml +0 -21
- examples/code/transform.switch.yml +0 -82
- examples/code/transform.timeslot.yml +0 -63
- examples/pathify.py +0 -45
- moat/kv/codec.py +0 -11
- moat_kv-0.71.0.dist-info/RECORD +0 -188
- moat_kv-0.71.0.dist-info/top_level.txt +0 -9
- scripts/current +0 -15
- scripts/env +0 -8
- scripts/init +0 -39
- scripts/recover +0 -17
- scripts/rotate +0 -33
- scripts/run +0 -29
- scripts/run-all +0 -10
- scripts/run-any +0 -10
- scripts/run-single +0 -15
- scripts/success +0 -4
- systemd/moat-kv-recover.service +0 -21
- systemd/moat-kv-rotate.service +0 -20
- systemd/moat-kv-rotate.timer +0 -10
- systemd/moat-kv-run-all.service +0 -26
- systemd/moat-kv-run-all@.service +0 -25
- systemd/moat-kv-run-any.service +0 -26
- systemd/moat-kv-run-any@.service +0 -25
- systemd/moat-kv-run-single.service +0 -26
- systemd/moat-kv-run-single@.service +0 -25
- systemd/moat-kv.service +0 -27
- systemd/postinst +0 -7
- systemd/sysusers +0 -3
- {moat_kv-0.71.0.dist-info → moat_kv-0.71.7.dist-info}/licenses/LICENSE.txt +0 -0
build/lib/moat/kv/obj/command.py
DELETED
@@ -1,241 +0,0 @@
|
|
1
|
-
# command line interface helpers for objects
|
2
|
-
from __future__ import annotations
|
3
|
-
|
4
|
-
import logging
|
5
|
-
import sys
|
6
|
-
|
7
|
-
import asyncclick as click
|
8
|
-
from moat.util import NotGiven
|
9
|
-
|
10
|
-
logger = logging.getLogger(__name__)
|
11
|
-
|
12
|
-
__all__ = ["std_command"]
|
13
|
-
|
14
|
-
|
15
|
-
class _InvSub:
|
16
|
-
"""
|
17
|
-
This class is a helper for "std_command".
|
18
|
-
"""
|
19
|
-
|
20
|
-
def __init__(
|
21
|
-
self,
|
22
|
-
name,
|
23
|
-
id_name="name",
|
24
|
-
id_typ=str,
|
25
|
-
aux=(),
|
26
|
-
name_cb=None,
|
27
|
-
id_cb=None,
|
28
|
-
postproc=None,
|
29
|
-
apply=None,
|
30
|
-
short_help=None,
|
31
|
-
sub_base=None,
|
32
|
-
sub_name=None,
|
33
|
-
long_name=None,
|
34
|
-
prepare=None,
|
35
|
-
list_recursive=False,
|
36
|
-
):
|
37
|
-
self.name = name
|
38
|
-
self.id_name = id_name
|
39
|
-
self.id_typ = id_typ
|
40
|
-
self.id_cb = id_cb or (lambda _c, _k, x: x)
|
41
|
-
self.apply = apply or (lambda _c, _t, _x: None)
|
42
|
-
self.name_cb = name_cb or (lambda _c, _k, x: x)
|
43
|
-
self.aux = aux
|
44
|
-
self.short_help = short_help
|
45
|
-
self.postproc = postproc or (lambda _c, _t, x: None)
|
46
|
-
self.long_name = long_name or name
|
47
|
-
self.sub_base = sub_base
|
48
|
-
self.prepare = prepare
|
49
|
-
self.list_recursive = list_recursive
|
50
|
-
if sub_name is NotGiven:
|
51
|
-
self.sub_name = None
|
52
|
-
else:
|
53
|
-
self.sub_name = sub_name or name
|
54
|
-
|
55
|
-
def id_arg(self, proc):
|
56
|
-
if self.id_name is None:
|
57
|
-
return proc
|
58
|
-
return click.argument(self.id_name, type=self.id_typ, callback=self.id_cb, nargs=1)(proc)
|
59
|
-
|
60
|
-
def apply_aux(self, proc):
|
61
|
-
for t in self.aux:
|
62
|
-
proc = t(proc)
|
63
|
-
return proc
|
64
|
-
|
65
|
-
|
66
|
-
def std_command(cli, *a, **kw):
|
67
|
-
"""
|
68
|
-
This procedure builds the interface for an inventory-ish thing.
|
69
|
-
|
70
|
-
Usage::
|
71
|
-
|
72
|
-
@click.group(short_help="Manage computer inventory.")
|
73
|
-
@click.pass_obj
|
74
|
-
async def cli(obj):
|
75
|
-
"Inventorize your computers, networks, and their connections."
|
76
|
-
obj.inv = await InventoryRoot.as_handler(obj.client)
|
77
|
-
|
78
|
-
std_command(
|
79
|
-
cli, # from above
|
80
|
-
"vlan", # subcommand name
|
81
|
-
"id", # item identifier
|
82
|
-
int, # item identifier type
|
83
|
-
aux=( # additional attributes
|
84
|
-
click.option("-d", "--desc", type=str, default=None, help="Description"),
|
85
|
-
click.option("-w", "--wlan", type=str, default=None, help="WLAN SSID"),
|
86
|
-
),
|
87
|
-
short_help="Manage VLANs",
|
88
|
-
)
|
89
|
-
"""
|
90
|
-
tinv = _InvSub(*a, **kw)
|
91
|
-
tname = tinv.name
|
92
|
-
tnname = "n_" + tname
|
93
|
-
|
94
|
-
def this(obj):
|
95
|
-
# Delayed resolving of the actual thing subhierarchy
|
96
|
-
if tinv.sub_base:
|
97
|
-
data = getattr(obj, tinv.sub_base)
|
98
|
-
else:
|
99
|
-
data = obj.data
|
100
|
-
if tinv.sub_name:
|
101
|
-
return getattr(data, tinv.sub_name)
|
102
|
-
return data
|
103
|
-
|
104
|
-
@cli.group(
|
105
|
-
name=tname,
|
106
|
-
invoke_without_command=True,
|
107
|
-
short_help=tinv.short_help,
|
108
|
-
help=f"""\
|
109
|
-
Manager for {tinv.long_name}s.
|
110
|
-
|
111
|
-
\b
|
112
|
-
Use '… {tname} -' to list all entries.
|
113
|
-
Use '… {tname} NAME' to show details of a single entry.
|
114
|
-
""",
|
115
|
-
)
|
116
|
-
@click.argument("name", type=str, nargs=1)
|
117
|
-
@click.pass_context
|
118
|
-
async def typ(ctx, name):
|
119
|
-
obj = ctx.obj
|
120
|
-
if tinv.prepare is not None:
|
121
|
-
await tinv.prepare(obj)
|
122
|
-
|
123
|
-
if name == "-":
|
124
|
-
if ctx.invoked_subcommand is not None:
|
125
|
-
raise click.BadParameter("The name '-' triggers a list and precludes subcommands.")
|
126
|
-
cnt = 0
|
127
|
-
for n in this(obj).all_children if tinv.list_recursive else this(obj):
|
128
|
-
cnt += 1
|
129
|
-
print(n, file=obj.stdout)
|
130
|
-
if not cnt and ctx.obj.debug:
|
131
|
-
print("no entries", file=sys.stderr)
|
132
|
-
elif ctx.invoked_subcommand is None:
|
133
|
-
# Show data from a single entry
|
134
|
-
n = this(obj).by_name(name)
|
135
|
-
if n is None:
|
136
|
-
raise KeyError(name)
|
137
|
-
cnt = 0
|
138
|
-
for k in n.ATTRS + getattr(n, "AUX_ATTRS", ()):
|
139
|
-
v = getattr(n, k, None)
|
140
|
-
if v is not None:
|
141
|
-
cnt += 1
|
142
|
-
if isinstance(v, dict):
|
143
|
-
v = v.items()
|
144
|
-
if isinstance(v, type({}.items())): # pylint: disable=W1116
|
145
|
-
for kk, vv in sorted(v):
|
146
|
-
if isinstance(vv, (tuple, list)):
|
147
|
-
if vv:
|
148
|
-
vv = " ".join(str(x) for x in vv)
|
149
|
-
else:
|
150
|
-
vv = "-"
|
151
|
-
elif isinstance(vv, dict):
|
152
|
-
vv = " ".join("%s=%s" % (x, y) for x, y in sorted(vv.items()))
|
153
|
-
print("%s %s %s" % (k, kk, vv), file=obj.stdout)
|
154
|
-
else:
|
155
|
-
print("%s %s" % (k, v), file=obj.stdout)
|
156
|
-
if not cnt and ctx.obj.debug:
|
157
|
-
print("exists, no data", file=sys.stderr)
|
158
|
-
else:
|
159
|
-
obj[tnname] = name
|
160
|
-
try:
|
161
|
-
obj[tname] = this(obj).by_name(name)
|
162
|
-
except KeyError:
|
163
|
-
obj[tname] = None
|
164
|
-
|
165
|
-
def alloc(obj, name):
|
166
|
-
# Allocate a new thing
|
167
|
-
if isinstance(name, (tuple, list)):
|
168
|
-
n = this(obj).follow(name, create=True)
|
169
|
-
else:
|
170
|
-
n = this(obj).allocate(name)
|
171
|
-
return n
|
172
|
-
|
173
|
-
# This is a hack for groups that take arguments. Doesn't work for
|
174
|
-
# multiple arguments, but you shouldn't do that anyway.
|
175
|
-
@typ.command("--help", hidden=True)
|
176
|
-
@click.pass_context
|
177
|
-
def help_(ctx): # pylint:disable=unused-variable # oh boy
|
178
|
-
print(typ.get_help(ctx))
|
179
|
-
|
180
|
-
@typ.command(short_help="Add a " + tinv.long_name)
|
181
|
-
@tinv.id_arg
|
182
|
-
@tinv.apply_aux
|
183
|
-
@click.pass_obj
|
184
|
-
async def add(obj, **kw):
|
185
|
-
name = obj[tnname]
|
186
|
-
if obj[tname] is not None:
|
187
|
-
raise RuntimeError(f"{name} already exists")
|
188
|
-
if tinv.id_name:
|
189
|
-
kw["name"] = name
|
190
|
-
n = alloc(obj, kw.pop(tinv.id_name))
|
191
|
-
else:
|
192
|
-
n = alloc(obj, name)
|
193
|
-
|
194
|
-
await _v_mod(obj, n, **kw)
|
195
|
-
|
196
|
-
add.__doc__ = f"""
|
197
|
-
Add a {tinv.long_name}
|
198
|
-
"""
|
199
|
-
|
200
|
-
@typ.command("set", short_help="Modify a " + tinv.long_name)
|
201
|
-
@tinv.apply_aux
|
202
|
-
@click.pass_obj
|
203
|
-
async def set_(obj, **kw):
|
204
|
-
n = obj[tname]
|
205
|
-
if n is None:
|
206
|
-
raise KeyError(tname)
|
207
|
-
|
208
|
-
await _v_mod(obj, n, **kw)
|
209
|
-
|
210
|
-
set_.__doc__ = f"""
|
211
|
-
Modify a {tinv.long_name}
|
212
|
-
"""
|
213
|
-
|
214
|
-
@typ.command(short_help="Delete a " + tinv.long_name)
|
215
|
-
@click.pass_obj
|
216
|
-
async def delete(obj, **kw): # pylint: disable=unused-argument,unused-variable
|
217
|
-
name = obj[tnname]
|
218
|
-
n = this(obj).by_name(name)
|
219
|
-
if n is not None:
|
220
|
-
await n.delete()
|
221
|
-
|
222
|
-
delete.__doc__ = """
|
223
|
-
Delete a {tinv.long_name}
|
224
|
-
"""
|
225
|
-
|
226
|
-
async def _v_mod(obj, thing, **kw):
|
227
|
-
tinv.apply(obj, thing, kw)
|
228
|
-
for k, v in kw.items():
|
229
|
-
if v:
|
230
|
-
if v == "-":
|
231
|
-
v = None
|
232
|
-
try:
|
233
|
-
setattr(thing, k, v)
|
234
|
-
except AttributeError:
|
235
|
-
if k != "name":
|
236
|
-
raise AttributeError(k, v) from None
|
237
|
-
tinv.postproc(obj, thing, kw)
|
238
|
-
await thing.save()
|
239
|
-
|
240
|
-
# Finally, return the CLI so the user can attach more stuff
|
241
|
-
return typ
|