ominfra 0.0.0.dev192__py3-none-any.whl → 0.0.0.dev194__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,8 +5,9 @@ import signal
5
5
  import tempfile
6
6
  import typing as ta
7
7
 
8
- from ..configs import ConfigMapping
9
- from ..configs import build_config_named_children
8
+ from omlish.configs.processing.names import build_config_named_children
9
+ from omlish.configs.types import ConfigMap
10
+
10
11
  from .utils.fs import check_existing_dir
11
12
  from .utils.fs import check_path_with_existing_dir
12
13
  from .utils.strings import parse_bytes_size
@@ -282,7 +283,7 @@ class ServerConfig:
282
283
  ##
283
284
 
284
285
 
285
- def prepare_process_group_config(dct: ConfigMapping) -> ConfigMapping:
286
+ def prepare_process_group_config(dct: ConfigMap) -> ConfigMap:
286
287
  out = dict(dct)
287
288
  out['processes'] = build_config_named_children(out.get('processes'))
288
289
  return out
@@ -35,12 +35,12 @@ import os.path
35
35
  import typing as ta
36
36
 
37
37
  from omlish.http.coro.server import CoroHttpServer
38
+ from omlish.lite.configs import load_config_file_obj
38
39
  from omlish.lite.inject import inj
39
40
  from omlish.lite.runtime import is_debugger_attached
40
41
  from omlish.logs.standard import configure_standard_logging
41
42
  from omlish.os.journald import journald_log_handler_factory
42
43
 
43
- from ..configs import read_config_file
44
44
  from .configs import ServerConfig
45
45
  from .configs import prepare_server_config
46
46
  from .inject import bind_server
@@ -91,7 +91,7 @@ def main(
91
91
 
92
92
  # if we hup, restart by making a new Supervisor()
93
93
  for epoch in itertools.count():
94
- config = read_config_file(
94
+ config = load_config_file_obj(
95
95
  os.path.expanduser(cf),
96
96
  ServerConfig,
97
97
  prepare=prepare_server_config,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ominfra
3
- Version: 0.0.0.dev192
3
+ Version: 0.0.0.dev194
4
4
  Summary: ominfra
5
5
  Author: wrmsr
6
6
  License: BSD-3-Clause
@@ -12,9 +12,9 @@ Classifier: Operating System :: OS Independent
12
12
  Classifier: Operating System :: POSIX
13
13
  Requires-Python: >=3.12
14
14
  License-File: LICENSE
15
- Requires-Dist: omdev==0.0.0.dev192
16
- Requires-Dist: omlish==0.0.0.dev192
17
- Requires-Dist: omserv==0.0.0.dev192
15
+ Requires-Dist: omdev==0.0.0.dev194
16
+ Requires-Dist: omlish==0.0.0.dev194
17
+ Requires-Dist: omserv==0.0.0.dev194
18
18
  Provides-Extra: all
19
19
  Requires-Dist: paramiko~=3.5; extra == "all"
20
20
  Requires-Dist: asyncssh~=2.18; extra == "all"
@@ -2,7 +2,6 @@ ominfra/.manifests.json,sha256=8KREXxMAlsilZOktXPYru1ND3V5hFI22vnrp6hT3bio,589
2
2
  ominfra/__about__.py,sha256=_gUs3H7uunGy5IfGw3mq4dFJWaF1mecSPruJPyjbs7Y,741
3
3
  ominfra/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  ominfra/cmds.py,sha256=E0AfnvEmnKntXWvmLW5L05_NeDpBET1VBXn7vV6EwBQ,2083
5
- ominfra/configs.py,sha256=UrwZrzsnU4E305OoFH_eAcyI8e82LQZ2yhy8WnuAUGM,3055
6
5
  ominfra/pyremote.py,sha256=HLfAZl3Xw5CpxLS5PS380zqCyE7n3vKVksIYT2Fbdc8,15197
7
6
  ominfra/ssh.py,sha256=jQpc4WvkMckIfk4vILda8zFaeharRqc_6wxW50b0OjQ,5431
8
7
  ominfra/systemd.py,sha256=d61NVrJoItzSaqhMDgKGrQjbrxEVAujUMDsj8WggXos,1022
@@ -19,7 +18,7 @@ ominfra/clouds/aws/journald2aws/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxk
19
18
  ominfra/clouds/aws/journald2aws/__main__.py,sha256=d23loR_cKfTYZwYiqpt_CmKI7dd5WcYFgIYzqMep75E,68
20
19
  ominfra/clouds/aws/journald2aws/cursor.py,sha256=tQ7O6BHlEdaalbiI_Rqagj0aHfdtTQ_ZJwdOSRUjNvQ,1173
21
20
  ominfra/clouds/aws/journald2aws/driver.py,sha256=b3XfSlIBWAWJLImmyh1ZK9FpdNAYNZ2YZeCv_Q9GckM,6111
22
- ominfra/clouds/aws/journald2aws/main.py,sha256=f1YbdF0FulIbUokaNz7NrPS304IdzYiw0Hd3ZDheYf0,2151
21
+ ominfra/clouds/aws/journald2aws/main.py,sha256=4qWnw33cTPUW1CU4_9ojkn0wRStANrQzSI_cXpyuOf8,2202
23
22
  ominfra/clouds/aws/journald2aws/poster.py,sha256=hz1XuctW8GtLmfjhRvCFY6py52D4BzXHYny5XKFpHSA,2833
24
23
  ominfra/clouds/gcp/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
25
24
  ominfra/clouds/gcp/auth.py,sha256=rDIiOH5gP3OSIaMC5Lp8yAD4zWuLDEYlFu37mDx5YDA,1360
@@ -34,7 +33,7 @@ ominfra/manage/bootstrap.py,sha256=1RIRhVkUZjxZcZerHMg8U6xgWhhemGgPN5cDye8dQ68,4
34
33
  ominfra/manage/bootstrap_.py,sha256=B9UfR9J7mS3J54PFaSe1MQS5lCnKgxt5dDRJ9mnHYwg,656
35
34
  ominfra/manage/config.py,sha256=1y2N_8nXHBZc6YbW6BaRZoDDCTBmiHuWtTOQ7zdr5VE,184
36
35
  ominfra/manage/inject.py,sha256=_FVaMZUBKi-oObv14H77luWYCodxNJJD1t4pNQzckFE,2030
37
- ominfra/manage/main.py,sha256=t4qilhICLxDCgLXaU6PJ56kINx0YwenWd8SXSSBWKVU,4381
36
+ ominfra/manage/main.py,sha256=1-PIAWnmd9XIy8pVcWGsME9xNTSj_t0sWWQTq9GYIzc,4403
38
37
  ominfra/manage/marshal.py,sha256=WKj7IU9bo4fBMSSzT6ZMm_WFalXIJZ-V7j8oi92fNhk,305
39
38
  ominfra/manage/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
39
  ominfra/manage/commands/base.py,sha256=LtaI0AgnplttQK7gNncNItq8yuTZQimJTaprVpZktI8,3993
@@ -62,8 +61,8 @@ ominfra/manage/deploy/types.py,sha256=ZcIoheZ3zW7n0IZiqTRW_Uo3JyWWeWg5nyKGryvGc2
62
61
  ominfra/manage/deploy/venvs.py,sha256=PlvhyhZavgiSwGt8BXrhoSwQFVKpU0zCtq2C2N1_8Ak,1696
63
62
  ominfra/manage/deploy/conf/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
64
63
  ominfra/manage/deploy/conf/inject.py,sha256=xHZQr7oaJCxaKgpJ0H-hgiQNGt4QsskhT3f5v7xrFwE,451
65
- ominfra/manage/deploy/conf/manager.py,sha256=ZJPwLuly5Jwd6-42umv_hDNr3J86zNrZkNU-RuM0ees,8302
66
- ominfra/manage/deploy/conf/specs.py,sha256=AWeofV1YbcNZS-7WX7EpsX8i_7stJAXndXktB6fDWw8,2187
64
+ ominfra/manage/deploy/conf/manager.py,sha256=0dKI9aDsq31ziKifS_BOnUjec-HR4i0dHvEcF6z-Vo8,8322
65
+ ominfra/manage/deploy/conf/specs.py,sha256=_TCIT5nokZiKEJBL8ZArmPiRt1GEUUC5TaE0QboNhq4,2191
67
66
  ominfra/manage/deploy/paths/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
68
67
  ominfra/manage/deploy/paths/inject.py,sha256=X81C-Qhef1LQ7tILWvkomBwFTvgooLVmWRnKL7TeVoI,596
69
68
  ominfra/manage/deploy/paths/manager.py,sha256=Dnl8euyZQYDGwDzkMvgPAwOssseducr5kP6T0qzVXQk,929
@@ -93,13 +92,13 @@ ominfra/manage/targets/connection.py,sha256=rVI1YJxFClcF-sdttqWyIz9_XjPI01GUdwxY
93
92
  ominfra/manage/targets/inject.py,sha256=P4597xWM-V3I_gCt2O71OLhYQkkXtuJvkYRsIbhhMcE,1561
94
93
  ominfra/manage/targets/targets.py,sha256=7GP6UAZyJFEhpkJN6UQdpr_WN3p7C76v-s445y-WB6U,1885
95
94
  ominfra/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
96
- ominfra/scripts/journald2aws.py,sha256=jxBI2ETft-GMJn0hFwV_lZgT55tj2kqKl0PszxUkOg8,158938
97
- ominfra/scripts/manage.py,sha256=_C2fwegFHqx7OK0dfPZ631HwZHYfCYubi24sDHwSk4U,346082
98
- ominfra/scripts/supervisor.py,sha256=5Nskq1fVdgwXvRXojDmkMO3JlcfQkxOwJ5vgexFi9EE,283429
95
+ ominfra/scripts/journald2aws.py,sha256=Bo_24qN3YI_72BcZYBHid9_SJWnCAmbKRJ3-wE6dGMU,166250
96
+ ominfra/scripts/manage.py,sha256=rsfvEfHm311jZ1uE90DGL2HQqZLvg36-Pybszoywjl4,353278
97
+ ominfra/scripts/supervisor.py,sha256=O0IETZgsTNq8nw_F5mL3Qkk3hHtvRNtZTeAsCixzZXw,291712
99
98
  ominfra/supervisor/LICENSE.txt,sha256=yvqaMNsDhWxziHa9ien6qCW1SkZv-DQlAg96XjfSee8,1746
100
99
  ominfra/supervisor/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
101
100
  ominfra/supervisor/__main__.py,sha256=I0yFw-C08OOiZ3BF6lF1Oiv789EQXu-_j6whDhQUTEA,66
102
- ominfra/supervisor/configs.py,sha256=rA32edDnkfcUYSUPVRG4QIoGwCvnhstaNN2jTXvoqt4,13825
101
+ ominfra/supervisor/configs.py,sha256=zpNZmei-Ajild6WNIGnxsPMGbGBFzr0K81L_gR0vBIA,13847
103
102
  ominfra/supervisor/dispatchers.py,sha256=zXLwQS4Vc6dWw5o9QOL04UMDt7w6CKu9wf19CjUiS2Q,1005
104
103
  ominfra/supervisor/dispatchersimpl.py,sha256=q3dEyOHWTPKm28nmAGisjgIW1BX6O3-SzbYa7nWuTEs,11349
105
104
  ominfra/supervisor/events.py,sha256=XGrtzHr1xm0dwjz329fn9eR0_Ap-LQL6Sk8LJ8eVDEo,6692
@@ -109,7 +108,7 @@ ominfra/supervisor/groupsimpl.py,sha256=PCDyc_Wc-pnvIj56_aEyiA5exCpK6n9iErqnJzO2
109
108
  ominfra/supervisor/http.py,sha256=Tl5eT6dyf4KuQXKbhGo1B6CFEzUDtPl_DZAuUFVD9zI,3453
110
109
  ominfra/supervisor/inject.py,sha256=IeR-WKvK1sGNxMe6G2OBT5kSP7EUP5ipkDgcUFmDPCA,4838
111
110
  ominfra/supervisor/io.py,sha256=moaGNaPuYXEAUzLg8Qjo05DEIcOUNYUj8SSr8eT0d24,3198
112
- ominfra/supervisor/main.py,sha256=7YrreFNntdRCp6MplCclfnRcgrRIb_UCeohJkDC9Few,4251
111
+ ominfra/supervisor/main.py,sha256=GjZXBnfv_f3eIrjiGsJ_aLzynZXovZeY5BNyIptS2Gs,4269
113
112
  ominfra/supervisor/pipes.py,sha256=2ZihNTnRNjnIPOtPbm3_pyqO15f7BNs7WnNtO5V8ahM,2231
114
113
  ominfra/supervisor/privileges.py,sha256=kaRTHI7XjqzxEWCeHp3_0J0Vc4gSPugRbXEwxuw6MYE,2054
115
114
  ominfra/supervisor/process.py,sha256=UaubVxsxVqDnbuWVpTH0DTGbJGLO0vGJ9mNcvy2kCXM,217
@@ -137,9 +136,9 @@ ominfra/tailscale/api.py,sha256=C5-t_b6jZXUWcy5k8bXm7CFnk73pSdrlMOgGDeGVrpw,1370
137
136
  ominfra/tailscale/cli.py,sha256=3FnJbgpLw6gInTfhERd1mDy9ijjMUGxkdYVo43Tnxx4,3555
138
137
  ominfra/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
139
138
  ominfra/tools/listresources.py,sha256=4qVg5txsb10EHhvqXXeM6gJ2jx9LbroEnPydDv1uXs0,6176
140
- ominfra-0.0.0.dev192.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
141
- ominfra-0.0.0.dev192.dist-info/METADATA,sha256=R7AOfKOeQacurgpdYE4zsQs9JRq0tCFHDEVItCCS5Lg,767
142
- ominfra-0.0.0.dev192.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
143
- ominfra-0.0.0.dev192.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
144
- ominfra-0.0.0.dev192.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
145
- ominfra-0.0.0.dev192.dist-info/RECORD,,
139
+ ominfra-0.0.0.dev194.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
140
+ ominfra-0.0.0.dev194.dist-info/METADATA,sha256=Mt6wkbgL4MtaixU5KmXhJ7SaxSqpw10RmamlQgUugFE,767
141
+ ominfra-0.0.0.dev194.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
142
+ ominfra-0.0.0.dev194.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
143
+ ominfra-0.0.0.dev194.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
144
+ ominfra-0.0.0.dev194.dist-info/RECORD,,
ominfra/configs.py DELETED
@@ -1,129 +0,0 @@
1
- # ruff: noqa: UP006 UP007
2
- # @omlish-lite
3
- import io
4
- import json
5
- import os.path
6
- import typing as ta
7
-
8
- from omdev.toml.parser import toml_loads
9
- from omlish.lite.check import check
10
- from omlish.lite.marshal import OBJ_MARSHALER_MANAGER
11
- from omlish.lite.marshal import ObjMarshalerManager
12
-
13
-
14
- T = ta.TypeVar('T')
15
-
16
- ConfigMapping = ta.Mapping[str, ta.Any]
17
-
18
- IniConfigSectionSettingsMap = ta.Mapping[str, ta.Mapping[str, ta.Union[str, ta.Sequence[str]]]] # ta.TypeAlias
19
-
20
-
21
- ##
22
-
23
-
24
- def parse_config_file(
25
- name: str,
26
- f: ta.TextIO,
27
- ) -> ConfigMapping:
28
- if name.endswith('.toml'):
29
- return toml_loads(f.read())
30
-
31
- elif any(name.endswith(e) for e in ('.yml', '.yaml')):
32
- yaml = __import__('yaml')
33
- return yaml.safe_load(f)
34
-
35
- elif name.endswith('.ini'):
36
- import configparser
37
- cp = configparser.ConfigParser()
38
- cp.read_file(f)
39
- config_dct: ta.Dict[str, ta.Any] = {}
40
- for sec in cp.sections():
41
- cd = config_dct
42
- for k in sec.split('.'):
43
- cd = cd.setdefault(k, {})
44
- cd.update(cp.items(sec))
45
- return config_dct
46
-
47
- else:
48
- return json.loads(f.read())
49
-
50
-
51
- def read_config_file(
52
- path: str,
53
- cls: ta.Type[T],
54
- *,
55
- prepare: ta.Optional[ta.Callable[[ConfigMapping], ConfigMapping]] = None,
56
- msh: ObjMarshalerManager = OBJ_MARSHALER_MANAGER,
57
- ) -> T:
58
- with open(path) as cf:
59
- config_dct = parse_config_file(os.path.basename(path), cf)
60
-
61
- if prepare is not None:
62
- config_dct = prepare(config_dct)
63
-
64
- return msh.unmarshal_obj(config_dct, cls)
65
-
66
-
67
- ##
68
-
69
-
70
- def build_config_named_children(
71
- o: ta.Union[
72
- ta.Sequence[ConfigMapping],
73
- ta.Mapping[str, ConfigMapping],
74
- None,
75
- ],
76
- *,
77
- name_key: str = 'name',
78
- ) -> ta.Optional[ta.Sequence[ConfigMapping]]:
79
- if o is None:
80
- return None
81
-
82
- lst: ta.List[ConfigMapping] = []
83
- if isinstance(o, ta.Mapping):
84
- for k, v in o.items():
85
- check.isinstance(v, ta.Mapping)
86
- if name_key in v:
87
- n = v[name_key]
88
- if k != n:
89
- raise KeyError(f'Given names do not match: {n} != {k}')
90
- lst.append(v)
91
- else:
92
- lst.append({name_key: k, **v})
93
-
94
- else:
95
- check.not_isinstance(o, str)
96
- lst.extend(o)
97
-
98
- seen = set()
99
- for d in lst:
100
- n = d['name']
101
- if n in d:
102
- raise KeyError(f'Duplicate name: {n}')
103
- seen.add(n)
104
-
105
- return lst
106
-
107
-
108
- ##
109
-
110
-
111
- def render_ini_config(
112
- settings_by_section: IniConfigSectionSettingsMap,
113
- ) -> str:
114
- out = io.StringIO()
115
-
116
- for i, (section, settings) in enumerate(settings_by_section.items()):
117
- if i:
118
- out.write('\n')
119
-
120
- out.write(f'[{section}]\n')
121
-
122
- for k, v in settings.items():
123
- if isinstance(v, str):
124
- out.write(f'{k}={v}\n')
125
- else:
126
- for vv in v:
127
- out.write(f'{k}={vv}\n')
128
-
129
- return out.getvalue()