Skip to content

Commit 179e9a2

Browse files
committed
Make summary colorful
1 parent ab77ac7 commit 179e9a2

File tree

3 files changed

+25
-16
lines changed

3 files changed

+25
-16
lines changed

colcon_output/event_handler/summary.py

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
import time
55

6+
import colorama
7+
68
from colcon_core.event.job import JobEnded
79
from colcon_core.event.job import JobQueued
810
from colcon_core.event.output import StderrLine
@@ -32,6 +34,7 @@ class SummaryHandler(EventHandlerExtensionPoint):
3234

3335
def __init__(self): # noqa: D107
3436
super().__init__()
37+
colorama.init()
3538
satisfies_version(
3639
EventHandlerExtensionPoint.EXTENSION_POINT_VERSION, '^1.0')
3740
self._queued = set()
@@ -73,38 +76,43 @@ def _print_summary(self):
7376

7477
count, job_type, _ = _msg_arguments(
7578
self._ended - self._interrupted - self._failed)
76-
print('Summary: {count} {job_type} finished '
77-
'[{duration_string}]'.format_map(locals()))
79+
print(colorama.Fore.YELLOW + colorama.Style.BRIGHT + 'Summary: ' +
80+
colorama.Fore.RESET + str(count) + colorama.Style.NORMAL + ' ' +
81+
job_type + ' finished [' + colorama.Fore.YELLOW +
82+
duration_string + colorama.Fore.RESET + ']')
7883

7984
if self._failed:
8085
count, job_type, names = _msg_arguments(self._failed)
81-
print(' {count} {job_type} failed: {names}'
82-
.format_map(locals()))
86+
print(colorama.Fore.RED +
87+
' {count} {job_type} failed: '.format_map(locals()) +
88+
colorama.Style.RESET_ALL + names)
8389

8490
if self._interrupted:
8591
count, job_type, names = _msg_arguments(self._interrupted)
86-
print(' {count} {job_type} aborted: {names}'
87-
.format_map(locals()))
92+
print(colorama.Fore.RED +
93+
' {count} {job_type} aborted: '.format_map(locals()) +
94+
colorama.Style.RESET_ALL + names)
8895

8996
if self._with_stderr:
9097
count, job_type, names = _msg_arguments(self._with_stderr)
91-
print(
92-
' {count} {job_type} had stderr output: {names}'
93-
.format_map(locals()))
98+
print(colorama.Fore.YELLOW +
99+
' {count} {job_type} had stderr output: '
100+
.format_map(locals()) +
101+
colorama.Style.RESET_ALL + names)
94102

95103
if self._with_test_failures:
96104
count, job_type, names = _msg_arguments(
97105
self._with_test_failures)
98-
print(
99-
' {count} {job_type} had test failures: {names}'
100-
.format_map(locals()))
106+
print(colorama.Fore.RED +
107+
' {count} {job_type} had test failures: '
108+
.format_map(locals()) +
109+
colorama.Style.RESET_ALL + names)
101110

102111
if len(self._queued) > len(self._ended):
103112
count = len(self._queued - self._ended)
104113
job_type = get_job_type_word_form(count)
105-
print(
106-
' {count} {job_type} not processed'
107-
.format_map(locals()))
114+
print(colorama.Fore.BLACK + ' {count} {job_type} not processed'
115+
.format_map(locals()) + colorama.Style.RESET_ALL)
108116

109117

110118
def _msg_arguments(jobs):

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ keywords = colcon
2727
[options]
2828
install_requires =
2929
colcon-core>=0.3.8
30+
colorama
3031
packages = find:
3132
zip_safe = true
3233

stdeb.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[colcon-output]
22
No-Python2:
3-
Depends3: python3-colcon-core (>= 0.3.8)
3+
Depends3: python3-colcon-core (>= 0.3.8), python3-colorama
44
Suite: bionic focal jammy stretch buster bullseye
55
X-Python3-Version: >= 3.5

0 commit comments

Comments
 (0)