Преглед на файлове

Bugfix and improvement for console color support

Cammy преди 7 години
родител
ревизия
e8671bc46e
променени са 2 файла, в които са добавени 10 реда и са изтрити 7 реда
  1. 6 3
      pyinstalive/initialize.py
  2. 4 4
      pyinstalive/logger.py

+ 6 - 3
pyinstalive/initialize.py

@@ -196,7 +196,7 @@ def show_info(config):
 	else:
 		log("[W] Cookie files:            	None found", "YELLOW")
 
-	log("[I] CLI supports color:     	" + str(supports_color()), "GREEN")
+	log("[I] CLI supports color:     	" + str(supports_color()[0]), "GREEN")
 	log("[I] File to run at start:       " + settings.run_at_start, "GREEN")
 	log("[I] File to run at finish:      " + settings.run_at_finish, "GREEN")
 	log("", "GREEN")
@@ -359,8 +359,11 @@ def run():
 		log("[E] The following invalid argument(s) were provided: ", "RED") 
 		log('', "GREEN") 
 		log(' '.join(unknown), "YELLOW") 
-		log('', "GREEN") 
-		log("[I] \033[94mpyinstalive -h\033[92m can be used to display command help.", "GREEN")
+		log('', "GREEN")
+		if (supports_color()[1] == True):
+			log("[I] \033[94mpyinstalive -h\033[92m can be used to display command help.", "GREEN")
+		else:
+			log("[I] pyinstalive -h can be used to display command help.", "GREEN")
 		exit(1)
 
 	if (args.info) or (not

+ 4 - 4
pyinstalive/logger.py

@@ -40,11 +40,11 @@ def supports_color():
 	# isatty is not always implemented, #6223.
 	is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
 	if not supported_platform or not is_a_tty:
-		return "No"
-	return "Yes"
+		return "No", False
+	return "Yes", True
 
 def log(string, color):
-	if supports_color() == "No":
+	if supports_color()[1] == False:
 		print(string)
 	else:
 		print('\033[1m' + colors(color) + string + colors("ENDC"))
@@ -58,7 +58,7 @@ def log(string, color):
 	sys.stdout.flush()
 
 def seperator(color):
-	if supports_color() == "No":
+	if supports_color()[1] == False:
 		print(sep)
 	else:
 		print('\033[1m' + colors(color) + (sep) + colors("ENDC"))