From 1ccfc883b2336cedd917a695a820f440e29fd986 Mon Sep 17 00:00:00 2001 From: Serge Rehbinder Date: Fri, 4 Nov 2016 10:36:15 +0100 Subject: [PATCH] sat job: when a command fail, display full stack --- commands/job.py | 5 +++-- salomeTools.py | 11 +++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/commands/job.py b/commands/job.py index da85234..ba7cd28 100644 --- a/commands/job.py +++ b/commands/job.py @@ -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: diff --git a/salomeTools.py b/salomeTools.py index 2cb9b8d..5169f7a 100755 --- a/salomeTools.py +++ b/salomeTools.py @@ -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 -- 2.39.2