ominfra 0.0.0.dev135__py3-none-any.whl → 0.0.0.dev136__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.
@@ -87,10 +87,10 @@ Basically this: https://mitogen.networkgenomics.com/howitworks.html
87
87
  ##
88
88
 
89
89
 
90
- _PYREMOTE_BOOTSTRAP_COMM_FD = 100
90
+ _PYREMOTE_BOOTSTRAP_INPUT_FD = 100
91
91
  _PYREMOTE_BOOTSTRAP_SRC_FD = 101
92
92
 
93
- _PYREMOTE_BOOTSTRAP_CHILD_PID_VAR = '_OPYR_CPID'
93
+ _PYREMOTE_BOOTSTRAP_CHILD_PID_VAR = '_OPYR_CHILD_PID'
94
94
  _PYREMOTE_BOOTSTRAP_ARGV0_VAR = '_OPYR_ARGV0'
95
95
 
96
96
  _PYREMOTE_BOOTSTRAP_ACK0 = b'OPYR000\n'
@@ -121,7 +121,7 @@ def _pyremote_bootstrap_main(context_name: str) -> None:
121
121
  # Parent process
122
122
 
123
123
  # Dup original stdin to comm_fd for use as comm channel
124
- os.dup2(0, _PYREMOTE_BOOTSTRAP_COMM_FD)
124
+ os.dup2(0, _PYREMOTE_BOOTSTRAP_INPUT_FD)
125
125
 
126
126
  # Overwrite stdin (fed to python repl) with first copy of src
127
127
  os.dup2(r0, 0)
@@ -179,7 +179,7 @@ def pyremote_build_bootstrap_cmd(context_name: str) -> str:
179
179
  bs_src = textwrap.dedent(inspect.getsource(_pyremote_bootstrap_main))
180
180
 
181
181
  for gl in [
182
- '_PYREMOTE_BOOTSTRAP_COMM_FD',
182
+ '_PYREMOTE_BOOTSTRAP_INPUT_FD',
183
183
  '_PYREMOTE_BOOTSTRAP_SRC_FD',
184
184
 
185
185
  '_PYREMOTE_BOOTSTRAP_CHILD_PID_VAR',
@@ -424,6 +424,7 @@ class PyremoteBootstrapDriver:
424
424
  @dc.dataclass(frozen=True)
425
425
  class PyremotePayloadRuntime:
426
426
  input: ta.BinaryIO
427
+ output: ta.BinaryIO
427
428
  main_src: str
428
429
  env_info: PyremoteEnvInfo
429
430
 
@@ -450,12 +451,19 @@ def pyremote_bootstrap_finalize() -> PyremotePayloadRuntime:
450
451
  os.write(1, struct.pack('<I', len(env_info_json)))
451
452
  os.write(1, env_info_json.encode('utf-8'))
452
453
 
454
+ # Setup IO
455
+ input = os.fdopen(_PYREMOTE_BOOTSTRAP_INPUT_FD, 'rb', 0) # noqa
456
+ output = os.fdopen(os.dup(1), 'wb', 0) # noqa
457
+ os.dup2(nfd := os.open('/dev/null', os.O_WRONLY), 1)
458
+ os.close(nfd)
459
+
453
460
  # Write fourth ack
454
- os.write(1, _PYREMOTE_BOOTSTRAP_ACK3)
461
+ output.write(_PYREMOTE_BOOTSTRAP_ACK3)
455
462
 
456
463
  # Return
457
464
  return PyremotePayloadRuntime(
458
- input=os.fdopen(_PYREMOTE_BOOTSTRAP_COMM_FD, 'rb', 0),
465
+ input=input,
466
+ output=output,
459
467
  main_src=main_src,
460
468
  env_info=env_info,
461
469
  )
@@ -1536,7 +1544,7 @@ def _remote_main() -> None:
1536
1544
 
1537
1545
  o = SubprocessCommand()._execute(i) # noqa
1538
1546
 
1539
- _send_obj(sys.stdout.buffer, o)
1547
+ _send_obj(rt.output, o)
1540
1548
 
1541
1549
 
1542
1550
  def _main() -> None:
@@ -1544,7 +1552,8 @@ def _main() -> None:
1544
1552
 
1545
1553
  parser = argparse.ArgumentParser()
1546
1554
 
1547
- parser.add_argument('--ssh')
1555
+ parser.add_argument('-s', '--shell')
1556
+ parser.add_argument('-q', '--shell-quote', action='store_true')
1548
1557
  parser.add_argument('--python', default='python3')
1549
1558
  parser.add_argument('--_amalg-file')
1550
1559
 
@@ -1582,9 +1591,11 @@ def _main() -> None:
1582
1591
 
1583
1592
  bs_src = pyremote_build_bootstrap_cmd(__package__ or 'manage')
1584
1593
 
1585
- if args.ssh is not None:
1586
- sh_src = ' '.join([args.python, '-c', shlex.quote(bs_src)])
1587
- sh_cmd = f'{args.ssh} {shlex.quote(sh_src)}'
1594
+ if args.shell is not None:
1595
+ sh_src = f'{args.python} -c {shlex.quote(bs_src)}'
1596
+ if args.shell_quote:
1597
+ sh_src = shlex.quote(sh_src)
1598
+ sh_cmd = f'{args.shell} {sh_src}'
1588
1599
  cmd = [sh_cmd]
1589
1600
  shell = True
1590
1601
  else:
@@ -60,7 +60,7 @@ def _remote_main() -> None:
60
60
 
61
61
  o = SubprocessCommand()._execute(i) # noqa
62
62
 
63
- _send_obj(sys.stdout.buffer, o)
63
+ _send_obj(rt.output, o)
64
64
 
65
65
 
66
66
  def _main() -> None:
@@ -68,7 +68,8 @@ def _main() -> None:
68
68
 
69
69
  parser = argparse.ArgumentParser()
70
70
 
71
- parser.add_argument('--ssh')
71
+ parser.add_argument('-s', '--shell')
72
+ parser.add_argument('-q', '--shell-quote', action='store_true')
72
73
  parser.add_argument('--python', default='python3')
73
74
  parser.add_argument('--_amalg-file')
74
75
 
@@ -106,9 +107,11 @@ def _main() -> None:
106
107
 
107
108
  bs_src = pyremote_build_bootstrap_cmd(__package__ or 'manage')
108
109
 
109
- if args.ssh is not None:
110
- sh_src = ' '.join([args.python, '-c', shlex.quote(bs_src)])
111
- sh_cmd = f'{args.ssh} {shlex.quote(sh_src)}'
110
+ if args.shell is not None:
111
+ sh_src = f'{args.python} -c {shlex.quote(bs_src)}'
112
+ if args.shell_quote:
113
+ sh_src = shlex.quote(sh_src)
114
+ sh_cmd = f'{args.shell} {sh_src}'
112
115
  cmd = [sh_cmd]
113
116
  shell = True
114
117
  else:
ominfra/pyremote.py CHANGED
@@ -21,10 +21,10 @@ import zlib
21
21
  ##
22
22
 
23
23
 
24
- _PYREMOTE_BOOTSTRAP_COMM_FD = 100
24
+ _PYREMOTE_BOOTSTRAP_INPUT_FD = 100
25
25
  _PYREMOTE_BOOTSTRAP_SRC_FD = 101
26
26
 
27
- _PYREMOTE_BOOTSTRAP_CHILD_PID_VAR = '_OPYR_CPID'
27
+ _PYREMOTE_BOOTSTRAP_CHILD_PID_VAR = '_OPYR_CHILD_PID'
28
28
  _PYREMOTE_BOOTSTRAP_ARGV0_VAR = '_OPYR_ARGV0'
29
29
 
30
30
  _PYREMOTE_BOOTSTRAP_ACK0 = b'OPYR000\n'
@@ -55,7 +55,7 @@ def _pyremote_bootstrap_main(context_name: str) -> None:
55
55
  # Parent process
56
56
 
57
57
  # Dup original stdin to comm_fd for use as comm channel
58
- os.dup2(0, _PYREMOTE_BOOTSTRAP_COMM_FD)
58
+ os.dup2(0, _PYREMOTE_BOOTSTRAP_INPUT_FD)
59
59
 
60
60
  # Overwrite stdin (fed to python repl) with first copy of src
61
61
  os.dup2(r0, 0)
@@ -113,7 +113,7 @@ def pyremote_build_bootstrap_cmd(context_name: str) -> str:
113
113
  bs_src = textwrap.dedent(inspect.getsource(_pyremote_bootstrap_main))
114
114
 
115
115
  for gl in [
116
- '_PYREMOTE_BOOTSTRAP_COMM_FD',
116
+ '_PYREMOTE_BOOTSTRAP_INPUT_FD',
117
117
  '_PYREMOTE_BOOTSTRAP_SRC_FD',
118
118
 
119
119
  '_PYREMOTE_BOOTSTRAP_CHILD_PID_VAR',
@@ -358,6 +358,7 @@ class PyremoteBootstrapDriver:
358
358
  @dc.dataclass(frozen=True)
359
359
  class PyremotePayloadRuntime:
360
360
  input: ta.BinaryIO
361
+ output: ta.BinaryIO
361
362
  main_src: str
362
363
  env_info: PyremoteEnvInfo
363
364
 
@@ -384,12 +385,19 @@ def pyremote_bootstrap_finalize() -> PyremotePayloadRuntime:
384
385
  os.write(1, struct.pack('<I', len(env_info_json)))
385
386
  os.write(1, env_info_json.encode('utf-8'))
386
387
 
388
+ # Setup IO
389
+ input = os.fdopen(_PYREMOTE_BOOTSTRAP_INPUT_FD, 'rb', 0) # noqa
390
+ output = os.fdopen(os.dup(1), 'wb', 0) # noqa
391
+ os.dup2(nfd := os.open('/dev/null', os.O_WRONLY), 1)
392
+ os.close(nfd)
393
+
387
394
  # Write fourth ack
388
- os.write(1, _PYREMOTE_BOOTSTRAP_ACK3)
395
+ output.write(_PYREMOTE_BOOTSTRAP_ACK3)
389
396
 
390
397
  # Return
391
398
  return PyremotePayloadRuntime(
392
- input=os.fdopen(_PYREMOTE_BOOTSTRAP_COMM_FD, 'rb', 0),
399
+ input=input,
400
+ output=output,
393
401
  main_src=main_src,
394
402
  env_info=env_info,
395
403
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ominfra
3
- Version: 0.0.0.dev135
3
+ Version: 0.0.0.dev136
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.dev135
16
- Requires-Dist: omlish==0.0.0.dev135
15
+ Requires-Dist: omdev==0.0.0.dev136
16
+ Requires-Dist: omlish==0.0.0.dev136
17
17
  Provides-Extra: all
18
18
  Requires-Dist: paramiko~=3.5; extra == "all"
19
19
  Requires-Dist: asyncssh~=2.18; extra == "all"
@@ -3,7 +3,7 @@ ominfra/__about__.py,sha256=6i1AoruFYQCd-PyhhbDQDWY2d1tiQu9nkwWr-fXAqfY,705
3
3
  ominfra/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
4
  ominfra/cmds.py,sha256=E0AfnvEmnKntXWvmLW5L05_NeDpBET1VBXn7vV6EwBQ,2083
5
5
  ominfra/configs.py,sha256=8aU1Qmbr-qjaE2iP3gAbA2SWJYMPZ-uGK007L01PoOI,1727
6
- ominfra/pyremote.py,sha256=z3D9nj26omHgl3_q_h7uSHRtgYu-Sb06fMQCqS69_QI,10289
6
+ ominfra/pyremote.py,sha256=djh4WzAUqqBoVfXij5ylYHtEh0bo5jxPWicnkg16q1s,10514
7
7
  ominfra/ssh.py,sha256=jQpc4WvkMckIfk4vILda8zFaeharRqc_6wxW50b0OjQ,5431
8
8
  ominfra/threadworkers.py,sha256=oX4ubZn7h932saXpRIJu2MNhBExgGGMuGhdXarZxLJw,4948
9
9
  ominfra/clouds/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -57,8 +57,8 @@ ominfra/manage/deploy/poly/site.py,sha256=QJwDDJoVm2-kxi4bxIrp-mn4y2qDLuW3CAUax3
57
57
  ominfra/manage/deploy/poly/supervisor.py,sha256=zkl6VQBcAZaMAhyR9DbbbqULcgFCDZoe9S_vP-mMFQ8,2289
58
58
  ominfra/manage/deploy/poly/venv.py,sha256=BoipDEa4NTeodjf3L57KJfq9eGKLagFNKwD8pS4yrzA,1552
59
59
  ominfra/manage/new/__init__.py,sha256=Y3l4WY4JRi2uLG6kgbGp93fuGfkxkKwZDvhsa0Rwgtk,15
60
- ominfra/manage/new/_manage.py,sha256=ycfNgyFofYs6f5jYV2SrAprGChQd-uVhWc79Tvd9iB0,40217
61
- ominfra/manage/new/main.py,sha256=WeiBAM7HQosnDbKahRmDWNvNYUZaKH2d3ooaqk9kQ04,3558
60
+ ominfra/manage/new/_manage.py,sha256=AA2XtuvrCUmy2lLlU6IvhNqPPPcD7kgDi2ccHJZHX3Y,40562
61
+ ominfra/manage/new/main.py,sha256=Qfsr0PyRq8Tqm2_IiPTHgCsNALeLwXSR2af8PGc8WZE,3678
62
62
  ominfra/manage/new/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
63
63
  ominfra/manage/new/commands/base.py,sha256=TTrHL213jf-ClVqToiNHuxQey1Yf6052E8u3E9hAf7Q,574
64
64
  ominfra/manage/new/commands/subprocess.py,sha256=GpbD-cTorgCRg203lCl81HAh-NBYA6ObKa5ZP2ss9rg,1884
@@ -106,9 +106,9 @@ ominfra/tailscale/api.py,sha256=C5-t_b6jZXUWcy5k8bXm7CFnk73pSdrlMOgGDeGVrpw,1370
106
106
  ominfra/tailscale/cli.py,sha256=DSGp4hn5xwOW-l_u_InKlSF6kIobxtUtVssf_73STs0,3567
107
107
  ominfra/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
108
108
  ominfra/tools/listresources.py,sha256=4qVg5txsb10EHhvqXXeM6gJ2jx9LbroEnPydDv1uXs0,6176
109
- ominfra-0.0.0.dev135.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
110
- ominfra-0.0.0.dev135.dist-info/METADATA,sha256=l8zW4aJP_w8h0b-wfdGnlXqPlofGjiw0HLQAfdFfJK4,731
111
- ominfra-0.0.0.dev135.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
112
- ominfra-0.0.0.dev135.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
113
- ominfra-0.0.0.dev135.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
114
- ominfra-0.0.0.dev135.dist-info/RECORD,,
109
+ ominfra-0.0.0.dev136.dist-info/LICENSE,sha256=B_hVtavaA8zCYDW99DYdcpDLKz1n3BBRjZrcbv8uG8c,1451
110
+ ominfra-0.0.0.dev136.dist-info/METADATA,sha256=A0w90koztPfCNzby7_wgr6Xog2aIZDmoSLiHtJP2V0A,731
111
+ ominfra-0.0.0.dev136.dist-info/WHEEL,sha256=PZUExdf71Ui_so67QXpySuHtCi3-J3wvF4ORK6k_S8U,91
112
+ ominfra-0.0.0.dev136.dist-info/entry_points.txt,sha256=kgecQ2MgGrM9qK744BoKS3tMesaC3yjLnl9pa5CRczg,37
113
+ ominfra-0.0.0.dev136.dist-info/top_level.txt,sha256=E-b2OHkk_AOBLXHYZQ2EOFKl-_6uOGd8EjeG-Zy6h_w,8
114
+ ominfra-0.0.0.dev136.dist-info/RECORD,,