Salome HOME
print stack for everybody, activate debug mode when sat -g option is used
authorcrouzet <nicolas.crouzet@cea.fr>
Thu, 17 Jan 2019 09:39:58 +0000 (10:39 +0100)
committercrouzet <nicolas.crouzet@cea.fr>
Thu, 17 Jan 2019 09:39:58 +0000 (10:39 +0100)
sat
src/debug.py
src/salomeTools.py

diff --git a/sat b/sat
index 14b9a86120235243cee480d70a73aaaca6715115..7355399b3af6a433a2bd6b71e14806a44b9b0a18 100755 (executable)
--- a/sat
+++ b/sat
@@ -52,9 +52,6 @@ DBG.write("Python version", sys.version, DBG.isDeveloper())
 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
 
index 5b373aeafd7450d1217154d7ed869fe8bb4894f8..1b8cc470fbb343aca677fd6808f9a14d03863fbe 100755 (executable)
@@ -141,18 +141,13 @@ def format_exception(msg, limit=None, trace=None):
   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):
   """
index d74ad11122ef877b2bc00c7f5ba1666d166fa240..251d6ea730b715b9c4b9b6e1c41a72ba586cba1c 100755 (executable)
@@ -234,6 +234,8 @@ class Sat(object):
     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
@@ -487,19 +489,6 @@ class Sat(object):
 
                     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