Skip to main content

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!

Release files for diplomat 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for diplomat 0.1.2
File Size Uploaded
diplomat-0.1.2.tar.gz 3.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for diplomat 0.1.2
File Interpreter ABI Platform
diplomat-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 19.0 kB

Release files / diplomat-0.1.2.tar.gz

Download URL diplomat-0.1.2.tar.gz
Size 3.2 kB
Tags Source
SHA-256 checksum
How to use checksums
1cd733758874240f4efc7b9ce099891d8b3b51bdd9d5a383f5a6c4c7475783f5
BLAKE2b-256 checksum
How to use checksums
af60b18d7742370393127d9c0bcb76567a7a7721651d68b2c45f79fab5e02553
Upload date
Uploaded using Trusted Publishing?
What is 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

Release files / diplomat-0.1.2-py3-none-any.whl

Download URL diplomat-0.1.2-py3-none-any.whl
Size 15.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b57e7bf7199288e005774f50e4e53de9282627b7f57764a17e03aff766a4b4dd
BLAKE2b-256 checksum
How to use checksums
f509d88f5c1d1dac3aa74535f09e96cda448356b848dbe043867c9cece6bab31
Upload date
Uploaded using Trusted Publishing?
What is 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

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page