]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
sat job : get full stack ig one command fails
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Thu, 27 Oct 2016 12:22:18 +0000 (14:22 +0200)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Thu, 27 Oct 2016 12:22:18 +0000 (14:22 +0200)
commands/job.py

index 0b7ed6db0bd741c9455a2dc90cccdf299e0a2143..908aa9c5eb73b8a179df056a304e5c42a1ec78e1 100644 (file)
@@ -17,6 +17,9 @@
 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 
 import os
+import sys
+import traceback
+import tempfile
 
 import src
 
@@ -133,7 +136,15 @@ def run(args, runner, logger):
                                logger_add_link = logger)
         except Exception as e:
             code = 1
+            # Get error
             error = str(e)
+            # get stack
+            __, __, exc_traceback = sys.exc_info()
+            fp = tempfile.TemporaryFile()
+            traceback.print_tb(exc_traceback, limit=1, file=fp)
+            fp.seek(0)
+            stack = fp.read()
+            
 
         # Print the status of the command
         if code == 0:
@@ -143,6 +154,7 @@ def run(args, runner, logger):
             res = 1
             logger.write('%s %s\n' % (src.printcolors.printc(src.KO_STATUS),
                                       error), 3)
+            logger.write('stack: %s\n' % stack, 3)
     
     # Print the final state
     if res == 0: