From d5a15758a840fc6da5127011c2ff247f7a5e0e12 Mon Sep 17 00:00:00 2001 From: "Salvador E. Tropea" Date: Mon, 5 Sep 2022 09:02:01 -0300 Subject: [PATCH] [Install Checker] Avoiod colors when no tty - Also feedback comment --- src/kibot-check | 28 ++++++++++++++++------------ src/kibot-check.in | 28 ++++++++++++++++------------ 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/kibot-check b/src/kibot-check index db4c9e08..bc304685 100755 --- a/src/kibot-check +++ b/src/kibot-check @@ -794,14 +794,17 @@ deps = '{\ kicad_plugins_dirs = [] NOT_AVAIL = 'Not available' UNKNOWN = '*UNKNOWN*' -CSI = '\033[' -RED = CSI+str(31)+'m' -GREEN = CSI+str(32)+'m' -YELLOW = CSI+str(33)+'m' -YELLOW2 = CSI+str(93)+'m' -RESET = CSI+str(39)+'m' -BRIGHT = CSI+";1;4"+'m' -NORMAL = CSI+'0'+'m' +if sys.stdout.isatty(): + CSI = '\033[' + RED = CSI+str(31)+'m' + GREEN = CSI+str(32)+'m' + YELLOW = CSI+str(33)+'m' + YELLOW2 = CSI+str(93)+'m' + RESET = CSI+str(39)+'m' + BRIGHT = CSI+";1;4"+'m' + NORMAL = CSI+'0'+'m' +else: + RED = GREEN = YELLOW = YELLOW2 = RESET = BRIGHT = NORMAL = '' last_ok = False is_x86 = is_64 = is_linux = False 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'], 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') -text = ', '.join([sev2color(c)+l+RESET for c, l in enumerate(labels)]) -print(do_bright('\nColor reference:')+' '+text) +if sys.stdout.isatty(): + labels = ('ok', 'optional for an output', 'optional for general use', 'mandatory for an output', 'mandatory for general use') + 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') diff --git a/src/kibot-check.in b/src/kibot-check.in index c599117b..a632ddd1 100755 --- a/src/kibot-check.in +++ b/src/kibot-check.in @@ -22,14 +22,17 @@ deps = '@json_dep@' kicad_plugins_dirs = [] NOT_AVAIL = 'Not available' UNKNOWN = '*UNKNOWN*' -CSI = '\033[' -RED = CSI+str(31)+'m' -GREEN = CSI+str(32)+'m' -YELLOW = CSI+str(33)+'m' -YELLOW2 = CSI+str(93)+'m' -RESET = CSI+str(39)+'m' -BRIGHT = CSI+";1;4"+'m' -NORMAL = CSI+'0'+'m' +if sys.stdout.isatty(): + CSI = '\033[' + RED = CSI+str(31)+'m' + GREEN = CSI+str(32)+'m' + YELLOW = CSI+str(33)+'m' + YELLOW2 = CSI+str(93)+'m' + RESET = CSI+str(39)+'m' + BRIGHT = CSI+";1;4"+'m' + NORMAL = CSI+'0'+'m' +else: + RED = GREEN = YELLOW = YELLOW2 = RESET = BRIGHT = NORMAL = '' last_ok = False is_x86 = is_64 = is_linux = False 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'], 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') -text = ', '.join([sev2color(c)+l+RESET for c, l in enumerate(labels)]) -print(do_bright('\nColor reference:')+' '+text) +if sys.stdout.isatty(): + labels = ('ok', 'optional for an output', 'optional for general use', 'mandatory for an output', 'mandatory for general use') + 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')