ominfra 0.0.0.dev218__py3-none-any.whl → 0.0.0.dev220__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/clouds/aws/instancetypes/cli.py +1 -1
- ominfra/scripts/supervisor.py +101 -48
- ominfra/tools/listresources.py +1 -1
- {ominfra-0.0.0.dev218.dist-info → ominfra-0.0.0.dev220.dist-info}/METADATA +3 -3
- {ominfra-0.0.0.dev218.dist-info → ominfra-0.0.0.dev220.dist-info}/RECORD +9 -9
- {ominfra-0.0.0.dev218.dist-info → ominfra-0.0.0.dev220.dist-info}/LICENSE +0 -0
- {ominfra-0.0.0.dev218.dist-info → ominfra-0.0.0.dev220.dist-info}/WHEEL +0 -0
- {ominfra-0.0.0.dev218.dist-info → ominfra-0.0.0.dev220.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev218.dist-info → ominfra-0.0.0.dev220.dist-info}/top_level.txt +0 -0
@@ -5,9 +5,9 @@ import typing as ta
|
|
5
5
|
|
6
6
|
from omdev.secrets import load_secrets
|
7
7
|
from omlish import lang
|
8
|
-
from omlish import secrets as sec
|
9
8
|
from omlish.argparse import all as ap
|
10
9
|
from omlish.formats import json
|
10
|
+
from omlish.secrets import all as sec
|
11
11
|
|
12
12
|
from .cache import load_instance_types
|
13
13
|
|
ominfra/scripts/supervisor.py
CHANGED
@@ -71,6 +71,7 @@ import select
|
|
71
71
|
import shlex
|
72
72
|
import signal
|
73
73
|
import socket
|
74
|
+
import socket as socket_
|
74
75
|
import stat
|
75
76
|
import string
|
76
77
|
import sys
|
@@ -2820,15 +2821,15 @@ TODO:
|
|
2820
2821
|
class SocketAddressInfoArgs:
|
2821
2822
|
host: ta.Optional[str]
|
2822
2823
|
port: ta.Union[str, int, None]
|
2823
|
-
family:
|
2824
|
+
family: socket_.AddressFamily = socket_.AddressFamily.AF_UNSPEC
|
2824
2825
|
type: int = 0
|
2825
2826
|
proto: int = 0
|
2826
|
-
flags:
|
2827
|
+
flags: socket_.AddressInfo = socket_.AddressInfo(0)
|
2827
2828
|
|
2828
2829
|
|
2829
2830
|
@dc.dataclass(frozen=True)
|
2830
2831
|
class SocketAddressInfo:
|
2831
|
-
family:
|
2832
|
+
family: socket_.AddressFamily
|
2832
2833
|
type: int
|
2833
2834
|
proto: int
|
2834
2835
|
canonname: ta.Optional[str]
|
@@ -2836,32 +2837,44 @@ class SocketAddressInfo:
|
|
2836
2837
|
|
2837
2838
|
|
2838
2839
|
class SocketFamilyAndAddress(ta.NamedTuple):
|
2839
|
-
family:
|
2840
|
+
family: socket_.AddressFamily
|
2840
2841
|
address: SocketAddress
|
2841
2842
|
|
2842
2843
|
|
2843
2844
|
def get_best_socket_family(
|
2844
2845
|
host: ta.Optional[str],
|
2845
2846
|
port: ta.Union[str, int, None],
|
2846
|
-
family: ta.Union[int,
|
2847
|
+
family: ta.Union[int, socket_.AddressFamily] = socket_.AddressFamily.AF_UNSPEC,
|
2847
2848
|
) -> SocketFamilyAndAddress:
|
2848
2849
|
"""https://github.com/python/cpython/commit/f289084c83190cc72db4a70c58f007ec62e75247"""
|
2849
2850
|
|
2850
|
-
infos =
|
2851
|
+
infos = socket_.getaddrinfo(
|
2851
2852
|
host,
|
2852
2853
|
port,
|
2853
2854
|
family,
|
2854
|
-
type=
|
2855
|
-
flags=
|
2855
|
+
type=socket_.SOCK_STREAM,
|
2856
|
+
flags=socket_.AI_PASSIVE,
|
2856
2857
|
)
|
2857
2858
|
ai = SocketAddressInfo(*next(iter(infos)))
|
2858
2859
|
return SocketFamilyAndAddress(ai.family, ai.sockaddr)
|
2859
2860
|
|
2860
2861
|
|
2861
2862
|
class SocketAndAddress(ta.NamedTuple):
|
2862
|
-
socket:
|
2863
|
+
socket: socket_.socket
|
2863
2864
|
address: SocketAddress
|
2864
2865
|
|
2866
|
+
def wrap_socket(self, fn: ta.Callable[[socket_.socket], socket_.socket]):
|
2867
|
+
return self._replace(socket=fn(self.socket))
|
2868
|
+
|
2869
|
+
@classmethod
|
2870
|
+
def socket_wrapper(
|
2871
|
+
cls,
|
2872
|
+
fn: ta.Callable[[socket_.socket], socket_.socket],
|
2873
|
+
) -> ta.Callable[['SocketAndAddress'], 'SocketAndAddress']:
|
2874
|
+
def inner(conn):
|
2875
|
+
return conn.wrap_socket(fn)
|
2876
|
+
return inner
|
2877
|
+
|
2865
2878
|
|
2866
2879
|
########################################
|
2867
2880
|
# ../../../omlish/sockets/io.py
|
@@ -6391,6 +6404,12 @@ def journald_log_handler_factory(
|
|
6391
6404
|
##
|
6392
6405
|
|
6393
6406
|
|
6407
|
+
class SocketHandler_(abc.ABC): # noqa
|
6408
|
+
@abc.abstractmethod
|
6409
|
+
def __call__(self, addr: SocketAddress, f: SocketIoPair) -> None:
|
6410
|
+
raise NotImplementedError
|
6411
|
+
|
6412
|
+
|
6394
6413
|
########################################
|
6395
6414
|
# ../configs.py
|
6396
6415
|
|
@@ -6831,12 +6850,20 @@ class HttpHandlerResponse:
|
|
6831
6850
|
data: ta.Optional[HttpHandlerResponseData] = None
|
6832
6851
|
close_connection: ta.Optional[bool] = None
|
6833
6852
|
|
6853
|
+
def close(self) -> None:
|
6854
|
+
if isinstance(d := self.data, HttpHandlerResponseStreamedData):
|
6855
|
+
d.close()
|
6856
|
+
|
6834
6857
|
|
6835
6858
|
@dc.dataclass(frozen=True)
|
6836
6859
|
class HttpHandlerResponseStreamedData:
|
6837
6860
|
iter: ta.Iterable[bytes]
|
6838
6861
|
length: ta.Optional[int] = None
|
6839
6862
|
|
6863
|
+
def close(self) -> None:
|
6864
|
+
if hasattr(d := self.iter, 'close'):
|
6865
|
+
d.close() # noqa
|
6866
|
+
|
6840
6867
|
|
6841
6868
|
class HttpHandlerError(Exception):
|
6842
6869
|
pass
|
@@ -6846,6 +6873,12 @@ class UnsupportedMethodHttpHandlerError(Exception):
|
|
6846
6873
|
pass
|
6847
6874
|
|
6848
6875
|
|
6876
|
+
class HttpHandler_(abc.ABC): # noqa
|
6877
|
+
@abc.abstractmethod
|
6878
|
+
def __call__(self, req: HttpHandlerRequest) -> HttpHandlerResponse:
|
6879
|
+
raise NotImplementedError
|
6880
|
+
|
6881
|
+
|
6849
6882
|
########################################
|
6850
6883
|
# ../../../omlish/lite/configs.py
|
6851
6884
|
|
@@ -7358,6 +7391,10 @@ class CoroHttpServer:
|
|
7358
7391
|
return h
|
7359
7392
|
return None
|
7360
7393
|
|
7394
|
+
def close(self) -> None:
|
7395
|
+
if isinstance(d := self.data, HttpHandlerResponseStreamedData):
|
7396
|
+
d.close()
|
7397
|
+
|
7361
7398
|
#
|
7362
7399
|
|
7363
7400
|
def _build_response_head_bytes(self, a: _Response) -> bytes:
|
@@ -7573,35 +7610,45 @@ class CoroHttpServer:
|
|
7573
7610
|
while True:
|
7574
7611
|
gen = self.coro_handle_one()
|
7575
7612
|
|
7576
|
-
o = next(gen)
|
7577
7613
|
i: ta.Optional[bytes]
|
7614
|
+
o: ta.Any = next(gen)
|
7578
7615
|
while True:
|
7579
|
-
|
7580
|
-
|
7581
|
-
|
7616
|
+
try:
|
7617
|
+
if isinstance(o, self.AnyLogIo):
|
7618
|
+
i = None
|
7619
|
+
yield o
|
7582
7620
|
|
7583
|
-
|
7584
|
-
|
7621
|
+
elif isinstance(o, self.AnyReadIo):
|
7622
|
+
i = check.isinstance((yield o), bytes)
|
7585
7623
|
|
7586
|
-
|
7587
|
-
|
7624
|
+
elif isinstance(o, self._Response):
|
7625
|
+
i = None
|
7588
7626
|
|
7589
|
-
|
7590
|
-
|
7591
|
-
|
7627
|
+
r = self._preprocess_response(o)
|
7628
|
+
hb = self._build_response_head_bytes(r)
|
7629
|
+
check.none((yield self.WriteIo(hb)))
|
7592
7630
|
|
7593
|
-
|
7594
|
-
|
7631
|
+
for b in self._yield_response_data(r):
|
7632
|
+
yield self.WriteIo(b)
|
7595
7633
|
|
7596
|
-
|
7597
|
-
|
7634
|
+
o.close()
|
7635
|
+
o = None
|
7598
7636
|
|
7599
|
-
|
7600
|
-
|
7601
|
-
|
7602
|
-
|
7603
|
-
|
7604
|
-
|
7637
|
+
else:
|
7638
|
+
raise TypeError(o) # noqa
|
7639
|
+
|
7640
|
+
try:
|
7641
|
+
o = gen.send(i)
|
7642
|
+
except EOFError:
|
7643
|
+
return
|
7644
|
+
except StopIteration:
|
7645
|
+
break
|
7646
|
+
|
7647
|
+
except Exception: # noqa
|
7648
|
+
if hasattr(o, 'close'):
|
7649
|
+
o.close()
|
7650
|
+
|
7651
|
+
raise
|
7605
7652
|
|
7606
7653
|
def coro_handle_one(self) -> ta.Generator[
|
7607
7654
|
ta.Union[AnyLogIo, AnyReadIo, _Response],
|
@@ -7683,34 +7730,40 @@ class CoroHttpServer:
|
|
7683
7730
|
yield self._build_error_response(err)
|
7684
7731
|
return
|
7685
7732
|
|
7686
|
-
|
7733
|
+
try:
|
7734
|
+
# Build internal response
|
7687
7735
|
|
7688
|
-
|
7689
|
-
|
7736
|
+
response_headers = handler_response.headers or {}
|
7737
|
+
response_data = handler_response.data
|
7690
7738
|
|
7691
|
-
|
7692
|
-
|
7693
|
-
|
7739
|
+
headers: ta.List[CoroHttpServer._Header] = [
|
7740
|
+
*self._make_default_headers(),
|
7741
|
+
]
|
7694
7742
|
|
7695
|
-
|
7696
|
-
|
7743
|
+
for k, v in response_headers.items():
|
7744
|
+
headers.append(self._Header(k, v))
|
7697
7745
|
|
7698
|
-
|
7699
|
-
|
7746
|
+
if handler_response.close_connection and 'Connection' not in headers:
|
7747
|
+
headers.append(self._Header('Connection', 'close'))
|
7700
7748
|
|
7701
|
-
|
7702
|
-
|
7703
|
-
|
7704
|
-
|
7705
|
-
|
7706
|
-
|
7707
|
-
|
7749
|
+
yield self._Response(
|
7750
|
+
version=parsed.version,
|
7751
|
+
code=http.HTTPStatus(handler_response.status),
|
7752
|
+
headers=headers,
|
7753
|
+
data=response_data,
|
7754
|
+
close_connection=handler_response.close_connection,
|
7755
|
+
)
|
7756
|
+
|
7757
|
+
except Exception: # noqa
|
7758
|
+
handler_response.close()
|
7759
|
+
|
7760
|
+
raise
|
7708
7761
|
|
7709
7762
|
|
7710
7763
|
##
|
7711
7764
|
|
7712
7765
|
|
7713
|
-
class CoroHttpServerSocketHandler:
|
7766
|
+
class CoroHttpServerSocketHandler(SocketHandler_):
|
7714
7767
|
def __init__(
|
7715
7768
|
self,
|
7716
7769
|
server_factory: CoroHttpServerFactory,
|
ominfra/tools/listresources.py
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ominfra
|
3
|
-
Version: 0.0.0.
|
3
|
+
Version: 0.0.0.dev220
|
4
4
|
Summary: ominfra
|
5
5
|
Author: wrmsr
|
6
6
|
License: BSD-3-Clause
|
@@ -12,8 +12,8 @@ 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.
|
16
|
-
Requires-Dist: omlish==0.0.0.
|
15
|
+
Requires-Dist: omdev==0.0.0.dev220
|
16
|
+
Requires-Dist: omlish==0.0.0.dev220
|
17
17
|
Provides-Extra: all
|
18
18
|
Requires-Dist: paramiko~=3.5; extra == "all"
|
19
19
|
Requires-Dist: asyncssh~=2.18; extra == "all"
|
@@ -16,7 +16,7 @@ ominfra/clouds/aws/instancetypes/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRk
|
|
16
16
|
ominfra/clouds/aws/instancetypes/__main__.py,sha256=Jsrv3P7LX2Cg08W7ByZfZ1JQT4lgLDPW1qNAmShFuMk,75
|
17
17
|
ominfra/clouds/aws/instancetypes/cache.json.gz,sha256=JGgZlMGh2nLPsFmn3PwtV5gO5UMWrjFSFnhniGZKbJc,26375
|
18
18
|
ominfra/clouds/aws/instancetypes/cache.py,sha256=CrfBzOb0DqQhf3ahQS6qQHHH1kVgZyniYOl22RTvjwo,333
|
19
|
-
ominfra/clouds/aws/instancetypes/cli.py,sha256=
|
19
|
+
ominfra/clouds/aws/instancetypes/cli.py,sha256=HcfOchROLGFsxmEIuXtXVywFJWjHOk4yvCKrbZFWVGQ,2195
|
20
20
|
ominfra/clouds/aws/journald2aws/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
21
21
|
ominfra/clouds/aws/journald2aws/__main__.py,sha256=d23loR_cKfTYZwYiqpt_CmKI7dd5WcYFgIYzqMep75E,68
|
22
22
|
ominfra/clouds/aws/journald2aws/cursor.py,sha256=tQ7O6BHlEdaalbiI_Rqagj0aHfdtTQ_ZJwdOSRUjNvQ,1173
|
@@ -114,7 +114,7 @@ ominfra/manage/targets/targets.py,sha256=7GP6UAZyJFEhpkJN6UQdpr_WN3p7C76v-s445y-
|
|
114
114
|
ominfra/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
115
115
|
ominfra/scripts/journald2aws.py,sha256=CM1nZMpecXJpcg7icJUCJ-_DX-7CduQurxZQ7EmhQmA,171450
|
116
116
|
ominfra/scripts/manage.py,sha256=MaUur1_dDdMHt5YnE6Waxa_v70kydHzKCBHXAuTmKd0,362827
|
117
|
-
ominfra/scripts/supervisor.py,sha256=
|
117
|
+
ominfra/scripts/supervisor.py,sha256=7rHuykKUftnClZnwIE3V75k7ESEt4u1Y6l5qo_ifI6E,296250
|
118
118
|
ominfra/supervisor/LICENSE.txt,sha256=ZrHY15PVR98y26Yg6iQfa-SXnUaYTDhrUsPVcEO5OKM,1874
|
119
119
|
ominfra/supervisor/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
|
120
120
|
ominfra/supervisor/__main__.py,sha256=I0yFw-C08OOiZ3BF6lF1Oiv789EQXu-_j6whDhQUTEA,66
|
@@ -155,10 +155,10 @@ ominfra/tailscale/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU
|
|
155
155
|
ominfra/tailscale/api.py,sha256=C5-t_b6jZXUWcy5k8bXm7CFnk73pSdrlMOgGDeGVrpw,1370
|
156
156
|
ominfra/tailscale/cli.py,sha256=3FnJbgpLw6gInTfhERd1mDy9ijjMUGxkdYVo43Tnxx4,3555
|
157
157
|
ominfra/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
158
|
-
ominfra/tools/listresources.py,sha256=
|
159
|
-
ominfra-0.0.0.
|
160
|
-
ominfra-0.0.0.
|
161
|
-
ominfra-0.0.0.
|
162
|
-
ominfra-0.0.0.
|
163
|
-
ominfra-0.0.0.
|
164
|
-
ominfra-0.0.0.
|
158
|
+
ominfra/tools/listresources.py,sha256=BxFoxtyF2aVEcW67ZD9QujoBkJBtvIxGmKqXvLwnEHo,6180
|
159
|
+
ominfra-0.0.0.dev220.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
160
|
+
ominfra-0.0.0.dev220.dist-info/METADATA,sha256=ZGFJV5Q1uT6rEdQR9oMzSmL3uuJARCDlM2QeJJ0n_vI,731
|
161
|
+
ominfra-0.0.0.dev220.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
162
|
+
ominfra-0.0.0.dev220.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
|
163
|
+
ominfra-0.0.0.dev220.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
|
164
|
+
ominfra-0.0.0.dev220.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|