if __name__ == "__main__":
from src.salomeTools import Sat # it is time to do import
- _debug = False # Have to be False in production (for programmers DEBUG only)
- DBG.push_debug(_debug) # as __main__ with sys.exit so no need pop_debug
-
args = sys.argv[1:] # skip useless "sat'
sat = Sat(logger) # instantiate the salomeTools class
with traceback only if (_debug) or (DBG._user in DBG._developers)
"""
etype, value, tb = sys.exc_info()
- if _debug[-1] or isDeveloper():
- res = msg
- if tb:
- res += "\nTraceback (most recent call last):\n"
- res += "".join(traceback.format_tb(tb, limit)) # [:-1])
- res += "\n"
- res += "\n".join(traceback.format_exception_only(etype, value))
- return res
- else:
- res = msg
- res += "".join(traceback.format_exception_only(etype, value))
- return res
+ res = msg
+ if tb:
+ res += "\nTraceback (most recent call last):\n"
+ res += "".join(traceback.format_tb(tb, limit)) # [:-1])
+ res += "\n"
+ res += "\n".join(traceback.format_exception_only(etype, value))
+ return res
def format_color_exception(msg, limit=None, trace=None):
"""
def setInternals(self, opt=None, datadir=None):
"""set the commands by calling the dedicated function etc..."""
options, remaindersArgs = parser.parse_args(opt)
+ if options.debug_mode:
+ DBG.push_debug(True)
self.arguments = opt
self.options = options # the generic options passed to salomeTools
self.remaindersArgs = remaindersArgs # the command and their options
logger_command.write("\n" + DBG.format_exception("") + "\n", 1)
- """
- # have python 3 problems...
- # get stack
- __, __, exc_traceback = sys.exc_info()
- fp = tempfile.TemporaryFile(mode='wt')
- traceback.print_tb(exc_traceback, file=fp)
- fp.seek(0)
- stack = fp.read()
- verbosity = 5
- if self.options.debug_mode:
- verbosity = 1
- logger_command.write("TRACEBACK: %s" % stack.replace('"',"'"), verbosity)
- """
finally:
# set res if it is not set in the command