ominfra 0.0.0.dev138__py3-none-any.whl → 0.0.0.dev140__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.
- ominfra/manage/__init__.py +13 -0
- ominfra/manage/{new/commands → commands}/base.py +9 -7
- ominfra/manage/{new/commands → commands}/subprocess.py +20 -15
- ominfra/manage/main.py +175 -0
- ominfra/manage/payload.py +35 -0
- ominfra/manage/spawning.py +100 -0
- ominfra/pyremote.py +18 -8
- ominfra/scripts/journald2aws.py +7 -0
- ominfra/{manage/new/_manage.py → scripts/manage.py} +248 -153
- ominfra/scripts/supervisor.py +7 -0
- {ominfra-0.0.0.dev138.dist-info → ominfra-0.0.0.dev140.dist-info}/METADATA +3 -3
- {ominfra-0.0.0.dev138.dist-info → ominfra-0.0.0.dev140.dist-info}/RECORD +17 -44
- ominfra/manage/deploy/_executor.py +0 -1415
- ominfra/manage/deploy/configs.py +0 -19
- ominfra/manage/deploy/executor/__init__.py +0 -1
- ominfra/manage/deploy/executor/base.py +0 -115
- ominfra/manage/deploy/executor/concerns/__init__.py +0 -0
- ominfra/manage/deploy/executor/concerns/dirs.py +0 -28
- ominfra/manage/deploy/executor/concerns/nginx.py +0 -47
- ominfra/manage/deploy/executor/concerns/repo.py +0 -17
- ominfra/manage/deploy/executor/concerns/supervisor.py +0 -46
- ominfra/manage/deploy/executor/concerns/systemd.py +0 -88
- ominfra/manage/deploy/executor/concerns/user.py +0 -25
- ominfra/manage/deploy/executor/concerns/venv.py +0 -22
- ominfra/manage/deploy/executor/main.py +0 -119
- ominfra/manage/deploy/poly/__init__.py +0 -1
- ominfra/manage/deploy/poly/_main.py +0 -975
- ominfra/manage/deploy/poly/base.py +0 -178
- ominfra/manage/deploy/poly/configs.py +0 -38
- ominfra/manage/deploy/poly/deploy.py +0 -25
- ominfra/manage/deploy/poly/main.py +0 -18
- ominfra/manage/deploy/poly/nginx.py +0 -60
- ominfra/manage/deploy/poly/repo.py +0 -41
- ominfra/manage/deploy/poly/runtime.py +0 -39
- ominfra/manage/deploy/poly/site.py +0 -11
- ominfra/manage/deploy/poly/supervisor.py +0 -64
- ominfra/manage/deploy/poly/venv.py +0 -52
- ominfra/manage/deploy/remote.py +0 -91
- ominfra/manage/manage.py +0 -12
- ominfra/manage/new/__init__.py +0 -1
- ominfra/manage/new/commands/__init__.py +0 -0
- ominfra/manage/new/main.py +0 -234
- /ominfra/manage/{deploy → commands}/__init__.py +0 -0
- {ominfra-0.0.0.dev138.dist-info → ominfra-0.0.0.dev140.dist-info}/LICENSE +0 -0
- {ominfra-0.0.0.dev138.dist-info → ominfra-0.0.0.dev140.dist-info}/WHEEL +0 -0
- {ominfra-0.0.0.dev138.dist-info → ominfra-0.0.0.dev140.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev138.dist-info → ominfra-0.0.0.dev140.dist-info}/top_level.txt +0 -0
ominfra/manage/new/main.py
DELETED
@@ -1,234 +0,0 @@
|
|
1
|
-
#!/usr/bin/env python3
|
2
|
-
# @omlish-amalg ./_manage.py
|
3
|
-
# ruff: noqa: UP006 UP007
|
4
|
-
"""
|
5
|
-
manage.py -s 'docker run -i python:3.12'
|
6
|
-
manage.py -qs 'ssh -i foo/bar foo@bar.baz' --python=python3.8
|
7
|
-
"""
|
8
|
-
import inspect
|
9
|
-
import json
|
10
|
-
import shlex
|
11
|
-
import struct
|
12
|
-
import subprocess
|
13
|
-
import sys
|
14
|
-
import typing as ta
|
15
|
-
|
16
|
-
from omlish.lite.cached import cached_nullary
|
17
|
-
from omlish.lite.check import check_not_none
|
18
|
-
from omlish.lite.json import json_dumps_compact
|
19
|
-
from omlish.lite.marshal import PolymorphicObjMarshaler
|
20
|
-
from omlish.lite.marshal import get_obj_marshaler
|
21
|
-
from omlish.lite.marshal import marshal_obj
|
22
|
-
from omlish.lite.marshal import register_opj_marshaler
|
23
|
-
from omlish.lite.marshal import unmarshal_obj
|
24
|
-
from omlish.lite.subprocesses import subprocess_maybe_shell_wrap_exec
|
25
|
-
|
26
|
-
from ...pyremote import PyremoteBootstrapDriver
|
27
|
-
from ...pyremote import PyremoteBootstrapOptions
|
28
|
-
from ...pyremote import pyremote_bootstrap_finalize
|
29
|
-
from ...pyremote import pyremote_build_bootstrap_cmd
|
30
|
-
from .commands.base import Command
|
31
|
-
from .commands.subprocess import SubprocessCommand
|
32
|
-
|
33
|
-
|
34
|
-
##
|
35
|
-
|
36
|
-
|
37
|
-
_COMMAND_TYPES = {
|
38
|
-
'subprocess': SubprocessCommand,
|
39
|
-
}
|
40
|
-
|
41
|
-
|
42
|
-
register_opj_marshaler(
|
43
|
-
Command.Input,
|
44
|
-
PolymorphicObjMarshaler.of([
|
45
|
-
PolymorphicObjMarshaler.Impl(
|
46
|
-
cty.Input,
|
47
|
-
k,
|
48
|
-
get_obj_marshaler(cty.Input),
|
49
|
-
)
|
50
|
-
for k, cty in _COMMAND_TYPES.items()
|
51
|
-
]),
|
52
|
-
)
|
53
|
-
|
54
|
-
register_opj_marshaler(
|
55
|
-
Command.Output,
|
56
|
-
PolymorphicObjMarshaler.of([
|
57
|
-
PolymorphicObjMarshaler.Impl(
|
58
|
-
cty.Output,
|
59
|
-
k,
|
60
|
-
get_obj_marshaler(cty.Output),
|
61
|
-
)
|
62
|
-
for k, cty in _COMMAND_TYPES.items()
|
63
|
-
]),
|
64
|
-
)
|
65
|
-
|
66
|
-
|
67
|
-
##
|
68
|
-
|
69
|
-
|
70
|
-
def _send_obj(f: ta.IO, o: ta.Any, ty: ta.Any = None) -> None:
|
71
|
-
j = json_dumps_compact(marshal_obj(o, ty))
|
72
|
-
d = j.encode('utf-8')
|
73
|
-
|
74
|
-
f.write(struct.pack('<I', len(d)))
|
75
|
-
f.write(d)
|
76
|
-
f.flush()
|
77
|
-
|
78
|
-
|
79
|
-
def _recv_obj(f: ta.IO, ty: ta.Any) -> ta.Any:
|
80
|
-
d = f.read(4)
|
81
|
-
if not d:
|
82
|
-
return None
|
83
|
-
if len(d) != 4:
|
84
|
-
raise EOFError
|
85
|
-
|
86
|
-
sz = struct.unpack('<I', d)[0]
|
87
|
-
d = f.read(sz)
|
88
|
-
if len(d) != sz:
|
89
|
-
raise EOFError
|
90
|
-
|
91
|
-
j = json.loads(d.decode('utf-8'))
|
92
|
-
return unmarshal_obj(j, ty)
|
93
|
-
|
94
|
-
|
95
|
-
##
|
96
|
-
|
97
|
-
|
98
|
-
def _remote_main() -> None:
|
99
|
-
rt = pyremote_bootstrap_finalize() # noqa
|
100
|
-
|
101
|
-
while True:
|
102
|
-
i = _recv_obj(rt.input, Command.Input)
|
103
|
-
if i is None:
|
104
|
-
break
|
105
|
-
|
106
|
-
if isinstance(i, SubprocessCommand.Input):
|
107
|
-
o = SubprocessCommand()._execute(i) # noqa
|
108
|
-
else:
|
109
|
-
raise TypeError(i)
|
110
|
-
|
111
|
-
_send_obj(rt.output, o, Command.Output)
|
112
|
-
|
113
|
-
|
114
|
-
##
|
115
|
-
|
116
|
-
|
117
|
-
@cached_nullary
|
118
|
-
def _get_self_src() -> str:
|
119
|
-
return inspect.getsource(sys.modules[__name__])
|
120
|
-
|
121
|
-
|
122
|
-
def _is_src_amalg(src: str) -> bool:
|
123
|
-
for l in src.splitlines(): # noqa
|
124
|
-
if l.startswith('# @omlish-amalg-output '):
|
125
|
-
return True
|
126
|
-
return False
|
127
|
-
|
128
|
-
|
129
|
-
@cached_nullary
|
130
|
-
def _is_self_amalg() -> bool:
|
131
|
-
return _is_src_amalg(_get_self_src())
|
132
|
-
|
133
|
-
|
134
|
-
def _get_amalg_src(*, amalg_file: ta.Optional[str]) -> str:
|
135
|
-
if amalg_file is not None:
|
136
|
-
with open(amalg_file) as f:
|
137
|
-
return f.read()
|
138
|
-
|
139
|
-
if _is_self_amalg():
|
140
|
-
return _get_self_src()
|
141
|
-
|
142
|
-
import importlib.resources
|
143
|
-
return importlib.resources.read_text(__package__, '_manage.py')
|
144
|
-
|
145
|
-
|
146
|
-
##
|
147
|
-
|
148
|
-
|
149
|
-
def _main() -> None:
|
150
|
-
import argparse
|
151
|
-
|
152
|
-
parser = argparse.ArgumentParser()
|
153
|
-
|
154
|
-
parser.add_argument('-s', '--shell')
|
155
|
-
parser.add_argument('-q', '--shell-quote', action='store_true')
|
156
|
-
parser.add_argument('--python', default='python3')
|
157
|
-
parser.add_argument('--_amalg-file')
|
158
|
-
|
159
|
-
args = parser.parse_args()
|
160
|
-
|
161
|
-
#
|
162
|
-
|
163
|
-
amalg_src = _get_amalg_src(amalg_file=args._amalg_file) # noqa
|
164
|
-
|
165
|
-
#
|
166
|
-
|
167
|
-
remote_src = '\n\n'.join([
|
168
|
-
'__name__ = "__remote__"',
|
169
|
-
amalg_src,
|
170
|
-
'_remote_main()',
|
171
|
-
])
|
172
|
-
|
173
|
-
#
|
174
|
-
|
175
|
-
bs_src = pyremote_build_bootstrap_cmd(__package__ or 'manage')
|
176
|
-
|
177
|
-
if args.shell is not None:
|
178
|
-
sh_src = f'{args.python} -c {shlex.quote(bs_src)}'
|
179
|
-
if args.shell_quote:
|
180
|
-
sh_src = shlex.quote(sh_src)
|
181
|
-
sh_cmd = f'{args.shell} {sh_src}'
|
182
|
-
cmd = [sh_cmd]
|
183
|
-
shell = True
|
184
|
-
else:
|
185
|
-
cmd = [args.python, '-c', bs_src]
|
186
|
-
shell = False
|
187
|
-
|
188
|
-
proc = subprocess.Popen(
|
189
|
-
subprocess_maybe_shell_wrap_exec(*cmd),
|
190
|
-
shell=shell,
|
191
|
-
stdin=subprocess.PIPE,
|
192
|
-
stdout=subprocess.PIPE,
|
193
|
-
)
|
194
|
-
|
195
|
-
stdin = check_not_none(proc.stdin)
|
196
|
-
stdout = check_not_none(proc.stdout)
|
197
|
-
|
198
|
-
res = PyremoteBootstrapDriver( # noqa
|
199
|
-
remote_src,
|
200
|
-
PyremoteBootstrapOptions(
|
201
|
-
# debug=True,
|
202
|
-
),
|
203
|
-
).run(stdin, stdout)
|
204
|
-
# print(res)
|
205
|
-
|
206
|
-
#
|
207
|
-
|
208
|
-
for ci in [
|
209
|
-
SubprocessCommand.Input(
|
210
|
-
args=['python3', '-'],
|
211
|
-
input=b'print(1)\n',
|
212
|
-
capture_stdout=True,
|
213
|
-
),
|
214
|
-
SubprocessCommand.Input(
|
215
|
-
args=['uname'],
|
216
|
-
capture_stdout=True,
|
217
|
-
),
|
218
|
-
]:
|
219
|
-
_send_obj(stdin, ci, Command.Input)
|
220
|
-
|
221
|
-
o = _recv_obj(stdout, Command.Output)
|
222
|
-
|
223
|
-
print(o)
|
224
|
-
|
225
|
-
try:
|
226
|
-
stdin.close()
|
227
|
-
except BrokenPipeError:
|
228
|
-
pass
|
229
|
-
|
230
|
-
proc.wait()
|
231
|
-
|
232
|
-
|
233
|
-
if __name__ == '__main__':
|
234
|
-
_main()
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|