Ver código fonte

Don't polute output in Windows console with colours, which it doesn't support

Yentl Van Tendeloo 9 anos atrás
pai
commit
a3cc3ba6bf
1 arquivos alterados com 8 adições e 2 exclusões
  1. 8 2
      scripts/prompt.py

+ 8 - 2
scripts/prompt.py

@@ -5,10 +5,16 @@ import subprocess
 import os
 
 def local_print(string):
-    print("\033[92m%s\033[0m" % string)
+    if os.name == "posix":
+        # Nicer colour output when using posix (and thus supporting colour)
+        string = "\033[92m%s\033[0m" % string
+    print(string)
 
 def remote_print(string):
-    print("\033[94m%s\033[0m" % string)
+    if os.name == "posix":
+        # Nicer colour output when using posix (and thus supporting colour)
+        string = "\033[94m%s\033[0m" % string
+    print(string)
 
 local_print("Welcome to the local shell!")
 local_print("Please specify Modelverse location (default: localhost:8001)")