Skip to main content

a command-line utility to pipe the exit code from a subprocess through one or more modifiers

Project description

exit-pipe

exit-pipe: a command-line utility to pipe the exit code from a subprocess through one or more modifiers.

build codecov

Background

This utility executes a specified subprocess, captures its exit code, and exits with the result of piping the exit code through a conditional exit code modifier.

The motivation for this slightly obtuse solution was to work around limitations imposed by build utilities which execute configurable subprocesses without exposing full shell access (e.g. tox) while also maintaining reasonable portability across multiple operating system environments (thus eliminating the option of executing an explicit shell within tox).

As of this release, one style of exit code modifier pipeline exists: bitfield.

The bitfield exit code pipeline (activated via the --bitfield argument) evaluates the exit code against one or more bitfield masks and either replaces the exit code with the mapping specified by the first matching bitfield mask or passes through the unmodified exit code if no bitfield masks match.

Supported Platforms

This utility has been tested on macOS Catalina 10.15.

Usage

Development Environment

Initialize a development environment by executing tox; the exit-pipe utility will be installed in the .tox/py38 Python virtual environment binary path.

Examples

Remap non-fatal, non-error pylint exit codes to 0

As of pylint 2.4.3, the utility's exit code is a bitfield that may be decoded as:

Bit Meaning
0 No error
1 Fatal message issued
2 Error message issued
4 Warning message issued
8 Refactor message issued
16 Convention message issued
32 Usage error

To remap the exit code for pylint src such that it exits with:

  • 1 for fatal (1) and error (2) exit codes, and
  • 0 for warning (4), refactor (8), convention (16), and usage (32) exit codes,

you may pass pylint through exit-pipe as follows:

exit-pipe --bitfield "3:1;60:0" -- pylint src

The equivalent bitfield masks may be specified individually as follows:

exit-pipe --bitfield "1,2:1;4,8,16,32:0" -- pylint src

As niche as this example may be, it serves as a generic workaround to cases where you may wish to log all pylint messages while only interpreting a few classes of messages as build errors. Disabling or ignoring classes of messages would result in them not being logged.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

exit-pipe-1.0.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

exit_pipe-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file exit-pipe-1.0.0.tar.gz.

File metadata

  • Download URL: exit-pipe-1.0.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.0

File hashes

Hashes for exit-pipe-1.0.0.tar.gz
Algorithm Hash digest
SHA256 5c1847982d4c917be7c33bd40c686ce1c66fd934d73cf4ca08381da5d3256848
MD5 d43e26399d714ca99d0023ff69083fc7
BLAKE2b-256 fb63f4d8f7b69fc13311ce6839aa248f195882f6ffaf43ddd9b98af39c6662cf

See more details on using hashes here.

File details

Details for the file exit_pipe-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: exit_pipe-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.8.0

File hashes

Hashes for exit_pipe-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 37424ebb9407d9b3d6c70182b167de2ee4ce3dd5a23107393fcf0e95a91b5557
MD5 1a80d32d83a21312a6c2aef1a9f56bb9
BLAKE2b-256 262cb41dbba097bc02fc7d8dee1febb38452b78bc1961b3cd40bee2f8a521525

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page