[Install Checker] Avoiod colors when no tty

- Also feedback comment
This commit is contained in:
Salvador E. Tropea 2022-09-05 09:02:01 -03:00
parent 0631836f29
commit d5a15758a8
2 changed files with 32 additions and 24 deletions

View File

@ -794,14 +794,17 @@ deps = '{\
kicad_plugins_dirs = [] kicad_plugins_dirs = []
NOT_AVAIL = 'Not available' NOT_AVAIL = 'Not available'
UNKNOWN = '*UNKNOWN*' UNKNOWN = '*UNKNOWN*'
CSI = '\033[' if sys.stdout.isatty():
RED = CSI+str(31)+'m' CSI = '\033['
GREEN = CSI+str(32)+'m' RED = CSI+str(31)+'m'
YELLOW = CSI+str(33)+'m' GREEN = CSI+str(32)+'m'
YELLOW2 = CSI+str(93)+'m' YELLOW = CSI+str(33)+'m'
RESET = CSI+str(39)+'m' YELLOW2 = CSI+str(93)+'m'
BRIGHT = CSI+";1;4"+'m' RESET = CSI+str(39)+'m'
NORMAL = CSI+'0'+'m' BRIGHT = CSI+";1;4"+'m'
NORMAL = CSI+'0'+'m'
else:
RED = GREEN = YELLOW = YELLOW2 = RESET = BRIGHT = NORMAL = ''
last_ok = False last_ok = False
is_x86 = is_64 = is_linux = False is_x86 = is_64 = is_linux = False
ver_re = re.compile(r'(\d+)\.(\d+)(?:\.(\d+))?(?:[\.-](\d+))?') ver_re = re.compile(r'(\d+)\.(\d+)(?:\.(\d+))?(?:[\.-](\d+))?')
@ -1235,9 +1238,10 @@ for name, d in dependencies.items():
binary_tool(d['sev'], d['name'], d['url'], d['url_down'], d['deb_package'], d['in_debian'], d['extra_deb'], binary_tool(d['sev'], d['name'], d['url'], d['url_down'], d['deb_package'], d['in_debian'], d['extra_deb'],
d['roles'], d['downloader_str'], d['comments']) d['roles'], d['downloader_str'], d['comments'])
labels = ('ok', 'optional for an output', 'optional for general use', 'mandatory for an output', 'mandatory for general use') if sys.stdout.isatty():
text = ', '.join([sev2color(c)+l+RESET for c, l in enumerate(labels)]) labels = ('ok', 'optional for an output', 'optional for general use', 'mandatory for an output', 'mandatory for general use')
print(do_bright('\nColor reference:')+' '+text) text = ', '.join([sev2color(c)+l+RESET for c, l in enumerate(labels)])
print(do_bright('\nColor reference:')+' '+text)
print('\nDid this help? Please consider commenting it on https://github.com/INTI-CMNB/KiBot/discussions/categories/kibot-check') print('\nDid this help? Please consider commenting it on https://github.com/INTI-CMNB/KiBot/discussions/categories/kibot-check')

View File

@ -22,14 +22,17 @@ deps = '@json_dep@'
kicad_plugins_dirs = [] kicad_plugins_dirs = []
NOT_AVAIL = 'Not available' NOT_AVAIL = 'Not available'
UNKNOWN = '*UNKNOWN*' UNKNOWN = '*UNKNOWN*'
CSI = '\033[' if sys.stdout.isatty():
RED = CSI+str(31)+'m' CSI = '\033['
GREEN = CSI+str(32)+'m' RED = CSI+str(31)+'m'
YELLOW = CSI+str(33)+'m' GREEN = CSI+str(32)+'m'
YELLOW2 = CSI+str(93)+'m' YELLOW = CSI+str(33)+'m'
RESET = CSI+str(39)+'m' YELLOW2 = CSI+str(93)+'m'
BRIGHT = CSI+";1;4"+'m' RESET = CSI+str(39)+'m'
NORMAL = CSI+'0'+'m' BRIGHT = CSI+";1;4"+'m'
NORMAL = CSI+'0'+'m'
else:
RED = GREEN = YELLOW = YELLOW2 = RESET = BRIGHT = NORMAL = ''
last_ok = False last_ok = False
is_x86 = is_64 = is_linux = False is_x86 = is_64 = is_linux = False
ver_re = re.compile(r'(\d+)\.(\d+)(?:\.(\d+))?(?:[\.-](\d+))?') ver_re = re.compile(r'(\d+)\.(\d+)(?:\.(\d+))?(?:[\.-](\d+))?')
@ -463,9 +466,10 @@ for name, d in dependencies.items():
binary_tool(d['sev'], d['name'], d['url'], d['url_down'], d['deb_package'], d['in_debian'], d['extra_deb'], binary_tool(d['sev'], d['name'], d['url'], d['url_down'], d['deb_package'], d['in_debian'], d['extra_deb'],
d['roles'], d['downloader_str'], d['comments']) d['roles'], d['downloader_str'], d['comments'])
labels = ('ok', 'optional for an output', 'optional for general use', 'mandatory for an output', 'mandatory for general use') if sys.stdout.isatty():
text = ', '.join([sev2color(c)+l+RESET for c, l in enumerate(labels)]) labels = ('ok', 'optional for an output', 'optional for general use', 'mandatory for an output', 'mandatory for general use')
print(do_bright('\nColor reference:')+' '+text) text = ', '.join([sev2color(c)+l+RESET for c, l in enumerate(labels)])
print(do_bright('\nColor reference:')+' '+text)
print('\nDid this help? Please consider commenting it on https://github.com/INTI-CMNB/KiBot/discussions/categories/kibot-check') print('\nDid this help? Please consider commenting it on https://github.com/INTI-CMNB/KiBot/discussions/categories/kibot-check')