mirror of https://github.com/zeldaret/oot.git
Colored Jenkins output
This commit is contained in:
parent
d4a87889ff
commit
3bf1e4afd9
|
@ -3,6 +3,10 @@ pipeline {
|
||||||
label 'oot'
|
label 'oot'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
options {
|
||||||
|
ansiColor('xterm')
|
||||||
|
}
|
||||||
|
|
||||||
stages {
|
stages {
|
||||||
stage('Check formatting (full)') {
|
stage('Check formatting (full)') {
|
||||||
when {
|
when {
|
||||||
|
|
|
@ -13,6 +13,7 @@ from dataclasses import dataclass
|
||||||
import io
|
import io
|
||||||
import multiprocessing
|
import multiprocessing
|
||||||
import multiprocessing.pool
|
import multiprocessing.pool
|
||||||
|
import os
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import re
|
import re
|
||||||
import shlex
|
import shlex
|
||||||
|
@ -36,9 +37,12 @@ import mapfile_parser.mapfile
|
||||||
# Set on program start since we replace sys.stdout in worker processes
|
# Set on program start since we replace sys.stdout in worker processes
|
||||||
stdout_isatty = sys.stdout.isatty()
|
stdout_isatty = sys.stdout.isatty()
|
||||||
|
|
||||||
|
# https://no-color.org/
|
||||||
|
enable_colors = os.environ.get("NO_COLOR", "") == ""
|
||||||
|
|
||||||
|
|
||||||
def output(message: str = "", color: Optional[str] = None, end: str = "\n"):
|
def output(message: str = "", color: Optional[str] = None, end: str = "\n"):
|
||||||
if color and stdout_isatty:
|
if color and enable_colors:
|
||||||
print(f"{color}{message}{colorama.Fore.RESET}", end=end)
|
print(f"{color}{message}{colorama.Fore.RESET}", end=end)
|
||||||
else:
|
else:
|
||||||
print(message, end=end)
|
print(message, end=end)
|
||||||
|
|
Loading…
Reference in New Issue