Skip to main content

simple python wrapper around FreeBSD sysexits

Project description

Unit Tests Unit Test Coverage MIT License

A simple python wrapper around the FreeBSD “preferable exit codes for programs”.

It is useful for getting informative error messages from subprocesses which use FreeBSD-recommended exit codes (linked above).

Usage

Either select an exception manually using the EXCEPTIONS dictionary, or call raise_for_returncode with the completed process.

import subprocess
import sysexits

print(sysexits.EX_PROTOCOL)
# 76

process = subprocess.run("exit 76", shell=True)
print(sysexits.EXCEPTIONS[process.returncode])
# <class 'sysexits.ProtocolError'>

sysexits.raise_for_returncode(process)
# Traceback (most recent call last):
# ...
# sysexits.ProtocolError

License

Copyright (c) 2022 Christopher McDonald

Distributed under the terms of the MIT license.

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

sysexits-0.5.0.tar.gz (6.5 kB view hashes)

Uploaded Source

Built Distribution

sysexits-0.5.0-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

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