ominfra 0.0.0.dev156__py3-none-any.whl → 0.0.0.dev157__py3-none-any.whl
Sign up to get free protection for your applications and to get access to all the features.
- ominfra/manage/main.py +33 -4
- ominfra/manage/remote/spawning.py +1 -6
- ominfra/scripts/journald2aws.py +3 -2
- ominfra/scripts/manage.py +946 -11
- ominfra/scripts/supervisor.py +44 -31
- ominfra/supervisor/configs.py +2 -0
- ominfra/supervisor/supervisor.py +2 -33
- ominfra/supervisor/utils/os.py +41 -0
- {ominfra-0.0.0.dev156.dist-info → ominfra-0.0.0.dev157.dist-info}/METADATA +3 -3
- {ominfra-0.0.0.dev156.dist-info → ominfra-0.0.0.dev157.dist-info}/RECORD +14 -14
- {ominfra-0.0.0.dev156.dist-info → ominfra-0.0.0.dev157.dist-info}/LICENSE +0 -0
- {ominfra-0.0.0.dev156.dist-info → ominfra-0.0.0.dev157.dist-info}/WHEEL +0 -0
- {ominfra-0.0.0.dev156.dist-info → ominfra-0.0.0.dev157.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev156.dist-info → ominfra-0.0.0.dev157.dist-info}/top_level.txt +0 -0
ominfra/manage/main.py
CHANGED
@@ -6,18 +6,23 @@ manage.py -s 'docker run -i python:3.12'
|
|
6
6
|
manage.py -s 'ssh -i /foo/bar.pem foo@bar.baz' -q --python=python3.8
|
7
7
|
"""
|
8
8
|
import asyncio
|
9
|
+
import dataclasses as dc
|
9
10
|
import json
|
11
|
+
import os.path
|
10
12
|
import sys
|
11
13
|
import typing as ta
|
12
14
|
|
13
15
|
from omlish.argparse.cli import ArgparseCli
|
14
16
|
from omlish.argparse.cli import argparse_arg
|
15
17
|
from omlish.argparse.cli import argparse_command
|
18
|
+
from omlish.lite.cached import cached_nullary
|
19
|
+
from omlish.lite.check import check
|
16
20
|
from omlish.lite.logs import log # noqa
|
17
21
|
from omlish.lite.marshal import ObjMarshalerManager
|
18
22
|
from omlish.lite.marshal import ObjMarshalOptions
|
19
23
|
from omlish.lite.pycharm import PycharmRemoteDebug
|
20
24
|
|
25
|
+
from ..configs import read_config_file
|
21
26
|
from .bootstrap import MainBootstrap
|
22
27
|
from .bootstrap_ import main_bootstrap
|
23
28
|
from .commands.base import Command
|
@@ -28,7 +33,28 @@ from .targets.connection import ManageTargetConnector
|
|
28
33
|
from .targets.targets import ManageTarget
|
29
34
|
|
30
35
|
|
36
|
+
@dc.dataclass(frozen=True)
|
37
|
+
class ManageConfig:
|
38
|
+
targets: ta.Optional[ta.Mapping[str, ManageTarget]] = None
|
39
|
+
|
40
|
+
|
31
41
|
class MainCli(ArgparseCli):
|
42
|
+
config_file: ta.Optional[str] = argparse_arg('--config-file', help='Config file path') # type: ignore
|
43
|
+
|
44
|
+
@cached_nullary
|
45
|
+
def config(self) -> ManageConfig:
|
46
|
+
if (cf := self.config_file) is None:
|
47
|
+
cf = os.path.expanduser('~/.omlish/manage.yml')
|
48
|
+
if not os.path.isfile(cf):
|
49
|
+
cf = None
|
50
|
+
|
51
|
+
if cf is None:
|
52
|
+
return ManageConfig()
|
53
|
+
else:
|
54
|
+
return read_config_file(cf, ManageConfig)
|
55
|
+
|
56
|
+
#
|
57
|
+
|
32
58
|
@argparse_command(
|
33
59
|
argparse_arg('--_payload-file'),
|
34
60
|
|
@@ -80,10 +106,13 @@ class MainCli(ArgparseCli):
|
|
80
106
|
|
81
107
|
msh = injector[ObjMarshalerManager]
|
82
108
|
|
83
|
-
|
84
|
-
if not ts.startswith('{'):
|
85
|
-
|
86
|
-
|
109
|
+
tgt: ManageTarget
|
110
|
+
if not (ts := self.args.target).startswith('{'):
|
111
|
+
tgt = check.not_none(self.config().targets)[ts]
|
112
|
+
else:
|
113
|
+
tgt = msh.unmarshal_obj(json.loads(ts), ManageTarget)
|
114
|
+
|
115
|
+
#
|
87
116
|
|
88
117
|
cmds: ta.List[Command] = []
|
89
118
|
cmd: Command
|
@@ -11,7 +11,6 @@ from omlish.lite.asyncio.subprocesses import asyncio_subprocesses
|
|
11
11
|
from omlish.lite.check import check
|
12
12
|
from omlish.lite.subprocesses import SUBPROCESS_CHANNEL_OPTION_VALUES
|
13
13
|
from omlish.lite.subprocesses import SubprocessChannelOption
|
14
|
-
from omlish.lite.subprocesses import subprocess_maybe_shell_wrap_exec
|
15
14
|
|
16
15
|
|
17
16
|
##
|
@@ -82,12 +81,8 @@ class SubprocessRemoteSpawning(RemoteSpawning):
|
|
82
81
|
) -> ta.AsyncGenerator[RemoteSpawning.Spawned, None]:
|
83
82
|
pc = self._prepare_cmd(tgt, src)
|
84
83
|
|
85
|
-
cmd = pc.cmd
|
86
|
-
if not debug:
|
87
|
-
cmd = subprocess_maybe_shell_wrap_exec(*cmd)
|
88
|
-
|
89
84
|
async with asyncio_subprocesses.popen(
|
90
|
-
*cmd,
|
85
|
+
*pc.cmd,
|
91
86
|
shell=pc.shell,
|
92
87
|
stdin=subprocess.PIPE,
|
93
88
|
stdout=subprocess.PIPE,
|
ominfra/scripts/journald2aws.py
CHANGED
@@ -932,8 +932,8 @@ class _CachedNullary(_AbstractCachedNullary):
|
|
932
932
|
return self._value
|
933
933
|
|
934
934
|
|
935
|
-
def cached_nullary(fn
|
936
|
-
return _CachedNullary(fn)
|
935
|
+
def cached_nullary(fn: CallableT) -> CallableT:
|
936
|
+
return _CachedNullary(fn) # type: ignore
|
937
937
|
|
938
938
|
|
939
939
|
def static_init(fn: CallableT) -> CallableT:
|
@@ -2559,6 +2559,7 @@ TODO:
|
|
2559
2559
|
- pickle stdlib objs? have to pin to 3.8 pickle protocol, will be cross-version
|
2560
2560
|
- namedtuple
|
2561
2561
|
- literals
|
2562
|
+
- newtypes?
|
2562
2563
|
"""
|
2563
2564
|
|
2564
2565
|
|