Salome HOME
sat jobs: add the jobs that will not be ran today in the xml matrix
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Thu, 16 Jun 2016 09:33:21 +0000 (11:33 +0200)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Thu, 16 Jun 2016 09:33:21 +0000 (11:33 +0200)
commands/jobs.py
src/xsl/job_report.xsl

index e9b8f50e09d5fe15c7f9f2f0dde57308812a47b4..5ad497df7d2deec265bc5f75db668cab22458012 100644 (file)
@@ -489,7 +489,9 @@ class Jobs(object):
         # can be several ssh parameters) 
         self.lhosts = []
         # The jobs to be launched today 
-        self.ljobs = []     
+        self.ljobs = []
+        # The jobs that will not be launched today
+        self.ljobsdef_not_today = []
         self.runner = runner
         self.logger = logger
         # The correlation dictionary between jobs and machines
@@ -611,6 +613,8 @@ class Jobs(object):
                 self.dic_job_machine[a_job] = a_machine
                 
                 self.ljobs.append(a_job)
+            else: # today in job_def.when
+                self.ljobsdef_not_today.append(job_def)
                                      
         self.lhosts = host_list
         
@@ -940,7 +944,7 @@ class Gui(object):
     
     """
     
-    def __init__(self, xml_file_path, l_jobs, stylesheet):
+    def __init__(self, xml_file_path, l_jobs, l_jobs_not_today, stylesheet):
         # The path of the xml file
         self.xml_file_path = xml_file_path
         # The stylesheet
@@ -948,22 +952,31 @@ class Gui(object):
         # Open the file in a writing stream
         self.xml_file = src.xmlManager.XmlLogFile(xml_file_path, "JobsReport")
         # Create the lines and columns
-        self.initialize_array(l_jobs)
+        self.initialize_array(l_jobs, l_jobs_not_today)
         # Write the wml file
         self.update_xml_file(l_jobs)
     
-    def initialize_array(self, l_jobs):
+    def initialize_array(self, l_jobs, l_jobs_not_today):
         l_dist = []
         l_applications = []
         for job in l_jobs:
             distrib = job.distribution
-            if distrib not in l_dist:
+            if distrib is not None and distrib not in l_dist:
                 l_dist.append(distrib)
             
             application = job.application
-            if application not in l_applications:
+            if application is not None and application not in l_applications:
                 l_applications.append(application)
-                    
+        
+        for job_def in l_jobs_not_today:
+            distrib = src.get_cfg_param(job_def, "distribution", "nothing")
+            if distrib is not "nothing" and distrib not in l_dist:
+                l_dist.append(distrib)
+                
+            application = src.get_cfg_param(job_def, "application", "nothing")
+            if application is not "nothing" and application not in l_applications:
+                l_applications.append(application)
+        
         self.l_dist = l_dist
         self.l_applications = l_applications
         
@@ -980,8 +993,19 @@ class Gui(object):
         # Initialize the jobs node
         self.xmljobs = self.xml_file.add_simple_node("jobs")
         
+        # 
+        self.put_jobs_not_today(l_jobs_not_today)
+        
         # Initialize the info node (when generated)
         self.xmlinfos = self.xml_file.add_simple_node("infos", attrib={"name" : "last update", "JobsCommandStatus" : "running"})
+    
+    def put_jobs_not_today(self, l_jobs_not_today):
+        for job_def in l_jobs_not_today:
+            xmlj = src.xmlManager.add_simple_node(self.xmljobs, "job", attrib={"name" : job_def.name})
+            src.xmlManager.add_simple_node(xmlj, "application", src.get_cfg_param(job_def, "application", "nothing"))
+            src.xmlManager.add_simple_node(xmlj, "distribution", src.get_cfg_param(job_def, "distribution", "nothing"))
+            src.xmlManager.add_simple_node(xmlj, "commands", " ; ".join(job_def.commands))
+            src.xmlManager.add_simple_node(xmlj, "state", "Not today")        
         
     def update_xml_file(self, l_jobs):      
         
@@ -1142,7 +1166,7 @@ def run(args, runner, logger):
     
     gui = None
     if options.publish:
-        gui = Gui("/export/home/serioja/LOGS/test.xml", today_jobs.ljobs, "job_report.xsl")
+        gui = Gui("/export/home/serioja/LOGS/test.xml", today_jobs.ljobs, today_jobs.ljobsdef_not_today, "job_report.xsl")
     
     today_jobs.gui = gui
     
index fc260b2975da5efea7e354e2401384d875d49488..9147912047e98b90187488ecfbcd775c32a21ab6 100644 (file)
@@ -41,6 +41,7 @@
     .KO2day       { color:#FF0000; font-weight: bold; }
     .KF2day       { color:#FF8000; font-weight: bold; }
     .NA2day       { color:#BBBBBB; font-weight: bold; }
+    .TO2day       { color:GoldenRod; font-weight: bold; }
 
     .new          { background-color:#FF5500; }
     .day          { background-color:#F0E25A; font-size: small; }
                              <a href="#">
                                    <xsl:attribute name="onclick">javascript:Toggle('<xsl:value-of select="@name"/>')</xsl:attribute>
                                    <xsl:attribute name="title"><xsl:value-of select="state/."/></xsl:attribute>
-                                   <xsl:attribute name="class">KO2</xsl:attribute>
+                                   <xsl:attribute name="class">KO2day</xsl:attribute>
                                    <xsl:value-of select="@name"/>
                              </a>
                            </xsl:when>
                              <a href="#">
                                    <xsl:attribute name="onclick">javascript:Toggle('<xsl:value-of select="@name"/>')</xsl:attribute>
                                    <xsl:attribute name="title"><xsl:value-of select="state/."/></xsl:attribute>
-                                   <xsl:attribute name="class">NA2</xsl:attribute>
+                                   <xsl:attribute name="class">NA2day</xsl:attribute>
                                    <xsl:value-of select="@name"/>
                              </a>
                            </xsl:when>
                              <a href="#">
                                    <xsl:attribute name="onclick">javascript:Toggle('<xsl:value-of select="@name"/>')</xsl:attribute>
                                    <xsl:attribute name="title"><xsl:value-of select="state/."/></xsl:attribute>
-                                   <xsl:attribute name="class">OK2</xsl:attribute>
+                                   <xsl:attribute name="class">OK2day</xsl:attribute>
                                    <xsl:value-of select="@name"/>
                              </a>
                            </xsl:when>
                              <a href="#">
                                    <xsl:attribute name="onclick">javascript:Toggle('<xsl:value-of select="@name"/>')</xsl:attribute>
                                    <xsl:attribute name="title"><xsl:value-of select="state/."/></xsl:attribute>
-                                   <xsl:attribute name="class">TO2</xsl:attribute>
+                                   <xsl:attribute name="class">TO2day</xsl:attribute>
+                                   <xsl:value-of select="@name"/>
+                             </a>
+                           </xsl:when>
+                           <xsl:when test="state/.='Not today'">
+                             <a href="#">
+                                   <xsl:attribute name="onclick">javascript:Toggle('<xsl:value-of select="@name"/>')</xsl:attribute>
+                                   <xsl:attribute name="title"><xsl:value-of select="state/."/></xsl:attribute>
+                                   <xsl:attribute name="class">NA2</xsl:attribute>
                                    <xsl:value-of select="@name"/>
                              </a>
                            </xsl:when>
                      </xsl:choose>
                      <!--<xsl:value-of select="state/." />-->
-                     <xsl:if test="not(remote_log_file_path/.='nothing')">
+                     <xsl:if test="not(remote_log_file_path/.='nothing') and state/.!='Not today'">
                             : 
                            <a>
                                <xsl:attribute name="title">remote log</xsl:attribute>
          <!-- Display job name -->
          <h4>Name : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/@name"/>
          <br/>
-         <!-- Display the job attributes -->
-         <h4>Hostname/port : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/host"/>/<xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/port"/>
-         <br/>
-         <h4>User : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/user"/>
-         <br/>
-         <h4>salomeTools path : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/sat_path"/>
-         <br/>
-         <h4>After : </h4>
-         <a href="#">
-               <xsl:attribute name="onclick">javascript:Toggle('<xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/after"/>')</xsl:attribute>
-               <xsl:attribute name="title">Click to get job information</xsl:attribute>
-               <xsl:attribute name="class">OK2</xsl:attribute>
-               <xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/after"/>
-         </a>
-         <br/>
-         <h4>Timeout : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/timeout"/>
-         <br/>
-         <h4>Begin : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/begin"/>
-         <br/>
-         <h4>End : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/end"/>
-         <br/>
+         <xsl:if test="//JobsReport/jobs/job[@name=$curr_job_name]/state!='Not today'">
+                 <!-- Display the job attributes -->
+                 <h4>Hostname/port : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/host"/>/<xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/port"/>
+                 <br/>
+                 <h4>User : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/user"/>
+                 <br/>
+                 <h4>salomeTools path : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/sat_path"/>
+                 <br/>
+                 <h4>After : </h4>
+                 <a href="#">
+                       <xsl:attribute name="onclick">javascript:Toggle('<xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/after"/>')</xsl:attribute>
+                       <xsl:attribute name="title">Click to get job information</xsl:attribute>
+                       <xsl:attribute name="class">OK2</xsl:attribute>
+                       <xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/after"/>
+                 </a>
+                 <br/>
+                 <h4>Timeout : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/timeout"/>
+                 <br/>
+                 <h4>Begin : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/begin"/>
+                 <br/>
+                 <h4>End : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/end"/>
+                 <br/>
+                 <h4>Out : </h4><PRE><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/out"/></PRE>
+                 <br/>
+                 <h4>Err : </h4><h_err><PRE><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/err"/></PRE></h_err>
+          </xsl:if>
          <h4>Status : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/state"/>
          <br/>
          <h4>Commands : </h4><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/commands"/>
          <br/>
-         <h4>Out : </h4><PRE><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/out"/></PRE>
-         <br/>
-         <h4>Err : </h4><h_err><PRE><xsl:value-of select="//JobsReport/jobs/job[@name=$curr_job_name]/err"/></PRE></h_err>
       </div>
     </xsl:for-each>