Salome HOME
Improve hat log
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Tue, 9 Feb 2016 13:05:08 +0000 (14:05 +0100)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Tue, 9 Feb 2016 13:05:08 +0000 (14:05 +0100)
commands/log.py
src/logger.py
src/xmlManager.py
src/xsl/hat.xsl

index fe1031e8f77ab3c7b83b81dc1d7d780881687f63..96fc057e1f5ab3a3d0198958f8cf8fd0bc44de81 100644 (file)
@@ -34,7 +34,10 @@ def run(args, runner):
     shutil.copy2(xslHat, logDir)
     shutil.copy2(imgLogo, logDir)
     
-    xmlHatFilePath = os.path.join(logDir, 'hat.xml')   
-    src.xmlManager.update_hat_xml(logDir)
+    xmlHatFilePath = os.path.join(logDir, 'hat.xml')
+    if 'APPLICATION' in runner.cfg:
+        src.xmlManager.update_hat_xml(runner.cfg.VARS.logDir, runner.cfg.VARS.application)
+    else:
+        src.xmlManager.update_hat_xml(runner.cfg.VARS.logDir)
     
     src.system.show_in_editor(runner.cfg.USER.browser, xmlHatFilePath)
\ No newline at end of file
index a624600ccbc1737e0f332938d87e1e4b1c788412..5c821e67e64e5dc8c601a7f53a04733888ec2793 100644 (file)
@@ -118,7 +118,10 @@ class Logger(object):
         self.xmlFile.add_simple_node("field", text=endtime , attrib={"name" : "endTime"})
         self.xmlFile.add_simple_node("field", text="%ih%im%is" % (hours, minutes, seconds) , attrib={"name" : "Total Time"})
         self.xmlFile.write_tree(stylesheet = "command.xsl")
-        src.xmlManager.update_hat_xml(self.config.VARS.logDir)
+        if 'APPLICATION' in self.config:
+            src.xmlManager.update_hat_xml(self.config.VARS.logDir, self.config.VARS.application)
+        else:
+            src.xmlManager.update_hat_xml(self.config.VARS.logDir)
 
 def date_to_datetime(date):
     Y = int(date[:4])
index 87cdeb43e287386201feceb008173af7ab910e0e..f5c3b097d76af2a7109736f6361c1345e03a4a83 100644 (file)
@@ -49,9 +49,12 @@ class xmlLogFile(object):
             if field.tag == node_name:
                 field.text += text
                 
-def update_hat_xml(logDir):
+def update_hat_xml(logDir, application=None):
     xmlHatFilePath = os.path.join(logDir, 'hat.xml')
-    xmlHat = xmlLogFile(xmlHatFilePath,  "LOGlist")
+    if application:
+        xmlHat = xmlLogFile(xmlHatFilePath,  "LOGlist", {"application" : application})
+    else:
+        xmlHat = xmlLogFile(xmlHatFilePath,  "LOGlist", {"application" : "NO"})
           
     for fileName in os.listdir(logDir):
         sExpr = "^[0-9]{8}_+[0-9]{6}_+[A-Za-z0-9]*.xml$"
index c532309ca7b6ba130fca557965eac06c18a8cf84..7fea5507bc49bdfacc2f565ed388bbae69435dc9 100644 (file)
 </head>
        <body class="def" bgcolor="aliceblue">
                <h1><img src="LOGO-SAT.png"/></h1>
+                       <xsl:choose>
+                         <xsl:when test="LOGlist/@application='NO'">
+                                 <h1>Logs of commands without application</h1>
+                         </xsl:when>
+                         <xsl:otherwise>
+                                 <h1>
+                                         Logs of application <xsl:value-of select="LOGlist/@application"/>
+                                 </h1>
+                         </xsl:otherwise>
+                       </xsl:choose>
                        <table border="0">
                                <tr>
                                <td width="100px">Command</td><td width="100px">date</td><td>time</td>