From 0b53361e612208519774de9535814b1fa8053d7f Mon Sep 17 00:00:00 2001 From: clamsawd Date: Sat, 31 Oct 2015 21:31:52 +0100 Subject: [PATCH] Errors handling when importing native color scheme --- ip2e-daemon.py | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/ip2e-daemon.py b/ip2e-daemon.py index c27b9ce..96a0466 100755 --- a/ip2e-daemon.py +++ b/ip2e-daemon.py @@ -93,24 +93,27 @@ else: exec(open("ip2e-conf.py").read()) #Import native OS color scheme -def GreenColor(): - if os.name == "posix": - GreenColor = (chr(27)+"[1;32m") - print (GreenColor+"", end="") - elif os.name == "nt": - os.system("color 2") -def RedColor(): - if os.name == "posix": - RedColor = (chr(27)+"[1;31m") - print (RedColor+"", end="") - elif os.name == "nt": - os.system("color 4") -def OrangeColor(): - if os.name == "posix": - OrangeColor = (chr(27)+"[1;33m") - print (OrangeColor+"", end="") - elif os.name == "nt": - os.system("color 6") +try: + def GreenColor(): + if os.name == "posix": + GreenColor = (chr(27)+"[1;32m") + print (GreenColor+"", end="") + elif os.name == "nt": + os.system("color 2") + def RedColor(): + if os.name == "posix": + RedColor = (chr(27)+"[1;31m") + print (RedColor+"", end="") + elif os.name == "nt": + os.system("color 4") + def OrangeColor(): + if os.name == "posix": + OrangeColor = (chr(27)+"[1;33m") + print (OrangeColor+"", end="") + elif os.name == "nt": + os.system("color 6") +except: + print ("Error importing native color scheme") #Check if exists a previous log.file. if os.path.isfile("ip2e.log"):