Make colorama optional
This commit is contained in:
parent
f7dcc8535c
commit
0cb75fd41f
47
run.py
47
run.py
@ -23,8 +23,51 @@ import api.opusnt as opusnt
|
||||
import json
|
||||
import subprocess
|
||||
import winreg
|
||||
import colorama
|
||||
colorama.init()
|
||||
|
||||
class coloramaFallback:
|
||||
class Fore:
|
||||
BLACK = ""
|
||||
RED = ""
|
||||
GREEN = ""
|
||||
YELLOW = ""
|
||||
BLUE = ""
|
||||
MAGENTA = ""
|
||||
CYAN = ""
|
||||
WHITE = ""
|
||||
RESET = ""
|
||||
|
||||
class Back:
|
||||
BLACK = ""
|
||||
RED = ""
|
||||
GREEN = ""
|
||||
YELLOW = ""
|
||||
BLUE = ""
|
||||
MAGENTA = ""
|
||||
CYAN = ""
|
||||
WHITE = ""
|
||||
RESET = ""
|
||||
|
||||
class Style:
|
||||
DIM = ""
|
||||
NORMAL = ""
|
||||
BRIGHT = ""
|
||||
RESET_ALL = ""
|
||||
|
||||
def coloramaInit():
|
||||
global colorama
|
||||
coloramaSuccess = False
|
||||
if not "-nocolor" in sys.argv:
|
||||
try:
|
||||
import colorama
|
||||
colorama.init()
|
||||
coloramaSuccess = True
|
||||
except Exception as e:
|
||||
print("Could not import/init colorama: " +str(e),file=sys.stderr)
|
||||
print("Colors deactivated.\n",file=sys.stderr)
|
||||
|
||||
if not coloramaSuccess:
|
||||
colorama = coloramaFallback
|
||||
coloramaInit()
|
||||
|
||||
def runCode(str, lcs = False, description = "loose-code"):
|
||||
if lcs == False: lcs = {}
|
||||
|
Loading…
Reference in New Issue
Block a user