diff options
author | QMK Bot <[email protected]> | 2024-06-15 09:38:16 +0000 |
---|---|---|
committer | QMK Bot <[email protected]> | 2024-06-15 09:38:16 +0000 |
commit | faa84a7c9016a76eb7d594b5ce33a62fe2b1f81e (patch) | |
tree | 88bd0ea38d2673c9c5920c74f80814bae670334f /lib/python/qmk/util.py | |
parent | e31418ee119a63dbc930e4148dca92a8e9260b07 (diff) | |
parent | 0262161914133e6abfc306e675dbac3ba816a6ee (diff) | |
download | qmk_firmware-faa84a7c9016a76eb7d594b5ce33a62fe2b1f81e.tar.gz qmk_firmware-faa84a7c9016a76eb7d594b5ce33a62fe2b1f81e.zip |
Merge remote-tracking branch 'origin/master' into develop
Diffstat (limited to 'lib/python/qmk/util.py')
-rw-r--r-- | lib/python/qmk/util.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/python/qmk/util.py b/lib/python/qmk/util.py index db7debd578..0145ab1354 100644 --- a/lib/python/qmk/util.py +++ b/lib/python/qmk/util.py @@ -2,9 +2,30 @@ """ import contextlib import multiprocessing +import sys from milc import cli +maybe_exit_should_exit = True +maybe_exit_reraise = False + + +# Controls whether or not early `exit()` calls should be made +def maybe_exit(rc): + if maybe_exit_should_exit: + sys.exit(rc) + if maybe_exit_reraise: + e = sys.exception() + if e: + raise e + + +def maybe_exit_config(should_exit: bool = True, should_reraise: bool = False): + global maybe_exit_should_exit + global maybe_exit_reraise + maybe_exit_should_exit = should_exit + maybe_exit_reraise = should_reraise + @contextlib.contextmanager def parallelize(): |