From f9f6b3e70f68fed49762105d9ff8526b2b12b67b Mon Sep 17 00:00:00 2001 From: Serge Rehbinder Date: Mon, 22 Feb 2016 09:39:36 +0100 Subject: [PATCH] 'sat log' : add option --last for terminal mode and add the corresponding test --- commands/log.py | 20 ++++++++++++-------- salomeTools.py | 2 +- test/log/launch_browser.py | 18 ++++++++++++++++++ 3 files changed, 31 insertions(+), 9 deletions(-) diff --git a/commands/log.py b/commands/log.py index 27a3694..bf37ac1 100644 --- a/commands/log.py +++ b/commands/log.py @@ -143,6 +143,18 @@ def run(args, runner, logger): if options.full: notShownCommands = [] + # If the last option is invoked, just, show the last log file + if options.last: + lastLogFilePath = get_last_log_file(logDir, notShownCommands) + if options.terminal: + # Show the log corresponding to the selected command call + print_log_command_in_terminal(lastLogFilePath, logger) + else: + # open the log xml file in the user editor + src.system.show_in_editor(runner.cfg.USER.browser, + lastLogFilePath, logger) + return 0 + # If the user asks for a terminal display if options.terminal: # Parse the log directory in order to find @@ -190,14 +202,6 @@ def run(args, runner, logger): shutil.copy2(xslHat, logDir) shutil.copy2(imgLogo, logDir) - # If the last option is invoked, just, show the last log file - if options.last: - lastLogFilePath = get_last_log_file(logDir, notShownCommands) - # open the log xml file in the user editor - src.system.show_in_editor(runner.cfg.USER.browser, - lastLogFilePath, logger) - return 0 - # Create or update the hat xml that gives access to all the commands log files xmlHatFilePath = os.path.join(logDir, 'hat.xml') src.logger.update_hat_xml(runner.cfg.SITE.log.logDir, diff --git a/salomeTools.py b/salomeTools.py index 57a0cfc..41d109c 100755 --- a/salomeTools.py +++ b/salomeTools.py @@ -219,7 +219,7 @@ class Sat(object): return # The hooks must be defined in the application pyconf in the - # APPLICATION section, hooks : { command : 'script_path.py'} + # APPLICATION section, hook : { command : 'script_path.py'} if "hook" not in self.cfg.APPLICATION \ or cmd_name not in self.cfg.APPLICATION.hook: return diff --git a/test/log/launch_browser.py b/test/log/launch_browser.py index 9a26384..8439ac3 100644 --- a/test/log/launch_browser.py +++ b/test/log/launch_browser.py @@ -223,6 +223,24 @@ class TestLog(unittest.TestCase): # pyunit method to compare 2 str self.assertEqual(OK, "OK") + def test_option_terminal7(self): + '''Test the terminal option and option last + ''' + + OK = "KO" + + # launch the command that will write a log + sat = Sat() + + try: + sat.log('--terminal --last') + OK = "OK" + finally: + sys.stdin = sys.__stdin__ + + # pyunit method to compare 2 str + self.assertEqual(OK, "OK") + def test_option_last(self): '''Test the option --last ''' -- 2.39.2