ominfra 0.0.0.dev143__py3-none-any.whl → 0.0.0.dev144__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
File without changes
@@ -0,0 +1,23 @@
1
+ # ruff: noqa: UP006 UP007
2
+ import dataclasses as dc
3
+
4
+ from ..commands.base import Command
5
+ from ..commands.base import CommandExecutor
6
+
7
+
8
+ ##
9
+
10
+
11
+ @dc.dataclass(frozen=True)
12
+ class DeployCommand(Command['DeployCommand.Output']):
13
+ @dc.dataclass(frozen=True)
14
+ class Output(Command.Output):
15
+ pass
16
+
17
+
18
+ ##
19
+
20
+
21
+ class DeployCommandExecutor(CommandExecutor[DeployCommand, DeployCommand.Output]):
22
+ def execute(self, cmd: DeployCommand) -> DeployCommand.Output:
23
+ return DeployCommand.Output()
@@ -0,0 +1,19 @@
1
+ # ruff: noqa: UP006 UP007
2
+ import typing as ta
3
+
4
+ from omlish.lite.inject import InjectorBindingOrBindings
5
+ from omlish.lite.inject import InjectorBindings
6
+ from omlish.lite.inject import inj
7
+
8
+ from ..commands.inject import bind_command
9
+ from .command import DeployCommand
10
+ from .command import DeployCommandExecutor
11
+
12
+
13
+ def bind_deploy(
14
+ ) -> InjectorBindings:
15
+ lst: ta.List[InjectorBindingOrBindings] = [
16
+ bind_command(DeployCommand, DeployCommandExecutor),
17
+ ]
18
+
19
+ return inj.as_bindings(*lst)
ominfra/manage/inject.py CHANGED
@@ -8,6 +8,7 @@ from omlish.lite.marshal import ObjMarshalerManager
8
8
 
9
9
  from .commands.inject import bind_commands
10
10
  from .config import MainConfig
11
+ from .deploy.inject import bind_deploy
11
12
  from .marshal import ObjMarshalerInstaller
12
13
  from .marshal import ObjMarshalerInstallers
13
14
  from .remote.config import RemoteConfig
@@ -32,6 +33,8 @@ def bind_main(
32
33
  bind_remote(
33
34
  remote_config=remote_config,
34
35
  ),
36
+
37
+ bind_deploy(),
35
38
  ]
36
39
 
37
40
  #
ominfra/manage/main.py CHANGED
@@ -5,15 +5,21 @@
5
5
  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
+ import contextlib
9
+ import typing as ta
10
+
8
11
  from omlish.lite.logs import log # noqa
9
- from omlish.lite.marshal import ObjMarshalOptions
10
12
  from omlish.lite.marshal import ObjMarshalerManager
13
+ from omlish.lite.marshal import ObjMarshalOptions
11
14
  from omlish.lite.pycharm import PycharmRemoteDebug
12
15
 
13
16
  from .bootstrap import MainBootstrap
14
17
  from .bootstrap_ import main_bootstrap
18
+ from .commands.base import Command
19
+ from .commands.base import CommandExecutor
15
20
  from .commands.subprocess import SubprocessCommand
16
21
  from .config import MainConfig
22
+ from .deploy.command import DeployCommand
17
23
  from .remote.config import RemoteConfig
18
24
  from .remote.execution import RemoteExecution
19
25
  from .remote.spawning import RemoteSpawning
@@ -39,6 +45,8 @@ def _main() -> None:
39
45
 
40
46
  parser.add_argument('--debug', action='store_true')
41
47
 
48
+ parser.add_argument('--local', action='store_true')
49
+
42
50
  parser.add_argument('command', nargs='+')
43
51
 
44
52
  args = parser.parse_args()
@@ -69,28 +77,34 @@ def _main() -> None:
69
77
 
70
78
  #
71
79
 
72
- cmds = [
73
- SubprocessCommand([c])
74
- for c in args.command
75
- ]
80
+ cmds: ta.List[Command] = []
81
+ for c in args.command:
82
+ if c == 'deploy':
83
+ cmds.append(DeployCommand())
84
+ else:
85
+ cmds.append(SubprocessCommand([c]))
76
86
 
77
87
  #
78
88
 
79
- tgt = RemoteSpawning.Target(
80
- shell=args.shell,
81
- shell_quote=args.shell_quote,
82
- python=args.python,
83
- )
89
+ with contextlib.ExitStack() as es:
90
+ ce: CommandExecutor
84
91
 
85
- with injector[RemoteExecution].connect(tgt, bs) as rce:
86
- for cmd in cmds:
87
- r = rce.try_execute(cmd)
92
+ if args.local:
93
+ ce = injector[CommandExecutor]
88
94
 
89
- print(injector[ObjMarshalerManager].marshal_obj(r, opts=ObjMarshalOptions(raw_bytes=True)))
95
+ else:
96
+ tgt = RemoteSpawning.Target(
97
+ shell=args.shell,
98
+ shell_quote=args.shell_quote,
99
+ python=args.python,
100
+ )
90
101
 
91
- #
102
+ ce = es.enter_context(injector[RemoteExecution].connect(tgt, bs)) # noqa
92
103
 
93
- print('Success')
104
+ for cmd in cmds:
105
+ r = ce.try_execute(cmd)
106
+
107
+ print(injector[ObjMarshalerManager].marshal_obj(r, opts=ObjMarshalOptions(raw_bytes=True)))
94
108
 
95
109
 
96
110
  if __name__ == '__main__':
ominfra/scripts/manage.py CHANGED
@@ -2807,6 +2807,28 @@ def install_command_marshaling(
2807
2807
  )
2808
2808
 
2809
2809
 
2810
+ ########################################
2811
+ # ../deploy/command.py
2812
+
2813
+
2814
+ ##
2815
+
2816
+
2817
+ @dc.dataclass(frozen=True)
2818
+ class DeployCommand(Command['DeployCommand.Output']):
2819
+ @dc.dataclass(frozen=True)
2820
+ class Output(Command.Output):
2821
+ pass
2822
+
2823
+
2824
+ ##
2825
+
2826
+
2827
+ class DeployCommandExecutor(CommandExecutor[DeployCommand, DeployCommand.Output]):
2828
+ def execute(self, cmd: DeployCommand) -> DeployCommand.Output:
2829
+ return DeployCommand.Output()
2830
+
2831
+
2810
2832
  ########################################
2811
2833
  # ../marshal.py
2812
2834
 
@@ -3423,6 +3445,19 @@ class RemoteExecution:
3423
3445
  yield RemoteCommandExecutor(chan)
3424
3446
 
3425
3447
 
3448
+ ########################################
3449
+ # ../deploy/inject.py
3450
+
3451
+
3452
+ def bind_deploy(
3453
+ ) -> InjectorBindings:
3454
+ lst: ta.List[InjectorBindingOrBindings] = [
3455
+ bind_command(DeployCommand, DeployCommandExecutor),
3456
+ ]
3457
+
3458
+ return inj.as_bindings(*lst)
3459
+
3460
+
3426
3461
  ########################################
3427
3462
  # ../remote/inject.py
3428
3463
 
@@ -3467,6 +3502,8 @@ def bind_main(
3467
3502
  bind_remote(
3468
3503
  remote_config=remote_config,
3469
3504
  ),
3505
+
3506
+ bind_deploy(),
3470
3507
  ]
3471
3508
 
3472
3509
  #
@@ -3530,6 +3567,8 @@ def _main() -> None:
3530
3567
 
3531
3568
  parser.add_argument('--debug', action='store_true')
3532
3569
 
3570
+ parser.add_argument('--local', action='store_true')
3571
+
3533
3572
  parser.add_argument('command', nargs='+')
3534
3573
 
3535
3574
  args = parser.parse_args()
@@ -3560,28 +3599,34 @@ def _main() -> None:
3560
3599
 
3561
3600
  #
3562
3601
 
3563
- cmds = [
3564
- SubprocessCommand([c])
3565
- for c in args.command
3566
- ]
3602
+ cmds: ta.List[Command] = []
3603
+ for c in args.command:
3604
+ if c == 'deploy':
3605
+ cmds.append(DeployCommand())
3606
+ else:
3607
+ cmds.append(SubprocessCommand([c]))
3567
3608
 
3568
3609
  #
3569
3610
 
3570
- tgt = RemoteSpawning.Target(
3571
- shell=args.shell,
3572
- shell_quote=args.shell_quote,
3573
- python=args.python,
3574
- )
3611
+ with contextlib.ExitStack() as es:
3612
+ ce: CommandExecutor
3575
3613
 
3576
- with injector[RemoteExecution].connect(tgt, bs) as rce:
3577
- for cmd in cmds:
3578
- r = rce.try_execute(cmd)
3614
+ if args.local:
3615
+ ce = injector[CommandExecutor]
3579
3616
 
3580
- print(injector[ObjMarshalerManager].marshal_obj(r, opts=ObjMarshalOptions(raw_bytes=True)))
3617
+ else:
3618
+ tgt = RemoteSpawning.Target(
3619
+ shell=args.shell,
3620
+ shell_quote=args.shell_quote,
3621
+ python=args.python,
3622
+ )
3581
3623
 
3582
- #
3624
+ ce = es.enter_context(injector[RemoteExecution].connect(tgt, bs)) # noqa
3583
3625
 
3584
- print('Success')
3626
+ for cmd in cmds:
3627
+ r = ce.try_execute(cmd)
3628
+
3629
+ print(injector[ObjMarshalerManager].marshal_obj(r, opts=ObjMarshalOptions(raw_bytes=True)))
3585
3630
 
3586
3631
 
3587
3632
  if __name__ == '__main__':
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ominfra
3
- Version: 0.0.0.dev143
3
+ Version: 0.0.0.dev144
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.dev143
16
- Requires-Dist: omlish==0.0.0.dev143
15
+ Requires-Dist: omdev==0.0.0.dev144
16
+ Requires-Dist: omlish==0.0.0.dev144
17
17
  Provides-Extra: all
18
18
  Requires-Dist: paramiko~=3.5; extra == "all"
19
19
  Requires-Dist: asyncssh~=2.18; extra == "all"
@@ -32,8 +32,8 @@ ominfra/manage/__main__.py,sha256=5IeIERm-371fSI5ZvPv8eldAJBwgKwpR0R49pTsILNM,76
32
32
  ominfra/manage/bootstrap.py,sha256=puGpmK6b6ZCAX5E_HI9ucUuWlXB4U_4Xwc2x8GAKSVo,240
33
33
  ominfra/manage/bootstrap_.py,sha256=WVry3P5ViPpdEC_-EFBouZTECMxs4CwRbek4Oz_iRbc,517
34
34
  ominfra/manage/config.py,sha256=1y2N_8nXHBZc6YbW6BaRZoDDCTBmiHuWtTOQ7zdr5VE,184
35
- ominfra/manage/inject.py,sha256=VuSnejEwEPWgVDEmyAqyNfJl-akWoBZUah066up3sqQ,1332
36
- ominfra/manage/main.py,sha256=HzBXHdtN69UKk3_qxlu-OrPpa3PddL4eavUemxP36PY,2399
35
+ ominfra/manage/inject.py,sha256=jGjGqlecpxzpJR3-RqQhEBOmpsix5UwSsvrz5DbayC4,1395
36
+ ominfra/manage/main.py,sha256=F8XJx8JvDDoDRUGgDyMb22dCuyySUkUvZW-XtGwKHMU,2909
37
37
  ominfra/manage/marshal.py,sha256=WKj7IU9bo4fBMSSzT6ZMm_WFalXIJZ-V7j8oi92fNhk,305
38
38
  ominfra/manage/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
39
39
  ominfra/manage/commands/base.py,sha256=yhOAh893iJrk0SvgkRZQMLw8cvStEI2IaHKP9Ifg7N0,3966
@@ -41,6 +41,9 @@ ominfra/manage/commands/execution.py,sha256=FBkc9tA_QeKfeajijhsgIiIbqwE9LVwI63Qo
41
41
  ominfra/manage/commands/inject.py,sha256=00QL4Xui5oHXbUG6F8QvJXeIdh2YKThKzqsusZUmfN4,3439
42
42
  ominfra/manage/commands/marshal.py,sha256=4DSCMPzRiRhufIB_9DPL6LrZkRZOle5ruOWU4MVlcXM,694
43
43
  ominfra/manage/commands/subprocess.py,sha256=3JaOt56uPqW3jYRtpBpHk5zm3ZzOXzCK-feyDBkq8P4,2198
44
+ ominfra/manage/deploy/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
+ ominfra/manage/deploy/command.py,sha256=mTBjerB7lIBdPrivgyWkoAYDY76cfHexjEFYTzanURY,493
46
+ ominfra/manage/deploy/inject.py,sha256=j5LYK5y_nZgdaNLde8sV2w_---GvmibgO_ZBT8qzeFM,499
44
47
  ominfra/manage/remote/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
45
48
  ominfra/manage/remote/channel.py,sha256=l3bsuE6JZ3VD5abxsWys7m-4kFjOr_B-27bEMgz4K4Q,1325
46
49
  ominfra/manage/remote/config.py,sha256=yMJsz8zB5i3ytiS-YaCb6-qXumMKXh18SjmtzPVO44c,280
@@ -50,7 +53,7 @@ ominfra/manage/remote/payload.py,sha256=Rn-Yo26POpHEOOfUHX3jWkqcQVEAvkJ_5Bu13jwo
50
53
  ominfra/manage/remote/spawning.py,sha256=6JLs_IsMjNQr6i8vROUjHsqmNFno1Ykh3oBXOOHBFYY,2614
51
54
  ominfra/scripts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
52
55
  ominfra/scripts/journald2aws.py,sha256=s_ratu1H5K76uM0sx0gMX1Y8pSDO29YqW6x5UrV8jTI,135495
53
- ominfra/scripts/manage.py,sha256=MBbHy36U41eF0MXaPQhk4xAu7ErhB29XqHUd3TiCujo,91910
56
+ ominfra/scripts/manage.py,sha256=sljVPfvf1pvzJU-NZVxKqikMYc-uFbvkeARE3GB5PWY,92967
54
57
  ominfra/scripts/supervisor.py,sha256=OTBihWooI6yRzY-kw20vMBqZmrKMKfZkVUcwd_xZ7ZM,249541
55
58
  ominfra/supervisor/LICENSE.txt,sha256=yvqaMNsDhWxziHa9ien6qCW1SkZv-DQlAg96XjfSee8,1746
56
59
  ominfra/supervisor/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
@@ -93,9 +96,9 @@ ominfra/tailscale/api.py,sha256=C5-t_b6jZXUWcy5k8bXm7CFnk73pSdrlMOgGDeGVrpw,1370
93
96
  ominfra/tailscale/cli.py,sha256=DSGp4hn5xwOW-l_u_InKlSF6kIobxtUtVssf_73STs0,3567
94
97
  ominfra/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
95
98
  ominfra/tools/listresources.py,sha256=4qVg5txsb10EHhvqXXeM6gJ2jx9LbroEnPydDv1uXs0,6176
96
- ominfra-0.0.0.dev143.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
97
- ominfra-0.0.0.dev143.dist-info/METADATA,sha256=vVDKCPEuzI6_WxcN4JdrbYNDZNNwxJqKReQWW8Z868A,731
98
- ominfra-0.0.0.dev143.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
99
- ominfra-0.0.0.dev143.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
100
- ominfra-0.0.0.dev143.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
101
- ominfra-0.0.0.dev143.dist-info/RECORD,,
99
+ ominfra-0.0.0.dev144.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
100
+ ominfra-0.0.0.dev144.dist-info/METADATA,sha256=svnd2N9jZtxI9FCLy1qVR8vuz4lD7GbuXvHq1nnC2Ko,731
101
+ ominfra-0.0.0.dev144.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
102
+ ominfra-0.0.0.dev144.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
103
+ ominfra-0.0.0.dev144.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
104
+ ominfra-0.0.0.dev144.dist-info/RECORD,,