Salome HOME
be able to prepend an env value from APPLICATION.environ
[tools/sat.git] / commands / jobs.py
index 66392da96c7d89f4dc46961338ec96df933758a9..2b29f3aa11c5a5cb2702ce8fbbde21cfa3c6deb6 100644 (file)
@@ -26,7 +26,6 @@ import re
 import paramiko
 
 import src
-from _ast import Expression
 
 STYLESHEET_GLOBAL = "jobs_global_report.xsl"
 STYLESHEET_BOARD = "jobs_board_report.xsl"
@@ -37,7 +36,7 @@ CSV_DELIMITER = ";"
 parser = src.options.Options()
 
 parser.add_option('n', 'name', 'string', 'jobs_cfg', 
-                  _('The name of the config file that contains'
+                  _('Mandatory: The name of the config file that contains'
                   ' the jobs configuration'))
 parser.add_option('o', 'only_jobs', 'list2', 'only_jobs',
                   _('Optional: the list of jobs to launch, by their name. '))
@@ -54,7 +53,7 @@ parser.add_option('p', 'publish', 'boolean', 'publish',
 parser.add_option('i', 'input_boards', 'string', 'input_boards', _("Optional: "
                                 "the path to csv file that contain "
                                 "the expected boards."),"")
-parser.add_option('n', 'completion', 'boolean', 'no_label',
+parser.add_option('', 'completion', 'boolean', 'no_label',
                   _("Optional (internal use): do not print labels, Works only "
                     "with --list."),
                   False)
@@ -1058,14 +1057,17 @@ class Gui(object):
                                        self.global_name + ".xml")
         self.xml_global_file = src.xmlManager.XmlLogFile(xml_global_path,
                                                          "JobsReport")
+
+        # Find history for each job
+        self.history = {}
+        self.find_history(l_jobs, l_jobs_not_today)
+
         # The xml files that corresponds to the boards.
         # {name_board : xml_object}}
         self.d_xml_board_files = {}
+
         # Create the lines and columns
         self.initialize_boards(l_jobs, l_jobs_not_today)
-        # Find history for each job
-        self.history = {}
-        self.find_history(l_jobs, l_jobs_not_today)
         
         # Write the xml file
         self.update_xml_files(l_jobs)
@@ -1185,10 +1187,28 @@ class Gui(object):
             # that will not be launched today
             self.put_jobs_not_today(l_jobs_not_today, xml_jobs)
             
+            # add also the infos node
             xml_file.add_simple_node("infos",
                                      attrib={"name" : "last update",
                                              "JobsCommandStatus" : "running"})
-        
+            
+            # and put the history node
+            history_node = xml_file.add_simple_node("history")
+            name_board = os.path.basename(xml_file.logFile)[:-len(".xml")]
+            # serach for board files
+            expression = "^[0-9]{8}_+[0-9]{6}_" + name_board + ".xml$"
+            oExpr = re.compile(expression)
+            # Get the list of xml borad files that are in the log directory
+            for file_name in os.listdir(self.xml_dir_path):
+                if oExpr.search(file_name):
+                    date = os.path.basename(file_name).split("_")[0]
+                    file_path = os.path.join(self.xml_dir_path, file_name)
+                    src.xmlManager.add_simple_node(history_node,
+                                                   "link",
+                                                   text=file_path,
+                                                   attrib={"date" : date})      
+            
+                
         # Find in each board the squares that needs to be filled regarding the
         # input csv files but that are not covered by a today job
         for board in self.d_input_boards.keys():
@@ -1484,7 +1504,8 @@ class Gui(object):
 # Describes the command
 def description():
     return _("The jobs command launches maintenances that are described"
-             " in the dedicated jobs configuration file.")
+             " in the dedicated jobs configuration file.\n\nexample:\nsat "
+             "jobs --name my_jobs --publish")
 
 ##
 # Runs the command.