diff options
author | Florian Bruhin <me@the-compiler.org> | 2020-04-21 09:56:34 +0200 |
---|---|---|
committer | Florian Bruhin <me@the-compiler.org> | 2020-04-21 09:56:34 +0200 |
commit | c799b7ddf62f476844f9bf5b3538db17fd976f87 (patch) | |
tree | c6a482280d3b48fe81830748f65e5a979d853129 /scripts/utils.py | |
parent | d07773784006337388ad6ab9bf45ac743b95d9ec (diff) | |
download | qutebrowser-c799b7ddf62f476844f9bf5b3538db17fd976f87.tar.gz qutebrowser-c799b7ddf62f476844f9bf5b3538db17fd976f87.zip |
scripts: Print errors to stderr instead of stdout
Diffstat (limited to 'scripts/utils.py')
-rw-r--r-- | scripts/utils.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/scripts/utils.py b/scripts/utils.py index 0d405c8a6..bdf3f96fc 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -21,6 +21,7 @@ import os import os.path +import sys # Import side-effects are an evil thing, but here it's okay so scripts using @@ -58,14 +59,18 @@ def _esc(code): return '\033[{}m'.format(code) -def print_col(text, color): +def print_col(text, color, file=sys.stdout): """Print a colorized text.""" if use_color: fg = _esc(fg_colors[color.lower()]) reset = _esc(fg_colors['reset']) - print(''.join([fg, text, reset])) + print(''.join([fg, text, reset]), file=file) else: - print(text) + print(text, file=file) + + +def print_error(text): + print_col(text, 'red', file=sys.stderr) def print_title(text): |