Convert print to functional type call like Python 3. Perform error checking that requires Python >2.7 <3.0 for better error checking.

This commit is contained in:
Matt Guthaus
2017-06-12 15:02:48 -07:00
parent 6e90bf0d6d
commit 8a821e13ac
4 changed files with 30 additions and 32 deletions
+4 -4
View File
@@ -13,20 +13,20 @@ def check(check,str):
(frame, filename, line_number, function_name, lines,
index) = inspect.getouterframes(inspect.currentframe())[1]
if not check:
print "ERROR: file ", os.path.basename(filename), ": line ", line_number, ": ", str
print("ERROR: file {0}: line {1}: {2}".format(os.path.basename(filename),line_number,str))
sys.exit(-1)
def error(str,return_value=None):
(frame, filename, line_number, function_name, lines,
index) = inspect.getouterframes(inspect.currentframe())[1]
print "ERROR: file ", os.path.basename(filename), ": line ", line_number, ": ", str
print("ERROR: file {0}: line {1}: {2}".format(os.path.basename(filename),line_number,str))
if return_value:
sys.exit(return_value)
def warning(str):
(frame, filename, line_number, function_name, lines,
index) = inspect.getouterframes(inspect.currentframe())[1]
print "WARNING: file ", os.path.basename(filename), ": line ", line_number, ": ", str
print("WARNING: file {0}: line {1}: {2}".format(os.path.basename(filename),line_number,str))
def info(lev, str):
@@ -34,6 +34,6 @@ def info(lev, str):
if (OPTS.debug_level >= lev):
frm = inspect.stack()[1]
mod = inspect.getmodule(frm[0])
print "\n[", frm[0].f_code.co_name, "]: ", str
print("\n[{0}]: {1}".format(frm[0].f_code.co_name,str))
# This sometimes gets a NoneType mod...
# print "[" , mod.__name__ , "]: ", str