Salome HOME
sat job: when a command fail, display full stack
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Fri, 4 Nov 2016 09:36:15 +0000 (10:36 +0100)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Fri, 4 Nov 2016 09:36:15 +0000 (10:36 +0100)
commands/job.py
salomeTools.py

index da85234192958240896ef1f2cb28ce49e0a33ae6..ba7cd287992d64a611b81833f455e6af750f5696 100644 (file)
@@ -142,7 +142,7 @@ def run(args, runner, logger):
             # get stack
             __, __, exc_traceback = sys.exc_info()
             fp = tempfile.TemporaryFile()
-            traceback.print_tb(exc_traceback, limit=1, file=fp)
+            traceback.print_tb(exc_traceback, file=fp)
             fp.seek(0)
             stack = fp.read()
             
@@ -155,7 +155,8 @@ 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)
+            if len(stack) > 0:
+                logger.write('stack: %s\n' % stack, 3)
     
     # Print the final state
     if res == 0:
index 2cb9b8d3166e83c1e74d558eae700da3894b9c0f..5169f7a0324ff94cc81ab9362ad66ca08ea2341b 100755 (executable)
@@ -217,9 +217,9 @@ class Sat(object):
                 if logger_add_link:
                     micro_command = True
                 logger_command = src.logger.Logger(self.cfg, 
-                                                   silent_sysstd=silent,
-                                                   all_in_terminal=self.options.all_in_terminal,
-                                                   micro_command=micro_command)
+                                   silent_sysstd=silent,
+                                   all_in_terminal=self.options.all_in_terminal,
+                                   micro_command=micro_command)
                 
                 # Check that the path given by the logs_paths_in_file option
                 # is a file path that can be written
@@ -237,7 +237,9 @@ class Sat(object):
                     except Exception as e:
                         msg = _("WARNING: the logs_paths_in_file option will "
                                 "not be taken into account.\nHere is the error:")
-                        logger_command.write("%s\n%s\n\n" % (src.printcolors.printcWarning(msg), str(e)))
+                        logger_command.write("%s\n%s\n\n" % (
+                                             src.printcolors.printcWarning(msg),
+                                             str(e)))
                         self.options.logs_paths_in_file = None
                 
                 try:
@@ -303,6 +305,7 @@ class Sat(object):
                             file_res.write(filepath)
                             if i < len(logger_command.l_logFiles):
                                 file_res.write("\n")
+                                file_res.flush()
                 
                 return res