ominfra 0.0.0.dev222__py3-none-any.whl → 0.0.0.dev224__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/scripts/journald2aws.py +128 -6
- ominfra/scripts/manage.py +141 -28
- ominfra/scripts/supervisor.py +107 -14
- ominfra/supervisor/http.py +3 -2
- ominfra/supervisor/inject.py +1 -1
- ominfra/supervisor/utils/strings.py +1 -1
- {ominfra-0.0.0.dev222.dist-info → ominfra-0.0.0.dev224.dist-info}/METADATA +3 -3
- {ominfra-0.0.0.dev222.dist-info → ominfra-0.0.0.dev224.dist-info}/RECORD +12 -12
- {ominfra-0.0.0.dev222.dist-info → ominfra-0.0.0.dev224.dist-info}/LICENSE +0 -0
- {ominfra-0.0.0.dev222.dist-info → ominfra-0.0.0.dev224.dist-info}/WHEEL +0 -0
- {ominfra-0.0.0.dev222.dist-info → ominfra-0.0.0.dev224.dist-info}/entry_points.txt +0 -0
- {ominfra-0.0.0.dev222.dist-info → ominfra-0.0.0.dev224.dist-info}/top_level.txt +0 -0
ominfra/scripts/journald2aws.py
CHANGED
@@ -3388,18 +3388,34 @@ class ObjMarshalerManager:
|
|
3388
3388
|
return reg
|
3389
3389
|
|
3390
3390
|
if abc.ABC in ty.__bases__:
|
3391
|
-
|
3392
|
-
|
3393
|
-
|
3394
|
-
|
3395
|
-
|
3391
|
+
tn = ty.__name__
|
3392
|
+
impls: ta.List[ta.Tuple[type, str]] = [ # type: ignore[var-annotated]
|
3393
|
+
(ity, ity.__name__)
|
3394
|
+
for ity in deep_subclasses(ty)
|
3395
|
+
if abc.ABC not in ity.__bases__
|
3396
|
+
]
|
3397
|
+
|
3398
|
+
if all(itn.endswith(tn) for _, itn in impls):
|
3399
|
+
impls = [
|
3400
|
+
(ity, snake_case(itn[:-len(tn)]))
|
3401
|
+
for ity, itn in impls
|
3402
|
+
]
|
3403
|
+
|
3404
|
+
dupe_tns = sorted(
|
3405
|
+
dn
|
3406
|
+
for dn, dc in collections.Counter(itn for _, itn in impls).items()
|
3407
|
+
if dc > 1
|
3408
|
+
)
|
3409
|
+
if dupe_tns:
|
3410
|
+
raise KeyError(f'Duplicate impl names for {ty}: {dupe_tns}')
|
3411
|
+
|
3396
3412
|
return PolymorphicObjMarshaler.of([
|
3397
3413
|
PolymorphicObjMarshaler.Impl(
|
3398
3414
|
ity,
|
3399
3415
|
itn,
|
3400
3416
|
rec(ity),
|
3401
3417
|
)
|
3402
|
-
for ity, itn in
|
3418
|
+
for ity, itn in impls
|
3403
3419
|
])
|
3404
3420
|
|
3405
3421
|
if issubclass(ty, enum.Enum):
|
@@ -4470,7 +4486,70 @@ class BaseSubprocesses(abc.ABC): # noqa
|
|
4470
4486
|
##
|
4471
4487
|
|
4472
4488
|
|
4489
|
+
@dc.dataclass(frozen=True)
|
4490
|
+
class SubprocessRun:
|
4491
|
+
cmd: ta.Sequence[str]
|
4492
|
+
input: ta.Any = None
|
4493
|
+
timeout: ta.Optional[float] = None
|
4494
|
+
check: bool = False
|
4495
|
+
capture_output: ta.Optional[bool] = None
|
4496
|
+
kwargs: ta.Optional[ta.Mapping[str, ta.Any]] = None
|
4497
|
+
|
4498
|
+
@classmethod
|
4499
|
+
def of(
|
4500
|
+
cls,
|
4501
|
+
*cmd: str,
|
4502
|
+
input: ta.Any = None, # noqa
|
4503
|
+
timeout: ta.Optional[float] = None,
|
4504
|
+
check: bool = False,
|
4505
|
+
capture_output: ta.Optional[bool] = None,
|
4506
|
+
**kwargs: ta.Any,
|
4507
|
+
) -> 'SubprocessRun':
|
4508
|
+
return cls(
|
4509
|
+
cmd=cmd,
|
4510
|
+
input=input,
|
4511
|
+
timeout=timeout,
|
4512
|
+
check=check,
|
4513
|
+
capture_output=capture_output,
|
4514
|
+
kwargs=kwargs,
|
4515
|
+
)
|
4516
|
+
|
4517
|
+
|
4518
|
+
@dc.dataclass(frozen=True)
|
4519
|
+
class SubprocessRunOutput(ta.Generic[T]):
|
4520
|
+
proc: T
|
4521
|
+
|
4522
|
+
returncode: int # noqa
|
4523
|
+
|
4524
|
+
stdout: ta.Optional[bytes] = None
|
4525
|
+
stderr: ta.Optional[bytes] = None
|
4526
|
+
|
4527
|
+
|
4473
4528
|
class AbstractSubprocesses(BaseSubprocesses, abc.ABC):
|
4529
|
+
@abc.abstractmethod
|
4530
|
+
def run_(self, run: SubprocessRun) -> SubprocessRunOutput:
|
4531
|
+
raise NotImplementedError
|
4532
|
+
|
4533
|
+
def run(
|
4534
|
+
self,
|
4535
|
+
*cmd: str,
|
4536
|
+
input: ta.Any = None, # noqa
|
4537
|
+
timeout: ta.Optional[float] = None,
|
4538
|
+
check: bool = False,
|
4539
|
+
capture_output: ta.Optional[bool] = None,
|
4540
|
+
**kwargs: ta.Any,
|
4541
|
+
) -> SubprocessRunOutput:
|
4542
|
+
return self.run_(SubprocessRun(
|
4543
|
+
cmd=cmd,
|
4544
|
+
input=input,
|
4545
|
+
timeout=timeout,
|
4546
|
+
check=check,
|
4547
|
+
capture_output=capture_output,
|
4548
|
+
kwargs=kwargs,
|
4549
|
+
))
|
4550
|
+
|
4551
|
+
#
|
4552
|
+
|
4474
4553
|
@abc.abstractmethod
|
4475
4554
|
def check_call(
|
4476
4555
|
self,
|
@@ -4534,6 +4613,25 @@ class AbstractSubprocesses(BaseSubprocesses, abc.ABC):
|
|
4534
4613
|
|
4535
4614
|
|
4536
4615
|
class Subprocesses(AbstractSubprocesses):
|
4616
|
+
def run_(self, run: SubprocessRun) -> SubprocessRunOutput[subprocess.CompletedProcess]:
|
4617
|
+
proc = subprocess.run(
|
4618
|
+
run.cmd,
|
4619
|
+
input=run.input,
|
4620
|
+
timeout=run.timeout,
|
4621
|
+
check=run.check,
|
4622
|
+
capture_output=run.capture_output or False,
|
4623
|
+
**(run.kwargs or {}),
|
4624
|
+
)
|
4625
|
+
|
4626
|
+
return SubprocessRunOutput(
|
4627
|
+
proc=proc,
|
4628
|
+
|
4629
|
+
returncode=proc.returncode,
|
4630
|
+
|
4631
|
+
stdout=proc.stdout, # noqa
|
4632
|
+
stderr=proc.stderr, # noqa
|
4633
|
+
)
|
4634
|
+
|
4537
4635
|
def check_call(
|
4538
4636
|
self,
|
4539
4637
|
*cmd: str,
|
@@ -4559,6 +4657,30 @@ subprocesses = Subprocesses()
|
|
4559
4657
|
|
4560
4658
|
|
4561
4659
|
class AbstractAsyncSubprocesses(BaseSubprocesses):
|
4660
|
+
@abc.abstractmethod
|
4661
|
+
async def run_(self, run: SubprocessRun) -> SubprocessRunOutput:
|
4662
|
+
raise NotImplementedError
|
4663
|
+
|
4664
|
+
def run(
|
4665
|
+
self,
|
4666
|
+
*cmd: str,
|
4667
|
+
input: ta.Any = None, # noqa
|
4668
|
+
timeout: ta.Optional[float] = None,
|
4669
|
+
check: bool = False,
|
4670
|
+
capture_output: ta.Optional[bool] = None,
|
4671
|
+
**kwargs: ta.Any,
|
4672
|
+
) -> ta.Awaitable[SubprocessRunOutput]:
|
4673
|
+
return self.run_(SubprocessRun(
|
4674
|
+
cmd=cmd,
|
4675
|
+
input=input,
|
4676
|
+
timeout=timeout,
|
4677
|
+
check=check,
|
4678
|
+
capture_output=capture_output,
|
4679
|
+
kwargs=kwargs,
|
4680
|
+
))
|
4681
|
+
|
4682
|
+
#
|
4683
|
+
|
4562
4684
|
@abc.abstractmethod
|
4563
4685
|
async def check_call(
|
4564
4686
|
self,
|
ominfra/scripts/manage.py
CHANGED
@@ -6826,18 +6826,34 @@ class ObjMarshalerManager:
|
|
6826
6826
|
return reg
|
6827
6827
|
|
6828
6828
|
if abc.ABC in ty.__bases__:
|
6829
|
-
|
6830
|
-
|
6831
|
-
|
6832
|
-
|
6833
|
-
|
6829
|
+
tn = ty.__name__
|
6830
|
+
impls: ta.List[ta.Tuple[type, str]] = [ # type: ignore[var-annotated]
|
6831
|
+
(ity, ity.__name__)
|
6832
|
+
for ity in deep_subclasses(ty)
|
6833
|
+
if abc.ABC not in ity.__bases__
|
6834
|
+
]
|
6835
|
+
|
6836
|
+
if all(itn.endswith(tn) for _, itn in impls):
|
6837
|
+
impls = [
|
6838
|
+
(ity, snake_case(itn[:-len(tn)]))
|
6839
|
+
for ity, itn in impls
|
6840
|
+
]
|
6841
|
+
|
6842
|
+
dupe_tns = sorted(
|
6843
|
+
dn
|
6844
|
+
for dn, dc in collections.Counter(itn for _, itn in impls).items()
|
6845
|
+
if dc > 1
|
6846
|
+
)
|
6847
|
+
if dupe_tns:
|
6848
|
+
raise KeyError(f'Duplicate impl names for {ty}: {dupe_tns}')
|
6849
|
+
|
6834
6850
|
return PolymorphicObjMarshaler.of([
|
6835
6851
|
PolymorphicObjMarshaler.Impl(
|
6836
6852
|
ity,
|
6837
6853
|
itn,
|
6838
6854
|
rec(ity),
|
6839
6855
|
)
|
6840
|
-
for ity, itn in
|
6856
|
+
for ity, itn in impls
|
6841
6857
|
])
|
6842
6858
|
|
6843
6859
|
if issubclass(ty, enum.Enum):
|
@@ -8407,7 +8423,70 @@ class BaseSubprocesses(abc.ABC): # noqa
|
|
8407
8423
|
##
|
8408
8424
|
|
8409
8425
|
|
8426
|
+
@dc.dataclass(frozen=True)
|
8427
|
+
class SubprocessRun:
|
8428
|
+
cmd: ta.Sequence[str]
|
8429
|
+
input: ta.Any = None
|
8430
|
+
timeout: ta.Optional[float] = None
|
8431
|
+
check: bool = False
|
8432
|
+
capture_output: ta.Optional[bool] = None
|
8433
|
+
kwargs: ta.Optional[ta.Mapping[str, ta.Any]] = None
|
8434
|
+
|
8435
|
+
@classmethod
|
8436
|
+
def of(
|
8437
|
+
cls,
|
8438
|
+
*cmd: str,
|
8439
|
+
input: ta.Any = None, # noqa
|
8440
|
+
timeout: ta.Optional[float] = None,
|
8441
|
+
check: bool = False,
|
8442
|
+
capture_output: ta.Optional[bool] = None,
|
8443
|
+
**kwargs: ta.Any,
|
8444
|
+
) -> 'SubprocessRun':
|
8445
|
+
return cls(
|
8446
|
+
cmd=cmd,
|
8447
|
+
input=input,
|
8448
|
+
timeout=timeout,
|
8449
|
+
check=check,
|
8450
|
+
capture_output=capture_output,
|
8451
|
+
kwargs=kwargs,
|
8452
|
+
)
|
8453
|
+
|
8454
|
+
|
8455
|
+
@dc.dataclass(frozen=True)
|
8456
|
+
class SubprocessRunOutput(ta.Generic[T]):
|
8457
|
+
proc: T
|
8458
|
+
|
8459
|
+
returncode: int # noqa
|
8460
|
+
|
8461
|
+
stdout: ta.Optional[bytes] = None
|
8462
|
+
stderr: ta.Optional[bytes] = None
|
8463
|
+
|
8464
|
+
|
8410
8465
|
class AbstractSubprocesses(BaseSubprocesses, abc.ABC):
|
8466
|
+
@abc.abstractmethod
|
8467
|
+
def run_(self, run: SubprocessRun) -> SubprocessRunOutput:
|
8468
|
+
raise NotImplementedError
|
8469
|
+
|
8470
|
+
def run(
|
8471
|
+
self,
|
8472
|
+
*cmd: str,
|
8473
|
+
input: ta.Any = None, # noqa
|
8474
|
+
timeout: ta.Optional[float] = None,
|
8475
|
+
check: bool = False,
|
8476
|
+
capture_output: ta.Optional[bool] = None,
|
8477
|
+
**kwargs: ta.Any,
|
8478
|
+
) -> SubprocessRunOutput:
|
8479
|
+
return self.run_(SubprocessRun(
|
8480
|
+
cmd=cmd,
|
8481
|
+
input=input,
|
8482
|
+
timeout=timeout,
|
8483
|
+
check=check,
|
8484
|
+
capture_output=capture_output,
|
8485
|
+
kwargs=kwargs,
|
8486
|
+
))
|
8487
|
+
|
8488
|
+
#
|
8489
|
+
|
8411
8490
|
@abc.abstractmethod
|
8412
8491
|
def check_call(
|
8413
8492
|
self,
|
@@ -8471,6 +8550,25 @@ class AbstractSubprocesses(BaseSubprocesses, abc.ABC):
|
|
8471
8550
|
|
8472
8551
|
|
8473
8552
|
class Subprocesses(AbstractSubprocesses):
|
8553
|
+
def run_(self, run: SubprocessRun) -> SubprocessRunOutput[subprocess.CompletedProcess]:
|
8554
|
+
proc = subprocess.run(
|
8555
|
+
run.cmd,
|
8556
|
+
input=run.input,
|
8557
|
+
timeout=run.timeout,
|
8558
|
+
check=run.check,
|
8559
|
+
capture_output=run.capture_output or False,
|
8560
|
+
**(run.kwargs or {}),
|
8561
|
+
)
|
8562
|
+
|
8563
|
+
return SubprocessRunOutput(
|
8564
|
+
proc=proc,
|
8565
|
+
|
8566
|
+
returncode=proc.returncode,
|
8567
|
+
|
8568
|
+
stdout=proc.stdout, # noqa
|
8569
|
+
stderr=proc.stderr, # noqa
|
8570
|
+
)
|
8571
|
+
|
8474
8572
|
def check_call(
|
8475
8573
|
self,
|
8476
8574
|
*cmd: str,
|
@@ -8496,6 +8594,30 @@ subprocesses = Subprocesses()
|
|
8496
8594
|
|
8497
8595
|
|
8498
8596
|
class AbstractAsyncSubprocesses(BaseSubprocesses):
|
8597
|
+
@abc.abstractmethod
|
8598
|
+
async def run_(self, run: SubprocessRun) -> SubprocessRunOutput:
|
8599
|
+
raise NotImplementedError
|
8600
|
+
|
8601
|
+
def run(
|
8602
|
+
self,
|
8603
|
+
*cmd: str,
|
8604
|
+
input: ta.Any = None, # noqa
|
8605
|
+
timeout: ta.Optional[float] = None,
|
8606
|
+
check: bool = False,
|
8607
|
+
capture_output: ta.Optional[bool] = None,
|
8608
|
+
**kwargs: ta.Any,
|
8609
|
+
) -> ta.Awaitable[SubprocessRunOutput]:
|
8610
|
+
return self.run_(SubprocessRun(
|
8611
|
+
cmd=cmd,
|
8612
|
+
input=input,
|
8613
|
+
timeout=timeout,
|
8614
|
+
check=check,
|
8615
|
+
capture_output=capture_output,
|
8616
|
+
kwargs=kwargs,
|
8617
|
+
))
|
8618
|
+
|
8619
|
+
#
|
8620
|
+
|
8499
8621
|
@abc.abstractmethod
|
8500
8622
|
async def check_call(
|
8501
8623
|
self,
|
@@ -9617,41 +9739,32 @@ class AsyncioSubprocesses(AbstractAsyncSubprocesses):
|
|
9617
9739
|
|
9618
9740
|
#
|
9619
9741
|
|
9620
|
-
|
9621
|
-
|
9622
|
-
proc: asyncio.subprocess.Process
|
9623
|
-
stdout: ta.Optional[bytes]
|
9624
|
-
stderr: ta.Optional[bytes]
|
9742
|
+
async def run_(self, run: SubprocessRun) -> SubprocessRunOutput[asyncio.subprocess.Process]:
|
9743
|
+
kwargs = dict(run.kwargs or {})
|
9625
9744
|
|
9626
|
-
|
9627
|
-
self,
|
9628
|
-
*cmd: str,
|
9629
|
-
input: ta.Any = None, # noqa
|
9630
|
-
timeout: ta.Optional[float] = None,
|
9631
|
-
check: bool = False, # noqa
|
9632
|
-
capture_output: ta.Optional[bool] = None,
|
9633
|
-
**kwargs: ta.Any,
|
9634
|
-
) -> RunOutput:
|
9635
|
-
if capture_output:
|
9745
|
+
if run.capture_output:
|
9636
9746
|
kwargs.setdefault('stdout', subprocess.PIPE)
|
9637
9747
|
kwargs.setdefault('stderr', subprocess.PIPE)
|
9638
9748
|
|
9639
9749
|
proc: asyncio.subprocess.Process
|
9640
|
-
async with self.popen(*cmd, **kwargs) as proc:
|
9641
|
-
stdout, stderr = await self.communicate(proc, input, timeout)
|
9750
|
+
async with self.popen(*run.cmd, **kwargs) as proc:
|
9751
|
+
stdout, stderr = await self.communicate(proc, run.input, run.timeout)
|
9642
9752
|
|
9643
9753
|
if check and proc.returncode:
|
9644
9754
|
raise subprocess.CalledProcessError(
|
9645
9755
|
proc.returncode,
|
9646
|
-
cmd,
|
9756
|
+
run.cmd,
|
9647
9757
|
output=stdout,
|
9648
9758
|
stderr=stderr,
|
9649
9759
|
)
|
9650
9760
|
|
9651
|
-
return
|
9652
|
-
proc,
|
9653
|
-
|
9654
|
-
|
9761
|
+
return SubprocessRunOutput(
|
9762
|
+
proc=proc,
|
9763
|
+
|
9764
|
+
returncode=check.isinstance(proc.returncode, int),
|
9765
|
+
|
9766
|
+
stdout=stdout,
|
9767
|
+
stderr=stderr,
|
9655
9768
|
)
|
9656
9769
|
|
9657
9770
|
#
|
ominfra/scripts/supervisor.py
CHANGED
@@ -599,7 +599,7 @@ class SuffixMultiplier:
|
|
599
599
|
for k in d:
|
600
600
|
if self._keysz is None:
|
601
601
|
self._keysz = len(k)
|
602
|
-
elif self._keysz != len(k):
|
602
|
+
elif self._keysz != len(k):
|
603
603
|
raise ValueError(k)
|
604
604
|
|
605
605
|
def __call__(self, v: ta.Union[str, int]) -> int:
|
@@ -3929,6 +3929,8 @@ class HttpRequestParser:
|
|
3929
3929
|
|
3930
3930
|
#
|
3931
3931
|
|
3932
|
+
_TLS_HANDSHAKE_PREFIX = b'\x16'
|
3933
|
+
|
3932
3934
|
def coro_parse(self) -> ta.Generator[int, bytes, ParseHttpRequestResult]:
|
3933
3935
|
raw_request_line = yield self._max_line + 1
|
3934
3936
|
|
@@ -3967,6 +3969,17 @@ class HttpRequestParser:
|
|
3967
3969
|
if not raw_request_line:
|
3968
3970
|
return EmptyParsedHttpResult(**result_kwargs())
|
3969
3971
|
|
3972
|
+
# Detect TLS
|
3973
|
+
|
3974
|
+
if raw_request_line.startswith(self._TLS_HANDSHAKE_PREFIX):
|
3975
|
+
return ParseHttpRequestError(
|
3976
|
+
code=http.HTTPStatus.BAD_REQUEST,
|
3977
|
+
message='Bad request version (probable TLS handshake)',
|
3978
|
+
**result_kwargs(),
|
3979
|
+
)
|
3980
|
+
|
3981
|
+
# Decode line
|
3982
|
+
|
3970
3983
|
request_line = raw_request_line.decode('iso-8859-1').rstrip('\r\n')
|
3971
3984
|
|
3972
3985
|
# Split words
|
@@ -5984,18 +5997,34 @@ class ObjMarshalerManager:
|
|
5984
5997
|
return reg
|
5985
5998
|
|
5986
5999
|
if abc.ABC in ty.__bases__:
|
5987
|
-
|
5988
|
-
|
5989
|
-
|
5990
|
-
|
5991
|
-
|
6000
|
+
tn = ty.__name__
|
6001
|
+
impls: ta.List[ta.Tuple[type, str]] = [ # type: ignore[var-annotated]
|
6002
|
+
(ity, ity.__name__)
|
6003
|
+
for ity in deep_subclasses(ty)
|
6004
|
+
if abc.ABC not in ity.__bases__
|
6005
|
+
]
|
6006
|
+
|
6007
|
+
if all(itn.endswith(tn) for _, itn in impls):
|
6008
|
+
impls = [
|
6009
|
+
(ity, snake_case(itn[:-len(tn)]))
|
6010
|
+
for ity, itn in impls
|
6011
|
+
]
|
6012
|
+
|
6013
|
+
dupe_tns = sorted(
|
6014
|
+
dn
|
6015
|
+
for dn, dc in collections.Counter(itn for _, itn in impls).items()
|
6016
|
+
if dc > 1
|
6017
|
+
)
|
6018
|
+
if dupe_tns:
|
6019
|
+
raise KeyError(f'Duplicate impl names for {ty}: {dupe_tns}')
|
6020
|
+
|
5992
6021
|
return PolymorphicObjMarshaler.of([
|
5993
6022
|
PolymorphicObjMarshaler.Impl(
|
5994
6023
|
ity,
|
5995
6024
|
itn,
|
5996
6025
|
rec(ity),
|
5997
6026
|
)
|
5998
|
-
for ity, itn in
|
6027
|
+
for ity, itn in impls
|
5999
6028
|
])
|
6000
6029
|
|
6001
6030
|
if issubclass(ty, enum.Enum):
|
@@ -6879,6 +6908,70 @@ class HttpHandler_(abc.ABC): # noqa
|
|
6879
6908
|
raise NotImplementedError
|
6880
6909
|
|
6881
6910
|
|
6911
|
+
##
|
6912
|
+
|
6913
|
+
|
6914
|
+
@dc.dataclass(frozen=True)
|
6915
|
+
class LoggingHttpHandler(HttpHandler_):
|
6916
|
+
handler: HttpHandler
|
6917
|
+
log: logging.Logger
|
6918
|
+
level: int = logging.DEBUG
|
6919
|
+
|
6920
|
+
def __call__(self, req: HttpHandlerRequest) -> HttpHandlerResponse:
|
6921
|
+
self.log.log(self.level, '%r', req)
|
6922
|
+
resp = self.handler(req)
|
6923
|
+
self.log.log(self.level, '%r', resp)
|
6924
|
+
return resp
|
6925
|
+
|
6926
|
+
|
6927
|
+
##
|
6928
|
+
|
6929
|
+
|
6930
|
+
@dc.dataclass(frozen=True)
|
6931
|
+
class BytesResponseHttpHandler(HttpHandler_):
|
6932
|
+
data: bytes
|
6933
|
+
|
6934
|
+
status: ta.Union[http.HTTPStatus, int] = 200
|
6935
|
+
content_type: ta.Optional[str] = 'application/octet-stream'
|
6936
|
+
headers: ta.Optional[ta.Mapping[str, str]] = None
|
6937
|
+
close_connection: bool = True
|
6938
|
+
|
6939
|
+
def __call__(self, req: HttpHandlerRequest) -> HttpHandlerResponse:
|
6940
|
+
return HttpHandlerResponse(
|
6941
|
+
status=self.status,
|
6942
|
+
headers={
|
6943
|
+
**({'Content-Type': self.content_type} if self.content_type else {}),
|
6944
|
+
'Content-Length': str(len(self.data)),
|
6945
|
+
**(self.headers or {}),
|
6946
|
+
},
|
6947
|
+
data=self.data,
|
6948
|
+
close_connection=self.close_connection,
|
6949
|
+
)
|
6950
|
+
|
6951
|
+
|
6952
|
+
@dc.dataclass(frozen=True)
|
6953
|
+
class StringResponseHttpHandler(HttpHandler_):
|
6954
|
+
data: str
|
6955
|
+
|
6956
|
+
status: ta.Union[http.HTTPStatus, int] = 200
|
6957
|
+
content_type: ta.Optional[str] = 'text/plain; charset=utf-8'
|
6958
|
+
headers: ta.Optional[ta.Mapping[str, str]] = None
|
6959
|
+
close_connection: bool = True
|
6960
|
+
|
6961
|
+
def __call__(self, req: HttpHandlerRequest) -> HttpHandlerResponse:
|
6962
|
+
data = self.data.encode('utf-8')
|
6963
|
+
return HttpHandlerResponse(
|
6964
|
+
status=self.status,
|
6965
|
+
headers={
|
6966
|
+
**({'Content-Type': self.content_type} if self.content_type else {}),
|
6967
|
+
'Content-Length': str(len(data)),
|
6968
|
+
**(self.headers or {}),
|
6969
|
+
},
|
6970
|
+
data=data,
|
6971
|
+
close_connection=self.close_connection,
|
6972
|
+
)
|
6973
|
+
|
6974
|
+
|
6882
6975
|
########################################
|
6883
6976
|
# ../../../omlish/lite/configs.py
|
6884
6977
|
|
@@ -7682,7 +7775,7 @@ class CoroHttpServer:
|
|
7682
7775
|
if isinstance(parsed, ParseHttpRequestError):
|
7683
7776
|
err = self._build_error(
|
7684
7777
|
parsed.code,
|
7685
|
-
*parsed.message,
|
7778
|
+
*([parsed.message] if isinstance(parsed.message, str) else parsed.message),
|
7686
7779
|
version=parsed.version,
|
7687
7780
|
)
|
7688
7781
|
yield self.ErrorLogIo(err)
|
@@ -8544,7 +8637,7 @@ class CoroHttpServerConnectionFdioHandler(SocketFdioHandler):
|
|
8544
8637
|
self._log_handler = log_handler
|
8545
8638
|
|
8546
8639
|
self._read_buf = ReadableListBuffer()
|
8547
|
-
self._write_buf: IncrementalWriteBuffer
|
8640
|
+
self._write_buf: ta.Optional[IncrementalWriteBuffer] = None
|
8548
8641
|
|
8549
8642
|
self._coro_srv = CoroHttpServer(
|
8550
8643
|
addr,
|
@@ -8552,7 +8645,7 @@ class CoroHttpServerConnectionFdioHandler(SocketFdioHandler):
|
|
8552
8645
|
)
|
8553
8646
|
self._srv_coro: ta.Optional[ta.Generator[CoroHttpServer.Io, ta.Optional[bytes], None]] = self._coro_srv.coro_handle() # noqa
|
8554
8647
|
|
8555
|
-
self._cur_io: CoroHttpServer.Io
|
8648
|
+
self._cur_io: ta.Optional[CoroHttpServer.Io] = None
|
8556
8649
|
self._next_io()
|
8557
8650
|
|
8558
8651
|
#
|
@@ -8560,7 +8653,7 @@ class CoroHttpServerConnectionFdioHandler(SocketFdioHandler):
|
|
8560
8653
|
def _next_io(self) -> None: # noqa
|
8561
8654
|
coro = check.not_none(self._srv_coro)
|
8562
8655
|
|
8563
|
-
d: bytes
|
8656
|
+
d: ta.Optional[bytes] = None
|
8564
8657
|
o = self._cur_io
|
8565
8658
|
while True:
|
8566
8659
|
if o is None:
|
@@ -8937,7 +9030,7 @@ class HttpServer(HasDispatchers):
|
|
8937
9030
|
##
|
8938
9031
|
|
8939
9032
|
|
8940
|
-
class SupervisorHttpHandler:
|
9033
|
+
class SupervisorHttpHandler(HttpHandler_):
|
8941
9034
|
def __init__(
|
8942
9035
|
self,
|
8943
9036
|
*,
|
@@ -8947,7 +9040,7 @@ class SupervisorHttpHandler:
|
|
8947
9040
|
|
8948
9041
|
self._groups = groups
|
8949
9042
|
|
8950
|
-
def
|
9043
|
+
def __call__(self, req: HttpHandlerRequest) -> HttpHandlerResponse:
|
8951
9044
|
dct = {
|
8952
9045
|
'method': req.method,
|
8953
9046
|
'path': req.path,
|
@@ -10163,7 +10256,7 @@ def bind_server(
|
|
10163
10256
|
|
10164
10257
|
if config.http_port is not None:
|
10165
10258
|
def _provide_http_handler(s: SupervisorHttpHandler) -> HttpServer.Handler:
|
10166
|
-
return HttpServer.Handler(s
|
10259
|
+
return HttpServer.Handler(s)
|
10167
10260
|
|
10168
10261
|
lst.extend([
|
10169
10262
|
inj.bind(HttpServer, singleton=True, eager=True),
|
ominfra/supervisor/http.py
CHANGED
@@ -6,6 +6,7 @@ import typing as ta
|
|
6
6
|
|
7
7
|
from omlish.http.coro.fdio import CoroHttpServerConnectionFdioHandler
|
8
8
|
from omlish.http.handlers import HttpHandler
|
9
|
+
from omlish.http.handlers import HttpHandler_
|
9
10
|
from omlish.http.handlers import HttpHandlerRequest
|
10
11
|
from omlish.http.handlers import HttpHandlerResponse
|
11
12
|
from omlish.io.fdio.handlers import SocketFdioHandler
|
@@ -98,7 +99,7 @@ class HttpServer(HasDispatchers):
|
|
98
99
|
##
|
99
100
|
|
100
101
|
|
101
|
-
class SupervisorHttpHandler:
|
102
|
+
class SupervisorHttpHandler(HttpHandler_):
|
102
103
|
def __init__(
|
103
104
|
self,
|
104
105
|
*,
|
@@ -108,7 +109,7 @@ class SupervisorHttpHandler:
|
|
108
109
|
|
109
110
|
self._groups = groups
|
110
111
|
|
111
|
-
def
|
112
|
+
def __call__(self, req: HttpHandlerRequest) -> HttpHandlerResponse:
|
112
113
|
dct = {
|
113
114
|
'method': req.method,
|
114
115
|
'path': req.path,
|
ominfra/supervisor/inject.py
CHANGED
@@ -133,7 +133,7 @@ def bind_server(
|
|
133
133
|
|
134
134
|
if config.http_port is not None:
|
135
135
|
def _provide_http_handler(s: SupervisorHttpHandler) -> HttpServer.Handler:
|
136
|
-
return HttpServer.Handler(s
|
136
|
+
return HttpServer.Handler(s)
|
137
137
|
|
138
138
|
lst.extend([
|
139
139
|
inj.bind(HttpServer, singleton=True, eager=True),
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.2
|
2
2
|
Name: ominfra
|
3
|
-
Version: 0.0.0.
|
3
|
+
Version: 0.0.0.dev224
|
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.dev224
|
16
|
+
Requires-Dist: omlish==0.0.0.dev224
|
17
17
|
Provides-Extra: all
|
18
18
|
Requires-Dist: paramiko~=3.5; extra == "all"
|
19
19
|
Requires-Dist: asyncssh~=2.18; extra == "all"
|
@@ -112,9 +112,9 @@ ominfra/manage/targets/connection.py,sha256=rVI1YJxFClcF-sdttqWyIz9_XjPI01GUdwxY
|
|
112
112
|
ominfra/manage/targets/inject.py,sha256=P4597xWM-V3I_gCt2O71OLhYQkkXtuJvkYRsIbhhMcE,1561
|
113
113
|
ominfra/manage/targets/targets.py,sha256=7GP6UAZyJFEhpkJN6UQdpr_WN3p7C76v-s445y-WB6U,1885
|
114
114
|
ominfra/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
115
|
-
ominfra/scripts/journald2aws.py,sha256=
|
116
|
-
ominfra/scripts/manage.py,sha256=
|
117
|
-
ominfra/scripts/supervisor.py,sha256=
|
115
|
+
ominfra/scripts/journald2aws.py,sha256=RzHOaeG2Pjoo3KVNdj-5HFZrGDNTXaHEu71UqPHA9KM,174660
|
116
|
+
ominfra/scripts/manage.py,sha256=IrlDAT-VvIPWa030ZtWvVR6xea8nuQiMK8XqmxZTmNs,365825
|
117
|
+
ominfra/scripts/supervisor.py,sha256=Bd6uUGc3-6xq9VVvmXfOR4mM22-jaR8-ba0Ib5iBVs8,299210
|
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
|
@@ -125,8 +125,8 @@ ominfra/supervisor/events.py,sha256=XGrtzHr1xm0dwjz329fn9eR0_Ap-LQL6Sk8LJ8eVDEo,
|
|
125
125
|
ominfra/supervisor/exceptions.py,sha256=Qbu211H3CLlSmi9LsSikOwrcL5HgJP9ugvcKWlGTAoI,750
|
126
126
|
ominfra/supervisor/groups.py,sha256=MBbsbt8Zh_WEYkGOr1KXa82gnPVw9wPB2lAnqhugXSc,2457
|
127
127
|
ominfra/supervisor/groupsimpl.py,sha256=PCDyc_Wc-pnvIj56_aEyiA5exCpK6n9iErqnJzO2rZk,2281
|
128
|
-
ominfra/supervisor/http.py,sha256=
|
129
|
-
ominfra/supervisor/inject.py,sha256=
|
128
|
+
ominfra/supervisor/http.py,sha256=LxhF-C7VyZ8WxzjhrHSLU9rCo26OF81IgZzvqSaCYtk,3449
|
129
|
+
ominfra/supervisor/inject.py,sha256=z3rVyAJMdvNxIewryuCF67uGpvUduhYV6-PnW00_4sw,4831
|
130
130
|
ominfra/supervisor/io.py,sha256=moaGNaPuYXEAUzLg8Qjo05DEIcOUNYUj8SSr8eT0d24,3198
|
131
131
|
ominfra/supervisor/main.py,sha256=zCVuHZG2kGIPHwTLH4EUr5xpN4vJYessmKO2P0NE5RU,4381
|
132
132
|
ominfra/supervisor/pipes.py,sha256=2ZihNTnRNjnIPOtPbm3_pyqO15f7BNs7WnNtO5V8ahM,2231
|
@@ -149,16 +149,16 @@ ominfra/supervisor/utils/fs.py,sha256=ABbNcsCpzSXAvq_ZZSCj61mj5kGnVuC4spUmoWenlq
|
|
149
149
|
ominfra/supervisor/utils/os.py,sha256=S-y50uhwUhYklIkYRXTHiejnWj_wtofplaOvFqwS0iM,2399
|
150
150
|
ominfra/supervisor/utils/ostypes.py,sha256=B7VjwbzVesz9we9MztoSk8bH8sTxMIWtILy_Qde0G7w,164
|
151
151
|
ominfra/supervisor/utils/signals.py,sha256=uZkTvissbtq7TlJD4MkTiL3F-zyWmAFUuWQtFjsf0MI,1474
|
152
|
-
ominfra/supervisor/utils/strings.py,sha256=
|
152
|
+
ominfra/supervisor/utils/strings.py,sha256=TQibMzwUFOPt3sE9a9DEYWgGlvxiQsQYATRHX1XjQRw,2459
|
153
153
|
ominfra/supervisor/utils/users.py,sha256=PRUhWy74WQCxix4BLNYcWW1i2mF1IyAxj1RzElnP4iM,1345
|
154
154
|
ominfra/tailscale/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
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
158
|
ominfra/tools/listresources.py,sha256=BxFoxtyF2aVEcW67ZD9QujoBkJBtvIxGmKqXvLwnEHo,6180
|
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.
|
159
|
+
ominfra-0.0.0.dev224.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
|
160
|
+
ominfra-0.0.0.dev224.dist-info/METADATA,sha256=0AC0qHfJ_AOl0R7bQPEr76-2LIxnn23jkLdKdnSyltQ,731
|
161
|
+
ominfra-0.0.0.dev224.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
162
|
+
ominfra-0.0.0.dev224.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
|
163
|
+
ominfra-0.0.0.dev224.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
|
164
|
+
ominfra-0.0.0.dev224.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|