Commit 13795cf3 authored by Vincent Stehlé's avatar Vincent Stehlé
Browse files

parser.py: more robust colors probing



Even tparm() can fail on some platforms; make the whole colors probing part
more robust by catching exceptions.
Reported-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
Signed-off-by: Vincent Stehlé's avatarVincent Stehlé <vincent.stehle@arm.com>
parent 25d42fd5
......@@ -44,13 +44,16 @@ yellow = ''
green = ''
if os.isatty(sys.stdout.fileno()):
curses.setupterm()
setafb = curses.tigetstr('setaf') or bytes()
setaf = setafb.decode()
normal = curses.tigetstr('sgr0').decode() or ''
red = curses.tparm(setafb, curses.COLOR_RED).decode() or ''
yellow = curses.tparm(setafb, curses.COLOR_YELLOW).decode() or ''
green = curses.tparm(setafb, curses.COLOR_GREEN).decode() or ''
try:
curses.setupterm()
setafb = curses.tigetstr('setaf') or bytes()
setaf = setafb.decode()
normal = curses.tigetstr('sgr0').decode() or ''
red = curses.tparm(setafb, curses.COLOR_RED).decode() or ''
yellow = curses.tparm(setafb, curses.COLOR_YELLOW).decode() or ''
green = curses.tparm(setafb, curses.COLOR_GREEN).decode() or ''
except Exception:
pass
# Compute the plural of a word.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment