Make colorama optional
This commit is contained in:
parent
f7dcc8535c
commit
0cb75fd41f
43
run.py
43
run.py
@ -23,8 +23,51 @@ import api.opusnt as opusnt
|
|||||||
import json
|
import json
|
||||||
import subprocess
|
import subprocess
|
||||||
import winreg
|
import winreg
|
||||||
|
|
||||||
|
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
|
import colorama
|
||||||
colorama.init()
|
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"):
|
def runCode(str, lcs = False, description = "loose-code"):
|
||||||
if lcs == False: lcs = {}
|
if lcs == False: lcs = {}
|
||||||
|
Loading…
Reference in New Issue
Block a user