Skip to content

chris-mcdo/sysexits

Repository files navigation

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.

About

python wrapper around FreeBSD exit codes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages