hostctl 0.2.0__tar.gz → 0.2.2__tar.gz
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.
- {hostctl-0.2.0 → hostctl-0.2.2}/CHANGELOG.md +86 -1
- {hostctl-0.2.0 → hostctl-0.2.2}/PKG-INFO +4 -3
- {hostctl-0.2.0 → hostctl-0.2.2}/docs/api/reference.md +1 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/pyproject.toml +13 -5
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/__init__.py +2 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/executor/_common.py +33 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/executor/container.py +3 -4
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/executor/local.py +2 -15
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/executor/psrp.py +5 -2
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/executor/qemu.py +6 -8
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/executor/ssh.py +2 -1
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/executor/winrm.py +2 -1
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/host/__init__.py +1 -0
- hostctl-0.2.2/src/hostctl/host/_connection.py +384 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/host/container.py +1 -7
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/host/system.py +1 -1
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/shell/_common.py +13 -3
- hostctl-0.2.2/tests/test_connection_string.py +267 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_exec_command.py +47 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/.gitignore +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/LICENSE +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/README.md +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/docs/changelog.md +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/docs/guide/cli.md +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/docs/guide/contracts.md +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/docs/guide/extending.md +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/docs/guide/path.md +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/docs/guide/providers.md +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/docs/guide/run.md +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/docs/guide/transfer.md +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/docs/index.md +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/examples/application_provider.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/examples/copy_between_hosts.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/examples/local_run.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/examples/remote_run.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/mkdocs.yml +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/AGENTS.md +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/__main__.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/_async.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/_cli.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/executor/__init__.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/executor/_qga.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/executor/serial.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/host/_common.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/host/_local.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/host/_ssh.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/host/_winrm.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/host/composite_path.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/host/container_path.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/host/qemu.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/host/serial.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/process/__init__.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/process/_common.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/process/container.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/process/psrp.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/process/qemu_serial.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/process/serial.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/process/ssh.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/provider/__init__.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/provider/_common.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/provider/transports.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/py.typed +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/serial/__init__.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/shell/__init__.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/shell/cmd.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/shell/fish.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/shell/posix.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/shell/powershell.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/src/hostctl/sync.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/conformance/__init__.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/conformance/path_fakes.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/conformance/providers.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/conformance/test_composite_path_routing.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/conformance/test_live.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/conformance/test_path_contract.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/conformance/test_process_contract.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/conformance/test_run_contract.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/conformance/test_sync_contract.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_application_provider.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_asyncssh_errors.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_cli.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_composite_path_propagation.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_container_path.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_container_process.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_host_api.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_host_container.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_host_local.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_host_module_layout.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_host_qemu.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_host_remote.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_host_winrm.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_observability.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_process.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_provider_fault_injection.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_psrp.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_qemu_executor.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_qemu_path.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_qemu_serial.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_qemu_serial_process.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_qga_ssh_transport.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_qga_transport.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_serial_executor.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_serial_host.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_serial_live.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_shell.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_ssh_process.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_sync_helpers.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_system_host_fidelity.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_system_hosts.py +0 -0
- {hostctl-0.2.0 → hostctl-0.2.2}/tests/test_winrm_path.py +0 -0
|
@@ -7,6 +7,89 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.2] - 2026-07-29
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- Dependency ranges widened to admit `pathlib_next` 0.9 and `netimps` 0.2:
|
|
15
|
+
`pathlib_next>=0.8.6,<0.10` and `netimps>=0.1,<0.3`, with the `ssh` extra's
|
|
16
|
+
`pathlib_next[sftp-async]` bound moved to `<0.10` alongside it. The
|
|
17
|
+
previous `netimps<0.2` also conflicted with `pathlib_next` 0.9's own `uri`
|
|
18
|
+
extra, which requires `netimps>=0.2.0`.
|
|
19
|
+
|
|
20
|
+
The floors stay where they were rather than rising to the new minors:
|
|
21
|
+
hostctl uses no API added in either release — its three netimps functions
|
|
22
|
+
(`get_default_port`, `is_local_address`, `try_parse`) all exist in 0.1, and
|
|
23
|
+
`ProgressReader` is hostctl's own wrapper, unrelated to pathlib_next 0.9's
|
|
24
|
+
native `copy(progress=)`. A floor demanding versions the code does not need
|
|
25
|
+
would exclude working installs for nothing. The ceilings span two minors
|
|
26
|
+
because both projects are pre-1.0, where a minor may break.
|
|
27
|
+
|
|
28
|
+
Verified against both ends of the range: the suite passes with
|
|
29
|
+
`pathlib_next` 0.8.6 and 0.9.0, each alongside `netimps` 0.2.0.
|
|
30
|
+
|
|
31
|
+
## [0.2.1] - 2026-07-29
|
|
32
|
+
|
|
33
|
+
### Added
|
|
34
|
+
|
|
35
|
+
- `ConnectionString` parses a connection target from whatever a user typed.
|
|
36
|
+
`ConnectionString("nas", scheme="wss")` and `ConnectionString("nas:8443",
|
|
37
|
+
...)` parse, because a bare host is not an invalid URI — it is a URI with
|
|
38
|
+
the scheme left off, which is what people type on a command line.
|
|
39
|
+
|
|
40
|
+
Every field can be supplied directly, and three layers decide each one: an
|
|
41
|
+
explicit argument wins, then whatever the string carried, then `defaults`.
|
|
42
|
+
`scheme=`/`port=`/`host=`/… are therefore *overrides* — `scheme="ssh"`
|
|
43
|
+
beats a `wss://` in the string — while `defaults` (a mapping, or another
|
|
44
|
+
`ConnectionString` used as a profile) fills only what nothing else
|
|
45
|
+
supplied.
|
|
46
|
+
|
|
47
|
+
A port carries its own resolution strategy wherever one is accepted: an
|
|
48
|
+
`int`, a callable `scheme -> port | None`, or anything indexable by scheme
|
|
49
|
+
(a plain mapping), so a caller passes its whole table without pre-selecting
|
|
50
|
+
an entry. When no layer supplies one, `netimps.get_default_port` resolves
|
|
51
|
+
the scheme — it knows schemes no system services database does (`ws`/`wss`,
|
|
52
|
+
`socks5`), and an application can register more with
|
|
53
|
+
`netimps.register_port`.
|
|
54
|
+
|
|
55
|
+
`False` stops the search outright: no port, and no lookup.
|
|
56
|
+
|
|
57
|
+
Credentials are parsed but never rendered. `str()` and `repr()` both emit
|
|
58
|
+
the redacted form, with the password **removed rather than masked**, so the
|
|
59
|
+
output stays a valid, reusable connection string that cannot round-trip a
|
|
60
|
+
wrong credential — and a value reaching a log line or a traceback frame
|
|
61
|
+
cannot leak one. A password may carry `key:value` extras after a newline,
|
|
62
|
+
as `parse_credentials` describes, written raw.
|
|
63
|
+
|
|
64
|
+
The host keeps the spelling it was given. `is_local` resolves nothing — it
|
|
65
|
+
is called while a configuration is built, which is network-free, and
|
|
66
|
+
resolving would both block and raise on a name that does not resolve. An
|
|
67
|
+
address literal is answered by `netimps.is_local_address`, so an address
|
|
68
|
+
actually assigned to this machine counts as local and not just loopback,
|
|
69
|
+
while a name is compared against the loopback spellings. `qsl` and
|
|
70
|
+
`query_val()` read the query; `replace()` returns a changed copy.
|
|
71
|
+
|
|
72
|
+
### Changed
|
|
73
|
+
|
|
74
|
+
- **`netimps` is now a required dependency**, supplying scheme/port and
|
|
75
|
+
address semantics rather than hostctl reimplementing them. Note this
|
|
76
|
+
arrives in a patch release: an existing install pinned within `0.2.x` gains
|
|
77
|
+
a new requirement, so a locked or offline environment needs `netimps`
|
|
78
|
+
available before upgrading.
|
|
79
|
+
|
|
80
|
+
### Fixed
|
|
81
|
+
|
|
82
|
+
- A path in a command is rendered through `__fspath__` rather than `str()`.
|
|
83
|
+
Every transport now shares one `command_text` helper — the SSH, WinRM,
|
|
84
|
+
container, QGA, and PSRP executors each stringified with `str()`, so only
|
|
85
|
+
the local executor asked for the filesystem representation. `__fspath__` is
|
|
86
|
+
tried by attribute rather than by `isinstance(value, os.PathLike)`, so a
|
|
87
|
+
duck-typed path that never registered with the ABC is honoured too, and an
|
|
88
|
+
object whose `__fspath__` raises or returns a non-string falls back to
|
|
89
|
+
`str()` rather than failing the command. The shell layer follows the same
|
|
90
|
+
rule. No shipped path type changes behaviour — `str()` and `__fspath__`
|
|
91
|
+
agree for all of them — but the contract now matches what a path promises.
|
|
92
|
+
|
|
10
93
|
## [0.2.0] - 2026-07-28
|
|
11
94
|
|
|
12
95
|
### Added
|
|
@@ -230,7 +313,9 @@ test suite on Python 3.9 through 3.14.
|
|
|
230
313
|
assigned to it; a config-less host now builds its own family configuration
|
|
231
314
|
instead.
|
|
232
315
|
|
|
233
|
-
[Unreleased]: https://github.com/jose-pr/hostctl/compare/v0.2.
|
|
316
|
+
[Unreleased]: https://github.com/jose-pr/hostctl/compare/v0.2.2...HEAD
|
|
317
|
+
[0.2.2]: https://github.com/jose-pr/hostctl/compare/v0.2.1...v0.2.2
|
|
318
|
+
[0.2.1]: https://github.com/jose-pr/hostctl/compare/v0.2.0...v0.2.1
|
|
234
319
|
[0.2.0]: https://github.com/jose-pr/hostctl/compare/v0.1.2...v0.2.0
|
|
235
320
|
[0.1.2]: https://github.com/jose-pr/hostctl/compare/v0.1.0...v0.1.2
|
|
236
321
|
[0.1.0]: https://github.com/jose-pr/hostctl/releases/tag/v0.1.0
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hostctl
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Run commands and access files on a host, local or remote, protocol-agnostic
|
|
5
5
|
Project-URL: Homepage, https://github.com/jose-pr/hostctl/
|
|
6
6
|
Project-URL: Documentation, https://jose-pr.github.io/hostctl/
|
|
@@ -24,7 +24,8 @@ Classifier: Topic :: System :: Filesystems
|
|
|
24
24
|
Classifier: Topic :: System :: Systems Administration
|
|
25
25
|
Classifier: Typing :: Typed
|
|
26
26
|
Requires-Python: >=3.9
|
|
27
|
-
Requires-Dist:
|
|
27
|
+
Requires-Dist: netimps<0.3,>=0.1
|
|
28
|
+
Requires-Dist: pathlib-next<0.10,>=0.8.6
|
|
28
29
|
Provides-Extra: container
|
|
29
30
|
Requires-Dist: docker<8,>=7.1; extra == 'container'
|
|
30
31
|
Provides-Extra: dev
|
|
@@ -43,7 +44,7 @@ Provides-Extra: serial
|
|
|
43
44
|
Requires-Dist: pyserial<4,>=3.5; extra == 'serial'
|
|
44
45
|
Provides-Extra: ssh
|
|
45
46
|
Requires-Dist: asyncssh; extra == 'ssh'
|
|
46
|
-
Requires-Dist: pathlib-next[sftp-async]<0.
|
|
47
|
+
Requires-Dist: pathlib-next[sftp-async]<0.10,>=0.8.4; extra == 'ssh'
|
|
47
48
|
Provides-Extra: winrm
|
|
48
49
|
Requires-Dist: pywinrm<0.6,>=0.5.0; extra == 'winrm'
|
|
49
50
|
Provides-Extra: winrm-credssp
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "hostctl"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.2"
|
|
8
8
|
authors = [{ name = "Jose A." }]
|
|
9
9
|
description = "Run commands and access files on a host, local or remote, protocol-agnostic"
|
|
10
10
|
readme = "README.md"
|
|
@@ -28,14 +28,22 @@ classifiers = [
|
|
|
28
28
|
"Topic :: System :: Filesystems",
|
|
29
29
|
"Typing :: Typed",
|
|
30
30
|
]
|
|
31
|
-
# pathlib_next supplies the common local/remote path return type.
|
|
32
|
-
#
|
|
33
|
-
|
|
31
|
+
# pathlib_next supplies the common local/remote path return type. netimps
|
|
32
|
+
# supplies scheme/port and address semantics -- including schemes no system
|
|
33
|
+
# services database knows (ws/wss, socks5) -- so hostctl does not reimplement
|
|
34
|
+
# them. Transport implementations remain extras, so importing hostctl never
|
|
35
|
+
# requires them.
|
|
36
|
+
#
|
|
37
|
+
# Both ranges span two minors deliberately: hostctl uses no API added in
|
|
38
|
+
# pathlib_next 0.9 or netimps 0.2, so raising the floor would exclude working
|
|
39
|
+
# installs for nothing. The ceilings stay at the next major-ish boundary
|
|
40
|
+
# because both projects are pre-1.0, where a minor may break.
|
|
41
|
+
dependencies = ["pathlib_next>=0.8.6,<0.10", "netimps>=0.1,<0.3"]
|
|
34
42
|
|
|
35
43
|
[project.optional-dependencies]
|
|
36
44
|
# SSH-backed run()/path(): asyncssh for shell exec, pathlib_next's SftpPath
|
|
37
45
|
# (asyncssh-only since 0.8.2) for the remote path backend.
|
|
38
|
-
ssh = ["asyncssh", "pathlib_next[sftp-async]>=0.8.4,<0.
|
|
46
|
+
ssh = ["asyncssh", "pathlib_next[sftp-async]>=0.8.4,<0.10"]
|
|
39
47
|
# Windows Remote Management command execution.
|
|
40
48
|
winrm = ["pywinrm>=0.5.0,<0.6"]
|
|
41
49
|
# PowerShell Remoting Protocol runspaces (Python 3.10+ only). The marker
|
|
@@ -33,6 +33,7 @@ from .executor import (
|
|
|
33
33
|
)
|
|
34
34
|
from .host import (
|
|
35
35
|
ContainerConfig as ContainerConfig,
|
|
36
|
+
ConnectionString as ConnectionString,
|
|
36
37
|
ContainerHost as ContainerHost,
|
|
37
38
|
Exec as Exec,
|
|
38
39
|
Host as Host,
|
|
@@ -126,6 +127,7 @@ __all__ = [
|
|
|
126
127
|
"ssh_providers",
|
|
127
128
|
"strict_uri_credentials",
|
|
128
129
|
"strict_uri_query",
|
|
130
|
+
"ConnectionString",
|
|
129
131
|
"uri_host",
|
|
130
132
|
"uri_hostname",
|
|
131
133
|
"winrm_providers",
|
|
@@ -94,6 +94,39 @@ def normalize_input(
|
|
|
94
94
|
return input
|
|
95
95
|
|
|
96
96
|
|
|
97
|
+
def command_text(
|
|
98
|
+
value: object, *, encoding: str = "utf-8", errors: str = "strict"
|
|
99
|
+
) -> str:
|
|
100
|
+
"""Render one command or argv value as the text a transport sends.
|
|
101
|
+
|
|
102
|
+
Anything offering `__fspath__` is asked for it first: that is the
|
|
103
|
+
filesystem representation a path promises, and it is what a transport
|
|
104
|
+
needs. `str()` happens to match for the path types shipped here, but that
|
|
105
|
+
is a coincidence of their `__str__` rather than a contract -- a path type
|
|
106
|
+
whose `repr`-ish `__str__` differs would otherwise send the wrong text.
|
|
107
|
+
|
|
108
|
+
`__fspath__` is tried directly rather than through
|
|
109
|
+
`isinstance(value, os.PathLike)`, so a duck-typed path that never
|
|
110
|
+
registered with the ABC is still honoured. A object whose `__fspath__`
|
|
111
|
+
raises or returns a non-string falls back to `str()` rather than failing
|
|
112
|
+
the command.
|
|
113
|
+
|
|
114
|
+
Bytes -- returned by `__fspath__` or passed directly -- are decoded;
|
|
115
|
+
everything else is stringified.
|
|
116
|
+
"""
|
|
117
|
+
fspath = getattr(value, "__fspath__", None)
|
|
118
|
+
if callable(fspath):
|
|
119
|
+
try:
|
|
120
|
+
resolved = fspath()
|
|
121
|
+
except Exception:
|
|
122
|
+
resolved = None
|
|
123
|
+
if isinstance(resolved, (str, bytes)):
|
|
124
|
+
value = resolved
|
|
125
|
+
if isinstance(value, bytes):
|
|
126
|
+
return value.decode(encoding, errors)
|
|
127
|
+
return str(value)
|
|
128
|
+
|
|
129
|
+
|
|
97
130
|
def normalize_environment(
|
|
98
131
|
env: typing.Optional[Environment],
|
|
99
132
|
) -> typing.Optional[typing.Dict[str, str]]:
|
|
@@ -7,6 +7,7 @@ import typing
|
|
|
7
7
|
|
|
8
8
|
from ._common import (
|
|
9
9
|
CaptureOutput,
|
|
10
|
+
command_text,
|
|
10
11
|
CommandArgument,
|
|
11
12
|
Environment,
|
|
12
13
|
Executor,
|
|
@@ -79,10 +80,8 @@ class ContainerExecutor(Executor[subprocess.CompletedProcess]):
|
|
|
79
80
|
)
|
|
80
81
|
|
|
81
82
|
stdout, stderr = capture_streams(capture_output, stdout, stderr)
|
|
82
|
-
argv = [
|
|
83
|
-
argv.extend(
|
|
84
|
-
value.decode() if isinstance(value, bytes) else str(value) for value in args
|
|
85
|
-
)
|
|
83
|
+
argv = [command_text(command)]
|
|
84
|
+
argv.extend(command_text(value) for value in args)
|
|
86
85
|
merge_stderr = stderr is subprocess.STDOUT
|
|
87
86
|
exec_options: typing.Dict[str, object] = {
|
|
88
87
|
"stdout": True,
|
|
@@ -8,6 +8,7 @@ import typing
|
|
|
8
8
|
|
|
9
9
|
from ._common import (
|
|
10
10
|
CaptureOutput,
|
|
11
|
+
command_text,
|
|
11
12
|
CommandArgument,
|
|
12
13
|
Environment,
|
|
13
14
|
Executor,
|
|
@@ -52,21 +53,7 @@ class LocalExecutor(Executor[subprocess.CompletedProcess]):
|
|
|
52
53
|
raise TypeError(f"unsupported local executor option: {sorted(options)[0]}")
|
|
53
54
|
reject_stdin_conflict(input, stdin)
|
|
54
55
|
stdout, stderr = capture_streams(capture_output, stdout, stderr)
|
|
55
|
-
argv = [
|
|
56
|
-
os.fspath(command),
|
|
57
|
-
*[
|
|
58
|
-
(
|
|
59
|
-
value.decode()
|
|
60
|
-
if isinstance(value, bytes)
|
|
61
|
-
else (
|
|
62
|
-
os.fspath(value)
|
|
63
|
-
if isinstance(value, os.PathLike)
|
|
64
|
-
else str(value)
|
|
65
|
-
)
|
|
66
|
-
)
|
|
67
|
-
for value in args
|
|
68
|
-
],
|
|
69
|
-
]
|
|
56
|
+
argv = [command_text(command), *(command_text(value) for value in args)]
|
|
70
57
|
return subprocess.run(
|
|
71
58
|
argv,
|
|
72
59
|
bufsize=bufsize,
|
|
@@ -9,6 +9,7 @@ import types
|
|
|
9
9
|
|
|
10
10
|
from ._common import (
|
|
11
11
|
CaptureOutput,
|
|
12
|
+
command_text,
|
|
12
13
|
CommandArgument,
|
|
13
14
|
Executor,
|
|
14
15
|
ExecutorCapability,
|
|
@@ -92,7 +93,9 @@ class PsrpExecutor(Executor[subprocess.CompletedProcess]):
|
|
|
92
93
|
"PSRP pipeline timeout is unsupported; configure WinRM timeouts"
|
|
93
94
|
)
|
|
94
95
|
stdout, stderr = capture_streams(capture_output, stdout, stderr)
|
|
95
|
-
result = self._session().invoke(
|
|
96
|
+
result = self._session().invoke(
|
|
97
|
+
command_text(command), raw=False, capture_exit=True
|
|
98
|
+
)
|
|
96
99
|
codec = encoding or "utf-8"
|
|
97
100
|
# Preserve PowerShell's object-pipeline line orientation when
|
|
98
101
|
# projecting objects to subprocess-compatible text.
|
|
@@ -135,7 +138,7 @@ class PsrpExecutor(Executor[subprocess.CompletedProcess]):
|
|
|
135
138
|
errors=errors,
|
|
136
139
|
)
|
|
137
140
|
completed = subprocess.CompletedProcess(
|
|
138
|
-
args=
|
|
141
|
+
args=command_text(command),
|
|
139
142
|
returncode=returncode,
|
|
140
143
|
stdout=out,
|
|
141
144
|
stderr=err,
|
|
@@ -11,6 +11,7 @@ import typing
|
|
|
11
11
|
from ._qga import GuestAgentTransport, QgaProtocolError
|
|
12
12
|
from ._common import (
|
|
13
13
|
CaptureOutput,
|
|
14
|
+
command_text,
|
|
14
15
|
CommandArgument,
|
|
15
16
|
Environment,
|
|
16
17
|
Executor,
|
|
@@ -113,7 +114,8 @@ class QemuExecutor(Executor[subprocess.CompletedProcess]):
|
|
|
113
114
|
"QGA guest-exec has no native working-directory support"
|
|
114
115
|
)
|
|
115
116
|
reject_stdin_conflict(input, stdin)
|
|
116
|
-
|
|
117
|
+
program = command_text(command)
|
|
118
|
+
if not program:
|
|
117
119
|
raise ValueError("QGA guest-exec path must not be empty")
|
|
118
120
|
if timeout is not None and timeout < 0:
|
|
119
121
|
raise ValueError("timeout must not be negative")
|
|
@@ -122,15 +124,11 @@ class QemuExecutor(Executor[subprocess.CompletedProcess]):
|
|
|
122
124
|
|
|
123
125
|
stdout, stderr = capture_streams(capture_output, stdout, stderr)
|
|
124
126
|
argv = [
|
|
125
|
-
(
|
|
126
|
-
value.decode(encoding or "utf-8", errors or "strict")
|
|
127
|
-
if isinstance(value, bytes)
|
|
128
|
-
else str(value)
|
|
129
|
-
)
|
|
127
|
+
command_text(value, encoding=encoding or "utf-8", errors=errors or "strict")
|
|
130
128
|
for value in args
|
|
131
129
|
]
|
|
132
130
|
arguments: typing.Dict[str, object] = {
|
|
133
|
-
"path":
|
|
131
|
+
"path": program,
|
|
134
132
|
"arg": argv,
|
|
135
133
|
"capture-output": True,
|
|
136
134
|
}
|
|
@@ -156,7 +154,7 @@ class QemuExecutor(Executor[subprocess.CompletedProcess]):
|
|
|
156
154
|
arguments["input-data"] = base64.b64encode(payload).decode("ascii")
|
|
157
155
|
|
|
158
156
|
deadline = None if timeout is None else self._clock() + timeout
|
|
159
|
-
command_display = [
|
|
157
|
+
command_display = [program, *argv]
|
|
160
158
|
started = self._execute(
|
|
161
159
|
{"execute": "guest-exec", "arguments": arguments},
|
|
162
160
|
deadline,
|
|
@@ -10,6 +10,7 @@ import typing
|
|
|
10
10
|
|
|
11
11
|
from ._common import (
|
|
12
12
|
CaptureOutput,
|
|
13
|
+
command_text,
|
|
13
14
|
CommandArgument,
|
|
14
15
|
Environment,
|
|
15
16
|
Executor,
|
|
@@ -135,7 +136,7 @@ class SshExecutor(Executor[subprocess.CompletedProcess]):
|
|
|
135
136
|
raise NotImplementedError("SshExecutor does not support native arguments")
|
|
136
137
|
if bufsize == 0:
|
|
137
138
|
raise ValueError("bufsize=0 is unsupported by the buffered SSH executor")
|
|
138
|
-
command =
|
|
139
|
+
command = command_text(command)
|
|
139
140
|
reject_stdin_conflict(input, stdin)
|
|
140
141
|
if text and encoding is None:
|
|
141
142
|
encoding = "utf-8"
|
|
@@ -9,6 +9,7 @@ import typing
|
|
|
9
9
|
|
|
10
10
|
from ._common import (
|
|
11
11
|
CaptureOutput,
|
|
12
|
+
command_text,
|
|
12
13
|
CommandArgument,
|
|
13
14
|
Executor,
|
|
14
15
|
ExecutorCommand,
|
|
@@ -165,7 +166,7 @@ class WinRMExecutor(Executor[subprocess.CompletedProcess]):
|
|
|
165
166
|
raise TypeError(f"unsupported WinRM executor option: {sorted(options)[0]}")
|
|
166
167
|
if args:
|
|
167
168
|
raise NotImplementedError("WinRMExecutor does not support native arguments")
|
|
168
|
-
command =
|
|
169
|
+
command = command_text(command)
|
|
169
170
|
if timeout is not None:
|
|
170
171
|
raise NotImplementedError(
|
|
171
172
|
"WinRMExecutor timeout is unsupported; configure transport timeouts"
|
|
@@ -13,6 +13,7 @@ from ._common import (
|
|
|
13
13
|
uri_host as uri_host,
|
|
14
14
|
uri_hostname as uri_hostname,
|
|
15
15
|
)
|
|
16
|
+
from ._connection import ConnectionString as ConnectionString
|
|
16
17
|
from ._ssh import ssh_providers as ssh_providers
|
|
17
18
|
from ._winrm import winrm_providers as winrm_providers
|
|
18
19
|
from ._local import LocalConfig as LocalConfig, LocalHost as LocalHost
|