diff --git a/run.py b/run.py index fc46864..12a818d 100644 --- a/run.py +++ b/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 = {}