Webconfig: Don't outright abort if curses can't be imported

We only need the curses module to look up sgr0, bold and underline
sequences.

Since those are going to be the xterm versions 90% of the time, we can
simply use those if this fails.

Fixes .
This commit is contained in:
Fabian Homborg 2021-11-27 09:53:11 +01:00
parent 6f7b80e5b4
commit 5a71d02d32

@ -508,6 +508,7 @@ g_special_escapes_dict = None
def get_special_ansi_escapes():
global g_special_escapes_dict
if g_special_escapes_dict is None:
try:
import curses
g_special_escapes_dict = {}
@ -527,6 +528,17 @@ def get_special_ansi_escapes():
g_special_escapes_dict["exit_attribute_mode"] = get_tparm("sgr0")
g_special_escapes_dict["bold"] = get_tparm("bold")
g_special_escapes_dict["underline"] = get_tparm("smul")
except ImportError:
print("WARNING: The python curses module is missing.")
print("WARNING: Falling back to xterm-256color settings.")
print("WARNING: Rebuild python with curses headers!")
g_special_escapes_dict = {
'exit_attribute_mode': '\x1b(B\x1b[m',
'bold': '\x1b[1m',
'underline': '\x1b[4m'
}
pass
return g_special_escapes_dict