ominfra 0.0.0.dev315__py3-none-any.whl → 0.0.0.dev488__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/{.manifests.json → .omlish-manifests.json} +6 -6
- ominfra/__about__.py +5 -2
- ominfra/clouds/aws/auth.py +2 -1
- ominfra/clouds/aws/cli.py +3 -0
- ominfra/clouds/aws/dataclasses.py +4 -1
- ominfra/clouds/aws/instancetypes/cache.json.gz +0 -0
- ominfra/clouds/aws/instancetypes/cache.py +3 -0
- ominfra/clouds/aws/instancetypes/cli.py +4 -1
- ominfra/clouds/aws/journald2aws/cursor.py +9 -2
- ominfra/clouds/aws/journald2aws/driver.py +5 -2
- ominfra/clouds/aws/journald2aws/main.py +3 -0
- ominfra/clouds/aws/journald2aws/poster.py +9 -2
- ominfra/clouds/aws/logs.py +1 -1
- ominfra/clouds/aws/metadata.py +3 -0
- ominfra/clouds/aws/models/{base.py → base/__init__.py} +7 -2
- ominfra/clouds/aws/models/base/_dataclasses.py +721 -0
- ominfra/clouds/aws/models/gen/cli.py +2 -1
- ominfra/clouds/aws/models/gen/gen.py +16 -7
- ominfra/clouds/aws/models/services/{ec2.py → ec2/__init__.py} +438 -1
- ominfra/clouds/aws/models/services/ec2/_dataclasses.py +30654 -0
- ominfra/clouds/aws/models/services/{lambda_.py → lambda_/__init__.py} +139 -1
- ominfra/clouds/aws/models/services/lambda_/_dataclasses.py +4182 -0
- ominfra/clouds/aws/models/services/{rds.py → rds/__init__.py} +254 -78
- ominfra/clouds/aws/models/services/rds/_dataclasses.py +8231 -0
- ominfra/clouds/aws/models/services/{s3.py → s3/__init__.py} +19 -1
- ominfra/clouds/aws/models/services/s3/_dataclasses.py +5014 -0
- ominfra/clouds/gcp/auth.py +3 -0
- ominfra/commands/runners.py +2 -0
- ominfra/commands/ssh.py +3 -0
- ominfra/journald/genmessages.py +3 -0
- ominfra/journald/messages.py +8 -2
- ominfra/journald/tailer.py +17 -11
- ominfra/manage/bootstrap.py +4 -1
- ominfra/manage/bootstrap_.py +4 -1
- ominfra/manage/commands/base.py +8 -7
- ominfra/manage/commands/inject.py +1 -1
- ominfra/manage/commands/injection.py +4 -1
- ominfra/manage/commands/local.py +4 -1
- ominfra/manage/commands/marshal.py +3 -0
- ominfra/manage/commands/subprocess.py +43 -5
- ominfra/manage/commands/types.py +1 -1
- ominfra/manage/config.py +4 -1
- ominfra/manage/deploy/apps.py +4 -1
- ominfra/manage/deploy/commands.py +5 -2
- ominfra/manage/deploy/conf/inject.py +4 -1
- ominfra/manage/deploy/conf/manager.py +1 -1
- ominfra/manage/deploy/conf/specs.py +3 -3
- ominfra/manage/deploy/config.py +1 -1
- ominfra/manage/deploy/deploy.py +1 -1
- ominfra/manage/deploy/git.py +1 -1
- ominfra/manage/deploy/inject.py +1 -1
- ominfra/manage/deploy/injection.py +4 -1
- ominfra/manage/deploy/interp.py +1 -1
- ominfra/manage/deploy/nginx.py +4 -1
- ominfra/manage/deploy/paths/inject.py +4 -1
- ominfra/manage/deploy/paths/manager.py +4 -1
- ominfra/manage/deploy/paths/owners.py +7 -3
- ominfra/manage/deploy/paths/paths.py +5 -4
- ominfra/manage/deploy/paths/specs.py +4 -1
- ominfra/manage/deploy/paths/types.py +1 -1
- ominfra/manage/deploy/specs.py +1 -1
- ominfra/manage/deploy/systemd.py +4 -1
- ominfra/manage/deploy/tags.py +9 -9
- ominfra/manage/deploy/tmp.py +4 -1
- ominfra/manage/deploy/venvs.py +4 -1
- ominfra/manage/inject.py +3 -2
- ominfra/manage/main.py +10 -5
- ominfra/manage/marshal.py +3 -0
- ominfra/manage/remote/_main.py +6 -2
- ominfra/manage/remote/channel.py +3 -2
- ominfra/manage/remote/config.py +4 -1
- ominfra/manage/remote/connection.py +1 -1
- ominfra/manage/remote/execution.py +11 -7
- ominfra/manage/remote/inject.py +4 -1
- ominfra/manage/remote/payload.py +4 -1
- ominfra/manage/remote/spawning.py +3 -2
- ominfra/manage/system/commands.py +5 -2
- ominfra/manage/system/config.py +4 -1
- ominfra/manage/system/inject.py +4 -1
- ominfra/manage/system/packages.py +7 -3
- ominfra/manage/system/platforms.py +7 -4
- ominfra/manage/targets/bestpython.py +3 -0
- ominfra/manage/targets/bestpython.sh +1 -1
- ominfra/manage/targets/connection.py +3 -2
- ominfra/manage/targets/inject.py +4 -1
- ominfra/manage/targets/targets.py +6 -6
- ominfra/pyremote.py +10 -4
- ominfra/scripts/journald2aws.py +5086 -2409
- ominfra/scripts/manage.py +10770 -7455
- ominfra/scripts/supervisor.py +6823 -3829
- ominfra/supervisor/configs.py +7 -7
- ominfra/supervisor/dispatchers.py +4 -1
- ominfra/supervisor/dispatchersimpl.py +10 -4
- ominfra/supervisor/events.py +14 -7
- ominfra/supervisor/groups.py +4 -1
- ominfra/supervisor/groupsimpl.py +4 -1
- ominfra/supervisor/http.py +2 -2
- ominfra/supervisor/inject.py +4 -1
- ominfra/supervisor/io.py +5 -2
- ominfra/supervisor/main.py +4 -4
- ominfra/supervisor/pipes.py +4 -1
- ominfra/supervisor/privileges.py +4 -1
- ominfra/supervisor/process.py +1 -1
- ominfra/supervisor/processimpl.py +5 -2
- ominfra/supervisor/setup.py +5 -3
- ominfra/supervisor/setupimpl.py +5 -2
- ominfra/supervisor/signals.py +8 -2
- ominfra/supervisor/spawning.py +4 -1
- ominfra/supervisor/spawningimpl.py +1 -1
- ominfra/supervisor/supervisor.py +5 -2
- ominfra/supervisor/types.py +13 -9
- ominfra/supervisor/utils/collections.py +8 -3
- ominfra/supervisor/utils/diag.py +4 -1
- ominfra/supervisor/utils/fds.py +4 -1
- ominfra/supervisor/utils/fs.py +4 -1
- ominfra/supervisor/utils/os.py +4 -3
- ominfra/supervisor/utils/signals.py +1 -1
- ominfra/supervisor/utils/strings.py +2 -1
- ominfra/supervisor/utils/users.py +1 -1
- ominfra/systemd.py +1 -1
- ominfra/tailscale/api.py +3 -0
- ominfra/threadworkers.py +7 -3
- ominfra/tools/listresources.py +1 -1
- ominfra-0.0.0.dev488.dist-info/METADATA +54 -0
- ominfra-0.0.0.dev488.dist-info/RECORD +169 -0
- {ominfra-0.0.0.dev315.dist-info → ominfra-0.0.0.dev488.dist-info}/WHEEL +1 -1
- ominfra-0.0.0.dev315.dist-info/METADATA +0 -23
- ominfra-0.0.0.dev315.dist-info/RECORD +0 -164
- {ominfra-0.0.0.dev315.dist-info → ominfra-0.0.0.dev488.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev315.dist-info → ominfra-0.0.0.dev488.dist-info}/licenses/LICENSE +0 -0
- {ominfra-0.0.0.dev315.dist-info → ominfra-0.0.0.dev488.dist-info}/top_level.txt +0 -0
ominfra/clouds/gcp/auth.py
CHANGED
ominfra/commands/runners.py
CHANGED
|
@@ -38,6 +38,7 @@ class CommandRunner(lang.Abstract):
|
|
|
38
38
|
class ReturnCodeError(Exception):
|
|
39
39
|
def __init__(self, result: 'CommandRunner.Result') -> None:
|
|
40
40
|
super().__init__(f'Bad return code: {result.rc}', result)
|
|
41
|
+
|
|
41
42
|
self.result = result
|
|
42
43
|
|
|
43
44
|
@abc.abstractmethod
|
|
@@ -52,6 +53,7 @@ class LocalCommandRunner(CommandRunner):
|
|
|
52
53
|
|
|
53
54
|
def __init__(self, cfg: Config = Config()) -> None:
|
|
54
55
|
super().__init__()
|
|
56
|
+
|
|
55
57
|
self._cfg = check.isinstance(cfg, LocalCommandRunner.Config)
|
|
56
58
|
|
|
57
59
|
async def run_command(self, cmd: CommandRunner.Command) -> CommandRunner.Result:
|
ominfra/commands/ssh.py
CHANGED
|
@@ -56,6 +56,7 @@ class SshSubprocessCommandRunner(CommandRunner):
|
|
|
56
56
|
lcr: LocalCommandRunner | None = None,
|
|
57
57
|
) -> None:
|
|
58
58
|
super().__init__()
|
|
59
|
+
|
|
59
60
|
self._cfg = check.isinstance(cfg, SshConfig)
|
|
60
61
|
self._lcr = check.isinstance(lcr, LocalCommandRunner) if lcr is not None else LocalCommandRunner()
|
|
61
62
|
|
|
@@ -89,6 +90,7 @@ class AsyncsshSshCommandRunner(CommandRunner):
|
|
|
89
90
|
cfg: SshConfig,
|
|
90
91
|
) -> None:
|
|
91
92
|
super().__init__()
|
|
93
|
+
|
|
92
94
|
self._cfg = check.isinstance(cfg, SshConfig)
|
|
93
95
|
|
|
94
96
|
async def run_command(self, cmd: CommandRunner.Command) -> CommandRunner.Result:
|
|
@@ -122,6 +124,7 @@ class ParamikoSshCommandRunner(CommandRunner):
|
|
|
122
124
|
cfg: SshConfig,
|
|
123
125
|
) -> None:
|
|
124
126
|
super().__init__()
|
|
127
|
+
|
|
125
128
|
self._cfg = check.isinstance(cfg, SshConfig)
|
|
126
129
|
|
|
127
130
|
def _run_command(self, cmd: CommandRunner.Command) -> CommandRunner.Result:
|
ominfra/journald/genmessages.py
CHANGED
ominfra/journald/messages.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
2
2
|
# @omlish-lite
|
|
3
3
|
import dataclasses as dc
|
|
4
4
|
import json
|
|
@@ -6,7 +6,13 @@ import typing as ta
|
|
|
6
6
|
|
|
7
7
|
from omlish.io.buffers import DelimitingBuffer
|
|
8
8
|
from omlish.lite.check import check
|
|
9
|
-
from omlish.
|
|
9
|
+
from omlish.logs.modules import get_module_logger
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
log = get_module_logger(globals()) # noqa
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
##
|
|
10
16
|
|
|
11
17
|
|
|
12
18
|
@dc.dataclass(frozen=True)
|
ominfra/journald/tailer.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ruff: noqa: UP007
|
|
1
|
+
# ruff: noqa: UP007 UP045
|
|
2
2
|
# @omlish-lite
|
|
3
3
|
"""
|
|
4
4
|
TODO:
|
|
@@ -190,7 +190,7 @@ Output Options
|
|
|
190
190
|
Reverse output so that the newest entries are displayed first.
|
|
191
191
|
--show-cursor
|
|
192
192
|
The cursor is shown after the last entry after two dashes:
|
|
193
|
-
-- cursor: s=0639
|
|
193
|
+
-- cursor: s=0639...
|
|
194
194
|
The format of the cursor is private and subject to change.
|
|
195
195
|
--utc
|
|
196
196
|
Express time in Coordinated Universal Time (UTC).
|
|
@@ -218,7 +218,7 @@ Output Options
|
|
|
218
218
|
--no-tail
|
|
219
219
|
Show all stored output lines, even in follow mode. Undoes the effect of --lines=.
|
|
220
220
|
-q, --quiet
|
|
221
|
-
Suppresses all informational messages (i.e. "-- Journal begins at
|
|
221
|
+
Suppresses all informational messages (i.e. "-- Journal begins at ...", "-- Reboot --"), any warning messages
|
|
222
222
|
regarding inaccessible system journals when run as a normal user.
|
|
223
223
|
|
|
224
224
|
Pager Control Options
|
|
@@ -302,10 +302,10 @@ Commands
|
|
|
302
302
|
Instead of showing journal contents, show internal header information of the journal fields accessed. This option is
|
|
303
303
|
particularly useful when trying to identify out-of-order journal entries, as happens for example when the machine is
|
|
304
304
|
booted with the wrong system time.
|
|
305
|
-
--list-catalog [128-bit-ID
|
|
305
|
+
--list-catalog [128-bit-ID...]
|
|
306
306
|
List the contents of the message catalog as a table of message IDs, plus their short description strings. If any
|
|
307
307
|
128-bit-IDs are specified, only those entries are shown.
|
|
308
|
-
--dump-catalog [128-bit-ID
|
|
308
|
+
--dump-catalog [128-bit-ID...]
|
|
309
309
|
Show the contents of the message catalog, with entries separated by a line consisting of two dashes and the ID (the
|
|
310
310
|
format is the same as .catalog files). If any 128-bit-IDs are specified, only those entries are shown.
|
|
311
311
|
--update-catalog
|
|
@@ -326,11 +326,11 @@ Environment
|
|
|
326
326
|
$SYSTEMD_LOG_LEVEL
|
|
327
327
|
The maximum log level of emitted messages (messages with a higher log level, i.e. less important ones, will be
|
|
328
328
|
suppressed). Takes a comma-separated list of values. A value may be either one of (in order of decreasing
|
|
329
|
-
importance) emerg, alert, crit, err, warning, notice, info, debug, or an integer in the range 0
|
|
330
|
-
more information. Each value may optionally be prefixed with one of console, syslog, kmsg or journal followed by
|
|
331
|
-
colon to set the maximum log level for that specific log target (e.g. SYSTEMD_LOG_LEVEL=debug,console:info
|
|
332
|
-
to log at debug level except when logging to the console which should be at info level). Note that the
|
|
333
|
-
maximum log level takes priority over any per target maximum log levels.
|
|
329
|
+
importance) emerg, alert, crit, err, warning, notice, info, debug, or an integer in the range 0...7. See syslog(3)
|
|
330
|
+
for more information. Each value may optionally be prefixed with one of console, syslog, kmsg or journal followed by
|
|
331
|
+
a colon to set the maximum log level for that specific log target (e.g. SYSTEMD_LOG_LEVEL=debug,console:info
|
|
332
|
+
specifies to log at debug level except when logging to the console which should be at info level). Note that the
|
|
333
|
+
global maximum log level takes priority over any per target maximum log levels.
|
|
334
334
|
$SYSTEMD_LOG_COLOR
|
|
335
335
|
A boolean. If true, messages written to the tty will be colored according to priority. This setting is only useful
|
|
336
336
|
when messages are written directly to the terminal, because journalctl(1) and other tools that display logs will
|
|
@@ -409,7 +409,7 @@ import typing as ta
|
|
|
409
409
|
|
|
410
410
|
from omlish.lite.cached import cached_nullary
|
|
411
411
|
from omlish.lite.check import check
|
|
412
|
-
from omlish.
|
|
412
|
+
from omlish.logs.modules import get_module_logger
|
|
413
413
|
from omlish.subprocesses.utils import subprocess_close
|
|
414
414
|
from omlish.subprocesses.wrap import subprocess_shell_wrap_exec
|
|
415
415
|
|
|
@@ -418,6 +418,12 @@ from .messages import JournalctlMessage # noqa
|
|
|
418
418
|
from .messages import JournalctlMessageBuilder
|
|
419
419
|
|
|
420
420
|
|
|
421
|
+
log = get_module_logger(globals()) # noqa
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
##
|
|
425
|
+
|
|
426
|
+
|
|
421
427
|
class JournalctlTailerWorker(ThreadWorker):
|
|
422
428
|
DEFAULT_CMD: ta.ClassVar[ta.Sequence[str]] = ['journalctl']
|
|
423
429
|
|
ominfra/manage/bootstrap.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
2
2
|
import dataclasses as dc
|
|
3
3
|
|
|
4
4
|
from .config import MainConfig
|
|
@@ -7,6 +7,9 @@ from .remote.config import RemoteConfig
|
|
|
7
7
|
from .system.config import SystemConfig
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
##
|
|
11
|
+
|
|
12
|
+
|
|
10
13
|
@dc.dataclass(frozen=True)
|
|
11
14
|
class MainBootstrap:
|
|
12
15
|
main_config: MainConfig = MainConfig()
|
ominfra/manage/bootstrap_.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
2
2
|
from omlish.lite.inject import Injector
|
|
3
3
|
from omlish.lite.inject import inj
|
|
4
4
|
from omlish.logs.standard import configure_standard_logging
|
|
@@ -7,6 +7,9 @@ from .bootstrap import MainBootstrap
|
|
|
7
7
|
from .inject import bind_main
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
##
|
|
11
|
+
|
|
12
|
+
|
|
10
13
|
def main_bootstrap(bs: MainBootstrap) -> Injector:
|
|
11
14
|
if (log_level := bs.main_config.log_level) is not None:
|
|
12
15
|
configure_standard_logging(log_level)
|
ominfra/manage/commands/base.py
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
2
2
|
import abc
|
|
3
3
|
import dataclasses as dc
|
|
4
|
-
import logging
|
|
5
4
|
import traceback
|
|
6
5
|
import typing as ta
|
|
7
6
|
|
|
7
|
+
from omlish.lite.abstract import Abstract
|
|
8
8
|
from omlish.lite.check import check
|
|
9
9
|
from omlish.lite.strings import snake_case
|
|
10
|
+
from omlish.logs.protocols import LoggerLike
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
CommandT = ta.TypeVar('CommandT', bound='Command')
|
|
@@ -17,9 +18,9 @@ CommandOutputT = ta.TypeVar('CommandOutputT', bound='Command.Output')
|
|
|
17
18
|
|
|
18
19
|
|
|
19
20
|
@dc.dataclass(frozen=True)
|
|
20
|
-
class Command(
|
|
21
|
+
class Command(Abstract, ta.Generic[CommandOutputT]):
|
|
21
22
|
@dc.dataclass(frozen=True)
|
|
22
|
-
class Output(
|
|
23
|
+
class Output(Abstract):
|
|
23
24
|
pass
|
|
24
25
|
|
|
25
26
|
@ta.final
|
|
@@ -65,7 +66,7 @@ class CommandException:
|
|
|
65
66
|
)
|
|
66
67
|
|
|
67
68
|
|
|
68
|
-
class CommandOutputOrException(
|
|
69
|
+
class CommandOutputOrException(Abstract, ta.Generic[CommandOutputT]):
|
|
69
70
|
@property
|
|
70
71
|
@abc.abstractmethod
|
|
71
72
|
def output(self) -> ta.Optional[CommandOutputT]:
|
|
@@ -83,7 +84,7 @@ class CommandOutputOrExceptionData(CommandOutputOrException):
|
|
|
83
84
|
exception: ta.Optional[CommandException] = None
|
|
84
85
|
|
|
85
86
|
|
|
86
|
-
class CommandExecutor(
|
|
87
|
+
class CommandExecutor(Abstract, ta.Generic[CommandT, CommandOutputT]):
|
|
87
88
|
@abc.abstractmethod
|
|
88
89
|
def execute(self, cmd: CommandT) -> ta.Awaitable[CommandOutputT]:
|
|
89
90
|
raise NotImplementedError
|
|
@@ -92,7 +93,7 @@ class CommandExecutor(abc.ABC, ta.Generic[CommandT, CommandOutputT]):
|
|
|
92
93
|
self,
|
|
93
94
|
cmd: CommandT,
|
|
94
95
|
*,
|
|
95
|
-
log: ta.Optional[
|
|
96
|
+
log: ta.Optional[LoggerLike] = None,
|
|
96
97
|
omit_exc_object: bool = False,
|
|
97
98
|
) -> CommandOutputOrException[CommandOutputT]:
|
|
98
99
|
try:
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
2
2
|
import typing as ta
|
|
3
3
|
|
|
4
4
|
from omlish.lite.inject import InjectorBindingOrBindings
|
|
@@ -11,6 +11,9 @@ from .base import CommandExecutorRegistration
|
|
|
11
11
|
from .base import CommandRegistration
|
|
12
12
|
|
|
13
13
|
|
|
14
|
+
##
|
|
15
|
+
|
|
16
|
+
|
|
14
17
|
def bind_command(
|
|
15
18
|
command_cls: ta.Type[Command],
|
|
16
19
|
executor_cls: ta.Optional[ta.Type[CommandExecutor]],
|
ominfra/manage/commands/local.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ruff: noqa: TC003 UP006 UP007
|
|
1
|
+
# ruff: noqa: TC003 UP006 UP007 UP045
|
|
2
2
|
import asyncio.subprocess
|
|
3
3
|
import dataclasses as dc
|
|
4
4
|
import os
|
|
@@ -28,13 +28,26 @@ class SubprocessCommand(Command['SubprocessCommand.Output']):
|
|
|
28
28
|
env: ta.Optional[ta.Mapping[str, str]] = None
|
|
29
29
|
|
|
30
30
|
stdout: str = 'pipe' # SubprocessChannelOption
|
|
31
|
+
decode_stdout: ta.Optional[str] = None
|
|
32
|
+
|
|
31
33
|
stderr: str = 'pipe' # SubprocessChannelOption
|
|
34
|
+
decode_stderr: ta.Optional[str] = None
|
|
32
35
|
|
|
33
36
|
input: ta.Optional[bytes] = None
|
|
37
|
+
encode_input: ta.Optional[str] = None
|
|
38
|
+
input_str: ta.Optional[str] = None
|
|
39
|
+
|
|
34
40
|
timeout: ta.Optional[float] = None
|
|
35
41
|
|
|
36
42
|
def __post_init__(self) -> None:
|
|
37
43
|
check.not_isinstance(self.cmd, str)
|
|
44
|
+
check.state(not (self.input is not None and self.input_str is not None))
|
|
45
|
+
if self.decode_stdout is not None:
|
|
46
|
+
check.non_empty_str(self.decode_stdout)
|
|
47
|
+
if self.decode_stderr is not None:
|
|
48
|
+
check.non_empty_str(self.decode_stderr)
|
|
49
|
+
if self.encode_input is not None:
|
|
50
|
+
check.non_empty_str(self.encode_input)
|
|
38
51
|
|
|
39
52
|
@dc.dataclass(frozen=True)
|
|
40
53
|
class Output(Command.Output):
|
|
@@ -44,11 +57,25 @@ class SubprocessCommand(Command['SubprocessCommand.Output']):
|
|
|
44
57
|
elapsed_s: float
|
|
45
58
|
|
|
46
59
|
stdout: ta.Optional[bytes] = None
|
|
60
|
+
stdout_str: ta.Optional[str] = None
|
|
61
|
+
|
|
47
62
|
stderr: ta.Optional[bytes] = None
|
|
63
|
+
stderr_str: ta.Optional[str] = None
|
|
48
64
|
|
|
49
65
|
|
|
50
66
|
class SubprocessCommandExecutor(CommandExecutor[SubprocessCommand, SubprocessCommand.Output]):
|
|
67
|
+
DEFAULT_INPUT_ENCODING: ta.ClassVar[str] = 'utf-8'
|
|
68
|
+
|
|
51
69
|
async def execute(self, cmd: SubprocessCommand) -> SubprocessCommand.Output:
|
|
70
|
+
input_bytes: ta.Optional[bytes]
|
|
71
|
+
if cmd.input is not None:
|
|
72
|
+
check.none(cmd.input_str)
|
|
73
|
+
input_bytes = cmd.input
|
|
74
|
+
elif cmd.input_str is not None:
|
|
75
|
+
input_bytes = cmd.input_str.encode(cmd.encode_input or self.DEFAULT_INPUT_ENCODING)
|
|
76
|
+
else:
|
|
77
|
+
input_bytes = None
|
|
78
|
+
|
|
52
79
|
proc: asyncio.subprocess.Process
|
|
53
80
|
async with asyncio_subprocesses.popen(
|
|
54
81
|
*subprocess_maybe_shell_wrap_exec(*cmd.cmd),
|
|
@@ -57,7 +84,7 @@ class SubprocessCommandExecutor(CommandExecutor[SubprocessCommand, SubprocessCom
|
|
|
57
84
|
cwd=cmd.cwd,
|
|
58
85
|
env={**os.environ, **(cmd.env or {})},
|
|
59
86
|
|
|
60
|
-
stdin=subprocess.PIPE if
|
|
87
|
+
stdin=subprocess.PIPE if input_bytes is not None else None,
|
|
61
88
|
stdout=SUBPROCESS_CHANNEL_OPTION_VALUES[ta.cast(SubprocessChannelOption, cmd.stdout)],
|
|
62
89
|
stderr=SUBPROCESS_CHANNEL_OPTION_VALUES[ta.cast(SubprocessChannelOption, cmd.stderr)],
|
|
63
90
|
|
|
@@ -66,17 +93,28 @@ class SubprocessCommandExecutor(CommandExecutor[SubprocessCommand, SubprocessCom
|
|
|
66
93
|
start_time = time.time()
|
|
67
94
|
stdout, stderr = await asyncio_subprocesses.communicate(
|
|
68
95
|
proc,
|
|
69
|
-
input=
|
|
96
|
+
input=input,
|
|
70
97
|
timeout=cmd.timeout,
|
|
71
98
|
)
|
|
72
99
|
end_time = time.time()
|
|
73
100
|
|
|
101
|
+
out_kw: ta.Dict[str, ta.Any] = {}
|
|
102
|
+
if stdout is not None:
|
|
103
|
+
if cmd.decode_stdout is not None:
|
|
104
|
+
out_kw.update(stdout_str=stdout.decode(cmd.decode_stdout))
|
|
105
|
+
else:
|
|
106
|
+
out_kw.update(stdout=stdout)
|
|
107
|
+
if stderr is not None:
|
|
108
|
+
if cmd.decode_stderr is not None:
|
|
109
|
+
out_kw.update(stderr_str=stderr.decode(cmd.decode_stderr))
|
|
110
|
+
else:
|
|
111
|
+
out_kw.update(stderr=stderr)
|
|
112
|
+
|
|
74
113
|
return SubprocessCommand.Output(
|
|
75
114
|
rc=check.not_none(proc.returncode),
|
|
76
115
|
pid=proc.pid,
|
|
77
116
|
|
|
78
117
|
elapsed_s=end_time - start_time,
|
|
79
118
|
|
|
80
|
-
|
|
81
|
-
stderr=stderr, # noqa
|
|
119
|
+
**out_kw,
|
|
82
120
|
)
|
ominfra/manage/commands/types.py
CHANGED
ominfra/manage/config.py
CHANGED
ominfra/manage/deploy/apps.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
2
2
|
import dataclasses as dc
|
|
3
3
|
import json
|
|
4
4
|
import os.path
|
|
@@ -20,6 +20,9 @@ from .types import DeployHome
|
|
|
20
20
|
from .venvs import DeployVenvManager
|
|
21
21
|
|
|
22
22
|
|
|
23
|
+
##
|
|
24
|
+
|
|
25
|
+
|
|
23
26
|
class DeployAppManager(DeployPathOwner):
|
|
24
27
|
def __init__(
|
|
25
28
|
self,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
2
2
|
import dataclasses as dc
|
|
3
3
|
|
|
4
|
-
from omlish.
|
|
4
|
+
from omlish.logs.modules import get_module_logger
|
|
5
5
|
|
|
6
6
|
from ..commands.base import Command
|
|
7
7
|
from ..commands.base import CommandExecutor
|
|
@@ -9,6 +9,9 @@ from .deploy import DeployDriverFactory
|
|
|
9
9
|
from .specs import DeploySpec
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
log = get_module_logger(globals()) # noqa
|
|
13
|
+
|
|
14
|
+
|
|
12
15
|
##
|
|
13
16
|
|
|
14
17
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
2
2
|
import typing as ta
|
|
3
3
|
|
|
4
4
|
from omlish.lite.inject import InjectorBindingOrBindings
|
|
@@ -9,6 +9,9 @@ from ..injection import bind_deploy_manager
|
|
|
9
9
|
from .manager import DeployConfManager
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
##
|
|
13
|
+
|
|
14
|
+
|
|
12
15
|
def bind_deploy_conf() -> InjectorBindings:
|
|
13
16
|
lst: ta.List[InjectorBindingOrBindings] = [
|
|
14
17
|
bind_deploy_manager(DeployConfManager),
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
2
|
-
import abc
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
3
2
|
import dataclasses as dc
|
|
4
3
|
import typing as ta
|
|
5
4
|
|
|
6
5
|
from omlish.formats.ini.sections import IniSectionSettingsMap
|
|
6
|
+
from omlish.lite.abstract import Abstract
|
|
7
7
|
from omlish.lite.check import check
|
|
8
8
|
from omlish.lite.marshal import register_single_field_type_obj_marshaler
|
|
9
9
|
|
|
@@ -13,7 +13,7 @@ from ..paths.specs import check_valid_deploy_spec_path
|
|
|
13
13
|
##
|
|
14
14
|
|
|
15
15
|
|
|
16
|
-
class DeployAppConfContent(
|
|
16
|
+
class DeployAppConfContent(Abstract):
|
|
17
17
|
pass
|
|
18
18
|
|
|
19
19
|
|
ominfra/manage/deploy/config.py
CHANGED
ominfra/manage/deploy/deploy.py
CHANGED
ominfra/manage/deploy/git.py
CHANGED
ominfra/manage/deploy/inject.py
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
2
2
|
from omlish.lite.inject import InjectorBindings
|
|
3
3
|
from omlish.lite.inject import inj
|
|
4
4
|
|
|
5
5
|
from .paths.owners import DeployPathOwner
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
##
|
|
9
|
+
|
|
10
|
+
|
|
8
11
|
def bind_deploy_manager(cls: type) -> InjectorBindings:
|
|
9
12
|
return inj.as_bindings(
|
|
10
13
|
inj.bind(cls, singleton=True),
|
ominfra/manage/deploy/interp.py
CHANGED
ominfra/manage/deploy/nginx.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
2
2
|
import typing as ta
|
|
3
3
|
|
|
4
4
|
from omlish.lite.inject import InjectorBindingOrBindings
|
|
@@ -10,6 +10,9 @@ from .owners import DeployPathOwner
|
|
|
10
10
|
from .owners import DeployPathOwners
|
|
11
11
|
|
|
12
12
|
|
|
13
|
+
##
|
|
14
|
+
|
|
15
|
+
|
|
13
16
|
def bind_deploy_paths() -> InjectorBindings:
|
|
14
17
|
lst: ta.List[InjectorBindingOrBindings] = [
|
|
15
18
|
inj.bind_array(DeployPathOwner),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
2
2
|
import typing as ta
|
|
3
3
|
|
|
4
4
|
from omlish.lite.cached import cached_nullary
|
|
@@ -9,6 +9,9 @@ from .paths import DeployPath
|
|
|
9
9
|
from .paths import DeployPathError
|
|
10
10
|
|
|
11
11
|
|
|
12
|
+
##
|
|
13
|
+
|
|
14
|
+
|
|
12
15
|
class DeployPathsManager:
|
|
13
16
|
def __init__(
|
|
14
17
|
self,
|
|
@@ -1,15 +1,19 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
2
2
|
import abc
|
|
3
3
|
import os.path
|
|
4
4
|
import typing as ta
|
|
5
5
|
|
|
6
|
+
from omlish.lite.abstract import Abstract
|
|
6
7
|
from omlish.lite.check import check
|
|
7
8
|
|
|
8
9
|
from ..types import DeployHome
|
|
9
10
|
from .paths import DeployPath
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
##
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
class DeployPathOwner(Abstract):
|
|
13
17
|
@abc.abstractmethod
|
|
14
18
|
def get_owned_deploy_paths(self) -> ta.AbstractSet[DeployPath]:
|
|
15
19
|
raise NotImplementedError
|
|
@@ -18,7 +22,7 @@ class DeployPathOwner(abc.ABC):
|
|
|
18
22
|
DeployPathOwners = ta.NewType('DeployPathOwners', ta.Sequence[DeployPathOwner])
|
|
19
23
|
|
|
20
24
|
|
|
21
|
-
class SingleDirDeployPathOwner(DeployPathOwner,
|
|
25
|
+
class SingleDirDeployPathOwner(DeployPathOwner, Abstract):
|
|
22
26
|
def __init__(
|
|
23
27
|
self,
|
|
24
28
|
*args: ta.Any,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# ruff: noqa: UP006 UP007
|
|
1
|
+
# ruff: noqa: UP006 UP007 UP045
|
|
2
2
|
"""
|
|
3
3
|
TODO:
|
|
4
4
|
- run/{.pid,.sock}
|
|
@@ -13,6 +13,7 @@ import dataclasses as dc
|
|
|
13
13
|
import itertools
|
|
14
14
|
import typing as ta
|
|
15
15
|
|
|
16
|
+
from omlish.lite.abstract import Abstract
|
|
16
17
|
from omlish.lite.cached import cached_nullary
|
|
17
18
|
from omlish.lite.check import check
|
|
18
19
|
from omlish.lite.strings import split_keep_delimiter
|
|
@@ -32,7 +33,7 @@ class DeployPathError(Exception):
|
|
|
32
33
|
pass
|
|
33
34
|
|
|
34
35
|
|
|
35
|
-
class DeployPathRenderable(
|
|
36
|
+
class DeployPathRenderable(Abstract):
|
|
36
37
|
@cached_nullary
|
|
37
38
|
def __str__(self) -> str:
|
|
38
39
|
return self.render(None)
|
|
@@ -45,7 +46,7 @@ class DeployPathRenderable(abc.ABC):
|
|
|
45
46
|
##
|
|
46
47
|
|
|
47
48
|
|
|
48
|
-
class DeployPathNamePart(DeployPathRenderable,
|
|
49
|
+
class DeployPathNamePart(DeployPathRenderable, Abstract):
|
|
49
50
|
@classmethod
|
|
50
51
|
def parse(cls, s: str) -> 'DeployPathNamePart':
|
|
51
52
|
check.non_empty_str(s)
|
|
@@ -137,7 +138,7 @@ class DeployPathName(DeployPathRenderable):
|
|
|
137
138
|
|
|
138
139
|
|
|
139
140
|
@dc.dataclass(frozen=True)
|
|
140
|
-
class DeployPathPart(DeployPathRenderable,
|
|
141
|
+
class DeployPathPart(DeployPathRenderable, Abstract):
|
|
141
142
|
name: DeployPathName
|
|
142
143
|
|
|
143
144
|
@property
|