|
3 | 3 |
|
4 | 4 | import time |
5 | 5 |
|
| 6 | +import colorama |
| 7 | + |
6 | 8 | from colcon_core.event.job import JobEnded |
7 | 9 | from colcon_core.event.job import JobQueued |
8 | 10 | from colcon_core.event.output import StderrLine |
@@ -32,6 +34,7 @@ class SummaryHandler(EventHandlerExtensionPoint): |
32 | 34 |
|
33 | 35 | def __init__(self): # noqa: D107 |
34 | 36 | super().__init__() |
| 37 | + colorama.init() |
35 | 38 | satisfies_version( |
36 | 39 | EventHandlerExtensionPoint.EXTENSION_POINT_VERSION, '^1.0') |
37 | 40 | self._queued = set() |
@@ -73,38 +76,43 @@ def _print_summary(self): |
73 | 76 |
|
74 | 77 | count, job_type, _ = _msg_arguments( |
75 | 78 | 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 + ']') |
78 | 83 |
|
79 | 84 | if self._failed: |
80 | 85 | 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) |
83 | 89 |
|
84 | 90 | if self._interrupted: |
85 | 91 | 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) |
88 | 95 |
|
89 | 96 | if self._with_stderr: |
90 | 97 | 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) |
94 | 102 |
|
95 | 103 | if self._with_test_failures: |
96 | 104 | count, job_type, names = _msg_arguments( |
97 | 105 | 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) |
101 | 110 |
|
102 | 111 | if len(self._queued) > len(self._ended): |
103 | 112 | count = len(self._queued - self._ended) |
104 | 113 | 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) |
108 | 116 |
|
109 | 117 |
|
110 | 118 | def _msg_arguments(jobs): |
|
0 commit comments