Skip to main content

A cross-operating-system compatible library for os.EX_* constants

Project description

Exit Codes

This package is a cross-operating-system compatible version of the os library's EX_* constants.

If these constants are available, they will be re-exported directly from os, otherwise the integer version will be provided from this library.

This library also provides an enum version of the exit codes, if that is of value.

Apologies for the weird PyPi name, they're a bit overly restrictive and don't point to what specifically is the conflicting package.

Installation

python -m pip install -U os-exitcodes

Usage

Constants

from os_exitcodes import (
    EX_OK,
    EX_USAGE,
)
from random import choice

def is_valid_usage() -> bool:
    # check if the user is using this properly
    # for a working example, this is random
    return choice([True, False])

def main() -> None:
    invalid_usage = random
    if not is_valid_usage():
        raise SystemExit(EX_USAGE)
    raise SystemExit(EX_OK)

if __name__ == "__main__":
    main()

Enumeration

from os_exitcodes import ExitCode
from random import choice

def is_valid_usage() -> bool:
    # check if the user is using this properly
    # for a working example, this is random
    return choice([True, False])

def main() -> None:
    invalid_usage = random
    if not is_valid_usage():
        raise SystemExit(ExitCode.EX_USAGE)
    raise SystemExit(ExitCode.EX_OK)

if __name__ == "__main__":
    main()

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

os_exitcodes-1.0.1.tar.gz (4.7 kB view hashes)

Uploaded Source

Built Distribution

os_exitcodes-1.0.1-py3-none-any.whl (5.8 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