Targomiko
A wrapper for paramiko, focused on easy remote command handling of IO, waiting, abortion and exit-code retrieval.
It also brings along sane defaults for zero-user-interaction automation.
Installing
pip install targomiko
Examples
import time
import targomiko
with targomiko.SSHConnection("127.0.0.1", "user", password="password") as ssh:
ssh.upload_recursive(".", "/opt/targomiko")
# Do something with the underlying paramiko client
with ssh.client.open_sftp() as sftp:
sftp.mkdir("/opt/somedir")
# Execute command and wait for exit.
with ssh.exec('/opt/targomiko/entrypoint.sh arg1 "long arg 2"') as cmd:
cmd.wait()
print(f"Exit code: {cmd.exit_code}") # Will output something along the lines of "Exit code: 0"
# Execute command and abort after 1.5 seconds
with ssh.exec('/opt/targomiko/entrypoint.sh arg1 "long arg 2"') as cmd:
try:
cmd.wait(1.5)
except TimeoutError:
print("command timed out")
# Upon exit of the with, the command is aborted
print(f"Exit code: {cmd.exit_code}") # If the timeout was reached, will output "Exit code: -1"
# Execute command and abort after 1.5 seconds
with ssh.exec('/opt/targomiko/entrypoint.sh arg1 "long arg 2"') as cmd:
cmd.stdin.write("helo")
time.sleep(1)
# Preliminary output
print(f"STDOUT: {cmd.stdout}")
print(f"STDERR: {cmd.stderr}")
cmd.wait()
# Final, complete output
print(f"STDOUT: {cmd.stdout}")
print(f"STDERR: {cmd.stderr}")
print(f"Exit code: {cmd.exit_code}")
# You don't *have to* use a with-statement, but then remember to call close!
cmd = ssh.exec('/opt/targomiko/entrypoint.sh arg1 "long arg 2"')
try:
cmd.wait(1.5)
except TimeoutError:
print("command timed out")
finally:
cmd.close()
Metadata
Release files for targomiko 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| targomiko-0.2.0.tar.gz | 5.2 kB | Without provenance | Details for targomiko-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| targomiko-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for targomiko-0.2.0-py3-none-any.whl |
Total release size: 11.2 kB
Release files / targomiko-0.2.0.tar.gz
| Download URL | targomiko-0.2.0.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0f6fef2c41a15e9a9543fec4e9c2bc8798010bb539612f2097c22e79335a3ab9
|
|
BLAKE2b-256 checksum How to use checksums |
1b17f819c1edf6f475944632e751a201d560a932177f6590b3d0201236b11ec4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|
Release files / targomiko-0.2.0-py3-none-any.whl
| Download URL | targomiko-0.2.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d48b0beddc31b579832a49883b9e8b5cc7cd899006cf990ed42437d5b7d4f914
|
|
BLAKE2b-256 checksum How to use checksums |
7cac9ed4bee70e354ee89e6d7ea32e99d5945238db95961d2baa46f364b56859
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1
|
Security for targomiko 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.