2013-04-18 01:46:47 +02:00
|
|
|
#!/usr/bin/python
|
2013-04-24 12:50:14 +02:00
|
|
|
import os
|
|
|
|
import thread
|
|
|
|
import lutinMultiprocess
|
2013-04-24 21:30:46 +02:00
|
|
|
import threading
|
|
|
|
|
2013-04-18 01:46:47 +02:00
|
|
|
debugLevel=3
|
|
|
|
debugColor=False
|
|
|
|
|
2013-04-18 22:09:45 +02:00
|
|
|
color_default= ""
|
|
|
|
color_red = ""
|
|
|
|
color_green = ""
|
|
|
|
color_yellow = ""
|
|
|
|
color_blue = ""
|
|
|
|
color_purple = ""
|
|
|
|
color_cyan = ""
|
|
|
|
|
2013-04-24 21:30:46 +02:00
|
|
|
|
|
|
|
debugLock = threading.Lock()
|
|
|
|
|
2013-04-18 01:46:47 +02:00
|
|
|
def SetLevel(id):
|
|
|
|
global debugLevel
|
|
|
|
debugLevel = id
|
|
|
|
#print "SetDebug level at " + str(debugLevel)
|
|
|
|
|
|
|
|
def EnableColor():
|
|
|
|
global debugColor
|
|
|
|
debugColor = True
|
2013-04-18 22:09:45 +02:00
|
|
|
global color_default
|
|
|
|
color_default= "\033[00m"
|
|
|
|
global color_red
|
|
|
|
color_red = "\033[31m"
|
|
|
|
global color_green
|
|
|
|
color_green = "\033[32m"
|
|
|
|
global color_yellow
|
|
|
|
color_yellow = "\033[33m"
|
|
|
|
global color_blue
|
|
|
|
color_blue = "\033[34m"
|
|
|
|
global color_purple
|
|
|
|
color_purple = "\033[35m"
|
|
|
|
global color_cyan
|
|
|
|
color_cyan = "\033[36m"
|
2013-04-18 01:46:47 +02:00
|
|
|
|
|
|
|
def verbose(input):
|
2013-04-24 21:30:46 +02:00
|
|
|
global debugLock
|
|
|
|
global debugLevel
|
2013-04-18 01:46:47 +02:00
|
|
|
if debugLevel >= 5:
|
2013-04-24 21:30:46 +02:00
|
|
|
debugLock.acquire()
|
|
|
|
print(color_blue + input + color_default)
|
|
|
|
debugLock.release()
|
2013-04-18 01:46:47 +02:00
|
|
|
|
|
|
|
def debug(input):
|
2013-04-24 21:30:46 +02:00
|
|
|
global debugLock
|
|
|
|
global debugLevel
|
2013-04-18 01:46:47 +02:00
|
|
|
if debugLevel >= 4:
|
2013-04-24 21:30:46 +02:00
|
|
|
debugLock.acquire()
|
|
|
|
print(color_green + input + color_default)
|
|
|
|
debugLock.release()
|
2013-04-18 01:46:47 +02:00
|
|
|
|
|
|
|
def info(input):
|
2013-04-24 21:30:46 +02:00
|
|
|
global debugLock
|
|
|
|
global debugLevel
|
2013-04-18 01:46:47 +02:00
|
|
|
if debugLevel >= 3:
|
2013-04-24 21:30:46 +02:00
|
|
|
debugLock.acquire()
|
|
|
|
print(input + color_default)
|
|
|
|
debugLock.release()
|
2013-04-18 01:46:47 +02:00
|
|
|
|
|
|
|
def warning(input):
|
2013-04-24 21:30:46 +02:00
|
|
|
global debugLock
|
|
|
|
global debugLevel
|
2013-04-18 01:46:47 +02:00
|
|
|
if debugLevel >= 2:
|
2013-04-24 21:30:46 +02:00
|
|
|
debugLock.acquire()
|
|
|
|
print(color_purple + "[WARNING] " + input + color_default)
|
|
|
|
debugLock.release()
|
2013-04-18 01:46:47 +02:00
|
|
|
|
2013-05-08 12:17:45 +02:00
|
|
|
def error(input, threadID=-1):
|
2013-04-24 21:30:46 +02:00
|
|
|
global debugLock
|
|
|
|
global debugLevel
|
2013-04-18 01:46:47 +02:00
|
|
|
if debugLevel >= 1:
|
2013-04-24 21:30:46 +02:00
|
|
|
debugLock.acquire()
|
|
|
|
print(color_red + "[ERROR] " + input + color_default)
|
|
|
|
debugLock.release()
|
2013-04-24 12:50:14 +02:00
|
|
|
lutinMultiprocess.ErrorOccured()
|
2013-05-08 12:17:45 +02:00
|
|
|
if threadID != -1:
|
|
|
|
thread.interrupt_main()
|
2013-04-18 22:09:45 +02:00
|
|
|
exit(-1)
|
2013-04-24 12:50:14 +02:00
|
|
|
#os_exit(-1)
|
2013-04-18 22:09:45 +02:00
|
|
|
#raise "error happend"
|
2013-04-18 01:46:47 +02:00
|
|
|
|
2013-04-18 22:09:45 +02:00
|
|
|
def printElement(type, lib, dir, name):
|
2013-04-24 21:30:46 +02:00
|
|
|
global debugLock
|
|
|
|
global debugLevel
|
2013-04-18 22:09:45 +02:00
|
|
|
if debugLevel >= 3:
|
2013-04-24 21:30:46 +02:00
|
|
|
debugLock.acquire()
|
|
|
|
print(color_cyan + type + color_default + " : " + color_yellow + lib + color_default + " " + dir + " " + color_blue + name + color_default)
|
|
|
|
debugLock.release()
|
|
|
|
|
|
|
|
|