]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
'sat log' : add option --last for terminal mode and add the corresponding test
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Mon, 22 Feb 2016 08:39:36 +0000 (09:39 +0100)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Mon, 22 Feb 2016 08:39:36 +0000 (09:39 +0100)
commands/log.py
salomeTools.py
test/log/launch_browser.py

index 27a3694034d58c5de518756e40cf1e4f2af4e888..bf37ac17cde453a6b065366802e45635647a4baf 100644 (file)
@@ -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, 
index 57a0cfc104d55c6942a275446d47e2536042f168..41d109c366b79f6588bf4db7fc420e4b89b5c94a 100755 (executable)
@@ -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
index 9a26384a47d14813eb9ebefbd2bc30dfd2539c3b..8439ac3e9f12618c4ecca3d84ed9fd6b554ae985 100644 (file)
@@ -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
         '''