failprint
Run a command, print its output only if it fails.
Tired of searching the quiet options of your programs
to lighten up the output of your make check or make lint commands?
Tired of finding out that standard output and error are mixed up in some of them?
Simply run your command through failprint.
If it succeeds, nothing is printed.
If it fails, standard error is printed.
Plus other configuration goodies 😉
Example
You don't want to see output when the command succeeds.
The task runner duty uses failprint,
allowing you to define tasks in Python and run them with minimalist and beautiful output:
Installation
pip install failprint
With uv:
uv tool install failprint
Usage
% poetry run failprint -h
usage: failprint [-h] [-c {stdout,stderr,both,none}] [-f {pretty,tap}] [-y | -Y] [-p | -P] [-q | -Q] [-s | -S] [-z | -Z] [-n NUMBER]
[-t TITLE]
COMMAND [COMMAND ...]
positional arguments:
COMMAND
optional arguments:
-h, --help show this help message and exit
-c {stdout,stderr,both,none}, --capture {stdout,stderr,both,none}
Which output to capture. Colors are supported with 'both' only, unless the command has a 'force color'
option.
-f {pretty,tap}, --format {pretty,tap}
Output format. Pass your own Jinja2 template as a string with '-f custom=TEMPLATE'. Available variables:
command, title (command or title passed with -t), code (exit status), success (boolean), failure (boolean),
number (command number passed with -n), output (command output), nofail (boolean), quiet (boolean), silent
(boolean). Available filters: indent (textwrap.indent).
-y, --pty Enable the use of a pseudo-terminal. PTY doesn't allow programs to use standard input.
-Y, --no-pty Disable the use of a pseudo-terminal. PTY doesn't allow programs to use standard input.
-p, --progress Print progress while running a command.
-P, --no-progress Don't print progress while running a command.
-q, --quiet Don't print the command output, even if it failed.
-Q, --no-quiet Print the command output when it fails.
-s, --silent Don't print anything.
-S, --no-silent Print output as usual.
-z, --zero, --nofail Don't fail. Always return a success (0) exit code.
-Z, --no-zero, --strict
Return the original exit code.
-n NUMBER, --number NUMBER
Command number. Useful for the 'tap' format.
-t TITLE, --title TITLE
Command title. Default is the command itself.
from failprint import run
cmd = "echo hello"
exit_code = run(
cmd, # str, list of str, or Python callable
args=None, # args for callable
kwargs=None, # kwargs for callable
number=1, # command number, useful for tap format
capture=None, # stdout, stderr, both, none, True or False
title=None, # command title
fmt=None, # pretty, tap, or custom="MY_CUSTOM_FORMAT"
pty=False, # use a PTY
progress=True, # print the "progress" template before running the command
nofail=False, # always return zero
quiet=False, # don't print output when the command fails
silent=False, # don't print anything
)
Sponsors
And 4 more private sponsor(s).
Metadata
Release files for failprint 1.1.1
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 |
|---|---|---|---|---|
| failprint-1.1.1.tar.gz | 52.7 kB | Without provenance | Details for failprint-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| failprint-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for failprint-1.1.1-py3-none-any.whl |
Total release size: 84.5 kB
Release files / failprint-1.1.1.tar.gz
| Download URL | failprint-1.1.1.tar.gz |
|---|---|
| Size | 52.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
05e8d7e0484379e34bf35665789199537b32e79ef5a474de5463ed1ee451ddba
|
|
BLAKE2b-256 checksum How to use checksums |
808df0687a2f62726b52db0785d9b7b4854344d35d5a5ecab01774701a320879
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Release files / failprint-1.1.1-py3-none-any.whl
| Download URL | failprint-1.1.1-py3-none-any.whl |
|---|---|
| Size | 31.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7fd282942e4b43d05d3d68b35c57e7f415a7989490d9b8396b0bd0cea25b1bcb
|
|
BLAKE2b-256 checksum How to use checksums |
b112e13177affa0140b9651069a011e10ae9cd45c3f2f3a29a339239bf824531
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.8
|
Security for failprint 1.1.1
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.