is the arbiter between shell scripts and commands.
Project description
diplomat
diplomat is the arbiter between shell scripts and commands. You give it
commands, and it gives you back diplomats that you can inquire about the
state of those commands, their output, and files containing their complete
output thus far.
Installation
pip install diplomat
Usage
A Diplomat is a high level, yet simple interface to commands and scripts.
You can give it shell commands as variable arguments, and it will execute
them asynchronously using subprocesses, writing the output into files.
from diplomat import Diplomat
diplo = Diplomat("ls", "-l", "example")
assert diplo.is_running()
# we can register asynchronous exit functions, can also be provided to
# constructor as on_exit, along with pre_start and post_start
diplo.register_exit_fn(lambda x: print("Diplomat is done"))
diplo.wait()
output = diplo.output()
file_name = diplo.output_file_name()
diplo.has_finished()
Output files can also be reused by providing the out and err keyword
arguments to the constructor of Diplomat.
An Attachee is an unprivileged grunt worker. It’s a read-only copy of a
Diplomat, or an interface to the files that a Diplomat created.
from diplomat import Attachee, Diplomat
diplo = Diplomat("ls", "-l", "example")
diplo.wait()
# we can create an attachee either from the diplomat directly
att = diplo.to_attachee()
# or from the file names; this is useful if we saved those
# references somewhere, for instance in a database
out = diplo.output_file_name()
err = diplo.error_file_name()
att = Attachee(out, err)
Have fun!
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
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 diplomat-0.1.2.tar.gz.
File metadata
- Download URL: diplomat-0.1.2.tar.gz
- Upload date:
- Size: 3.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1cd733758874240f4efc7b9ce099891d8b3b51bdd9d5a383f5a6c4c7475783f5
|
|
| MD5 |
dd4ea7ecb2f374dbd53d158f4364dbac
|
|
| BLAKE2b-256 |
af60b18d7742370393127d9c0bcb76567a7a7721651d68b2c45f79fab5e02553
|
File details
Details for the file diplomat-0.1.2-py3-none-any.whl.
File metadata
- Download URL: diplomat-0.1.2-py3-none-any.whl
- Upload date:
- Size: 15.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.7.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b57e7bf7199288e005774f50e4e53de9282627b7f57764a17e03aff766a4b4dd
|
|
| MD5 |
8ea493ddb65e37fc5151559b669cb1a3
|
|
| BLAKE2b-256 |
f509d88f5c1d1dac3aa74535f09e96cda448356b848dbe043867c9cece6bab31
|