sysexits

simple python wrapper around FreeBSD sysexits


Keywords
freebsd, exit, error, wrapper
License
MIT
Install
pip install sysexits==0.5.0

Documentation

sysexits

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.