Salome HOME
jobs report: add the board history
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Fri, 7 Oct 2016 12:50:22 +0000 (14:50 +0200)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Fri, 7 Oct 2016 12:50:22 +0000 (14:50 +0200)
commands/jobs.py
src/xsl/jobs_board_report.xsl

index 9ac0b123cba22327787d14ab5e6ed89c8de129dd..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"
@@ -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():
index 1551fe1fe2fecb84546d72ae5796764084a9488b..e33abe42f2ddc03a0023219001a4e042211eeba3 100644 (file)
        legend
     </a>
     <br/>
+    <a href="#">
+       <xsl:attribute name="onclick">javascript:Toggle('history')</xsl:attribute>
+       <xsl:attribute name="title">history</xsl:attribute>
+       history
+    </a>
+    <br/>
     <br/>
     
     <div id="matrix">
            <tr>Extra job: <td> <xsl:attribute name="bgcolor">FFCCCC</xsl:attribute> Job name </td></tr>
        </td>
     </div>
+
+    <div style="display:none"><xsl:attribute name="id">history</xsl:attribute>
+      <xsl:for-each select="//JobsReport/history/link">
+       <xsl:sort select="@date" order="descending" />
+       <h4>
+         <a>
+           <xsl:attribute name="title">old board</xsl:attribute>
+           <xsl:attribute name="href"><xsl:value-of select="."/></xsl:attribute>
+           <xsl:value-of select="@date"/>
+         </a>
+       </h4>
+       <br/>
+      </xsl:for-each>
+    </div>
     
 </body>