2016-11-08 18:57:35 +01:00
|
|
|
import os
|
|
|
|
|
import inspect
|
|
|
|
|
import globals
|
|
|
|
|
import sys
|
|
|
|
|
|
|
|
|
|
# the debug levels:
|
|
|
|
|
# 0 = minimum output (default)
|
|
|
|
|
# 1 = major stages
|
|
|
|
|
# 2 = verbose
|
|
|
|
|
# n = custom setting
|
|
|
|
|
|
2017-05-12 23:56:31 +02:00
|
|
|
def check(check,str):
|
|
|
|
|
(frame, filename, line_number, function_name, lines,
|
|
|
|
|
index) = inspect.getouterframes(inspect.currentframe())[1]
|
|
|
|
|
if not check:
|
2017-06-13 00:02:48 +02:00
|
|
|
print("ERROR: file {0}: line {1}: {2}".format(os.path.basename(filename),line_number,str))
|
2018-01-31 20:48:41 +01:00
|
|
|
assert 0
|
2016-11-08 18:57:35 +01:00
|
|
|
|
2018-01-31 20:54:20 +01:00
|
|
|
def error(str,return_value=0):
|
2016-11-08 18:57:35 +01:00
|
|
|
(frame, filename, line_number, function_name, lines,
|
|
|
|
|
index) = inspect.getouterframes(inspect.currentframe())[1]
|
2017-06-13 00:02:48 +02:00
|
|
|
print("ERROR: file {0}: line {1}: {2}".format(os.path.basename(filename),line_number,str))
|
2018-01-31 20:48:41 +01:00
|
|
|
assert return_value==0
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
def warning(str):
|
|
|
|
|
(frame, filename, line_number, function_name, lines,
|
|
|
|
|
index) = inspect.getouterframes(inspect.currentframe())[1]
|
2017-06-13 00:02:48 +02:00
|
|
|
print("WARNING: file {0}: line {1}: {2}".format(os.path.basename(filename),line_number,str))
|
2016-11-08 18:57:35 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def info(lev, str):
|
2017-11-16 22:52:58 +01:00
|
|
|
from globals import OPTS
|
2016-11-08 18:57:35 +01:00
|
|
|
if (OPTS.debug_level >= lev):
|
|
|
|
|
frm = inspect.stack()[1]
|
|
|
|
|
mod = inspect.getmodule(frm[0])
|
2017-11-14 22:24:14 +01:00
|
|
|
#classname = frm.f_globals['__name__']
|
|
|
|
|
if mod.__name__ == None:
|
|
|
|
|
class_name=""
|
|
|
|
|
else:
|
|
|
|
|
class_name=mod.__name__
|
|
|
|
|
print("[{0}/{1}]: {2}".format(class_name,frm[0].f_code.co_name,str))
|