My package description
Project description
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()
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
targomiko-0.2.0.tar.gz
(5.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file targomiko-0.2.0.tar.gz.
File metadata
- Download URL: targomiko-0.2.0.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f6fef2c41a15e9a9543fec4e9c2bc8798010bb539612f2097c22e79335a3ab9
|
|
| MD5 |
0273579c79ca98552668073dba4aed05
|
|
| BLAKE2b-256 |
1b17f819c1edf6f475944632e751a201d560a932177f6590b3d0201236b11ec4
|
File details
Details for the file targomiko-0.2.0-py3-none-any.whl.
File metadata
- Download URL: targomiko-0.2.0-py3-none-any.whl
- Upload date:
- Size: 6.0 kB
- Tags: Python 3
- Uploaded using 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
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d48b0beddc31b579832a49883b9e8b5cc7cd899006cf990ed42437d5b7d4f914
|
|
| MD5 |
5ef00f48876ee2964d0d7d9737ee23e0
|
|
| BLAKE2b-256 |
7cac9ed4bee70e354ee89e6d7ea32e99d5945238db95961d2baa46f364b56859
|