diff --git a/colcon_output/event_handler/summary.py b/colcon_output/event_handler/summary.py index be68f7f..764f3e8 100644 --- a/colcon_output/event_handler/summary.py +++ b/colcon_output/event_handler/summary.py @@ -3,6 +3,8 @@ import time +import colorama + from colcon_core.event.job import JobEnded from colcon_core.event.job import JobQueued from colcon_core.event.output import StderrLine @@ -32,6 +34,7 @@ class SummaryHandler(EventHandlerExtensionPoint): def __init__(self): # noqa: D107 super().__init__() + colorama.init() satisfies_version( EventHandlerExtensionPoint.EXTENSION_POINT_VERSION, '^1.0') self._queued = set() @@ -73,38 +76,43 @@ def _print_summary(self): count, job_type, _ = _msg_arguments( self._ended - self._interrupted - self._failed) - print('Summary: {count} {job_type} finished ' - '[{duration_string}]'.format_map(locals())) + print(colorama.Fore.YELLOW + colorama.Style.BRIGHT + 'Summary: ' + + colorama.Fore.RESET + str(count) + colorama.Style.NORMAL + ' ' + + job_type + ' finished [' + colorama.Fore.YELLOW + + duration_string + colorama.Fore.RESET + ']') if self._failed: count, job_type, names = _msg_arguments(self._failed) - print(' {count} {job_type} failed: {names}' - .format_map(locals())) + print(colorama.Fore.RED + + ' {count} {job_type} failed: '.format_map(locals()) + + colorama.Style.RESET_ALL + names) if self._interrupted: count, job_type, names = _msg_arguments(self._interrupted) - print(' {count} {job_type} aborted: {names}' - .format_map(locals())) + print(colorama.Fore.RED + + ' {count} {job_type} aborted: '.format_map(locals()) + + colorama.Style.RESET_ALL + names) if self._with_stderr: count, job_type, names = _msg_arguments(self._with_stderr) - print( - ' {count} {job_type} had stderr output: {names}' - .format_map(locals())) + print(colorama.Fore.YELLOW + + ' {count} {job_type} had stderr output: ' + .format_map(locals()) + + colorama.Style.RESET_ALL + names) if self._with_test_failures: count, job_type, names = _msg_arguments( self._with_test_failures) - print( - ' {count} {job_type} had test failures: {names}' - .format_map(locals())) + print(colorama.Fore.RED + + ' {count} {job_type} had test failures: ' + .format_map(locals()) + + colorama.Style.RESET_ALL + names) if len(self._queued) > len(self._ended): count = len(self._queued - self._ended) job_type = get_job_type_word_form(count) - print( - ' {count} {job_type} not processed' - .format_map(locals())) + print(colorama.Fore.BLACK + ' {count} {job_type} not processed' + .format_map(locals()) + colorama.Style.RESET_ALL) def _msg_arguments(jobs): diff --git a/setup.cfg b/setup.cfg index 70ee272..e569403 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,6 +28,7 @@ keywords = colcon python_requires = >=3.6 install_requires = colcon-core>=0.3.8 + colorama packages = find: zip_safe = true diff --git a/stdeb.cfg b/stdeb.cfg index b2c91c7..46676ea 100644 --- a/stdeb.cfg +++ b/stdeb.cfg @@ -1,5 +1,5 @@ [colcon-output] No-Python2: -Depends3: python3-colcon-core (>= 0.3.8) +Depends3: python3-colcon-core (>= 0.3.8), python3-colorama Suite: focal jammy noble bookworm trixie X-Python3-Version: >= 3.6