diff --git a/CHANGELOG.md b/CHANGELOG.md index c62b424e..1a9107a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Command line: - `--help-list-offsets` to list footprint offsets (JLCPCB) - `--help-list-rotations` to list footprint rotations (JLCPCB) + - `--stop-on-warnings` (`-W`) to stop on warnings (#545) - Global options: - `remove_solder_mask_for_dnp` similar to `remove_solder_paste_for_dnp` but applied to the solder mask apertures. (#476) diff --git a/kibot/__main__.py b/kibot/__main__.py index 721846e3..9510e3f5 100644 --- a/kibot/__main__.py +++ b/kibot/__main__.py @@ -10,7 +10,7 @@ Usage: kibot [-b BOARD] [-e SCHEMA] [-c CONFIG] [-d OUT_DIR] [-s PRE] [-D] [-q | -v...] [-L LOGFILE] [-C | -i | -n] [-m MKFILE] [-A] [-g DEF] ... - [-E DEF] ... [-w LIST] [--banner N] [TARGET...] + [-E DEF] ... [-w LIST] [-W] [--banner N] [TARGET...] kibot [-v...] [-b BOARD] [-e SCHEMA] [-c PLOT_CONFIG] [--banner N] [-E DEF] ... [--config-outs] [--only-pre|--only-groups] [--only-names] [--output-name-first] --list @@ -72,6 +72,7 @@ Options: -v, --verbose Show debugging information -V, --version Show program's version number and exit -w, --no-warn LIST Exclude the mentioned warnings (comma sep) + -W, --stop-on-warnings Stop on warnings -x, --example Create a template configuration file Quick start options: @@ -410,6 +411,7 @@ def main(): # The log setup finished, this is our first log message logger.debug('KiBot {} verbose level: {} started on {}'.format(__version__, args.verbose, datetime.now())) apply_warning_filter(args) + log.stop_on_warnings = args.stop_on_warnings # Now we have the debug level set we can check (and optionally inform) KiCad info detect_kicad() detect_windows() diff --git a/kibot/log.py b/kibot/log.py index 591f6d73..55f63319 100644 --- a/kibot/log.py +++ b/kibot/log.py @@ -14,6 +14,7 @@ import os import sys import traceback import logging +from .misc import WARN_AS_ERROR no_colorama = False try: from colorama import init as colorama_init, Fore, Back, Style @@ -30,6 +31,7 @@ filters = [] root_logger = None visual_level = None debug_level = 0 +stop_on_warnings = False def get_logger(name=None, indent=None): @@ -106,6 +108,9 @@ class MyLogger(logging.Logger): super().warning(buf, stacklevel=2, **kwargs) # pragma: no cover (Py38) else: super().warning(buf, **kwargs) + if stop_on_warnings: + self.error('Warnings treated as errors') + sys.exit(WARN_AS_ERROR) def log(self, level, msg, *args, **kwargs): if level < self.getEffectiveLevel(): diff --git a/kibot/misc.py b/kibot/misc.py index 757fc94a..801b16d0 100644 --- a/kibot/misc.py +++ b/kibot/misc.py @@ -46,6 +46,7 @@ DXF_SCH_PRINT = 32 HPGL_SCH_PRINT = 33 CORRUPTED_PRO = 34 BLENDER_ERROR = 35 +WARN_AS_ERROR = 36 error_level_to_name = ['NONE', 'INTERNAL_ERROR', 'WRONG_ARGUMENTS', @@ -81,7 +82,8 @@ error_level_to_name = ['NONE', 'DXF_SCH_PRINT', 'HPGL_SCH_PRINT', 'CORRUPTED_PRO', - 'BLENDER_ERROR' + 'BLENDER_ERROR', + 'WARN_AS_ERROR' ] KICOST_SUBMODULE = '../submodules/KiCost/src/kicost' EXAMPLE_CFG = 'example_template.kibot.yaml'