Executor: Programmer friendly subprocess wrapper

23.2 · active · verified Wed Apr 15

The `executor` package is a simple wrapper for Python's `subprocess` module, designed to simplify handling external commands on UNIX systems. It provides an object-oriented interface with proper argument escaping and error checking. Features include support for local commands, remote commands over SSH, execution within chroots, and concurrent command execution through command pools. The library's latest version is 23.2, released in November 2020, with an irregular release cadence.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to run basic commands, handle their success/failure, provide standard input, and capture standard output using the `execute` function.

from executor import execute
import os

# Run a simple command and check its success
print(f"'true' command success: {execute('true')}")
print(f"'false' command success (without check): {execute('false', check=False)}")

# Provide input to a command and capture its output
output = execute('tr a-z A-Z', input='Hello Python Executor\n', capture=True)
print(f"Transformed output: {output.strip()}")

# Example of running a command that fails, demonstrating default error handling
try:
    execute('non_existent_command')
except Exception as e:
    print(f"Caught expected error for non-existent command: {e}")

view raw JSON →