Jelajahi Sumber

Zabawa z antem

Mariusz Muszyński 9 tahun lalu
induk
melakukan
9e5bb17197

+ 5 - 5
SE/schema/ant-url_action/procesy5_status/build.xml

@@ -26,7 +26,7 @@
         
         
       <exec executable="df" outputproperty="storage_free" >
-          <arg line=" -a /"/>
+          <arg line=" -mT hfs"/>
       </exec>
           
       
@@ -43,7 +43,7 @@
       
       <echo> storage_free ${loadfile} 
                 xml:
-                ${storage_free}}
+                ${storage_free}
         
       </echo>
       
@@ -71,10 +71,10 @@
           <classpath location="/opt/local/share/java/saxon9he.jar"/>
       </xslt>
       
+      <loadfile srcfile="${procesy5_status.xml}" property="result"/>
       
-      
-      <echo> RAPORT Z DZIALANIA </echo>
-      
+      <echo>RAPORT Z DZIALANIA:
+${result}</echo>
       
       
   </target>

+ 6 - 0
SE/schema/ant-url_action/procesy5_status/build_procesy5_status.html

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<storage_free.xml xmlns:raport="procesy5_raport">
+   <raport:df>
+      <hd0 raport:free="4292319944"/>
+   </raport:df>
+</storage_free.xml>

+ 2 - 0
SE/schema/ant-url_action/procesy5_status/empty.xml

@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<empty>empty</empty>

+ 11 - 0
SE/schema/ant-url_action/procesy5_status/out/procesy5_status.xml

@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<build_procesy5_status xmlns:raport="procesy5_raport">
+   <storage_free.xml>
+      <raport:df>
+         <disk Mountpoint="/dev/disk0s2">
+            <Capacity error="Zbyt duże wykorzystanie">92%</Capacity>
+            <Available>21048</Available>
+         </disk>
+      </raport:df>
+   </storage_free.xml>
+</build_procesy5_status>

+ 29 - 15
SE/schema/ant-url_action/procesy5_status/procesy5_status.xsl

@@ -12,7 +12,7 @@
     
     
     <xsl:variable name="raport:df_correct">
-        <hd0 raport:free="100"/>
+        <disk raport:max_capacity="90" raport:min_free="1000"/>
     </xsl:variable>
     
     
@@ -45,30 +45,44 @@
    
    
     
-    <xsl:template match="empty"/>
+ <!--   <xsl:template match="empty"/> -->
     
     
     
     <xsl:template match="*|text()" mode="df_output">
         <xsl:variable name="df_output">
             <df_output>
-                <xsl:for-each select="tokenize(normalize-space(.),' ')">
-                <el><xsl:attribute name="pos" select="position()"/>
-                    <xsl:value-of select="."/></el>
-            </xsl:for-each>
+                <xsl:for-each select="tokenize(.,'\n')">
+                    <xsl:if test="position() &gt; 1">
+                        <row><xsl:attribute name="pos" select="position()-1"/>
+                            <xsl:for-each select="tokenize(normalize-space(.),' ')">
+                                <el><xsl:attribute name="pos" select="position()"/>
+                                <xsl:value-of select="."/></el>
+                            </xsl:for-each>
+                        </row>
+                    </xsl:if>
+                </xsl:for-each>
             </df_output>
         </xsl:variable>
         
         <raport:df>
-            <hd0>
-                <xsl:attribute name="raport:free" select="$df_output//el[@pos='17']"/>
-                <xsl:if test="number($raport:df_correct/hd0/@raport:free) &gt; number($df_output//el[@pos='17'])  ">
-                    <xsl:attribute name="error" select="'blad za malo'"/>
-                </xsl:if>
-                <!--<xsl:processing-instruction name="php">
-                    echo "dupa";
-                </xsl:processing-instruction>-->
-            </hd0>
+            <xsl:for-each select="$df_output//row">
+                <disk>
+                    <xsl:attribute name="Mountpoint" select="el[@pos='1']"/>
+                    <xsl:element name="Capacity">
+                        <xsl:if test="number(replace(el[@pos='5'],'%','')) &gt; number($raport:df_correct/disk/@raport:max_capacity)">
+                            <xsl:attribute name="error" select="'Zbyt duże wykorzystanie'"/>
+                        </xsl:if>
+                        <xsl:value-of select="el[@pos='5']"/>
+                    </xsl:element>
+                    <xsl:element name="Available">
+                        <xsl:if test="number(el[@pos='4']) &lt; number($raport:df_correct/disk/@raport:min_free)">
+                            <xsl:attribute name="error" select="'Zbyt mało wolnego miejsca'"/>
+                        </xsl:if>
+                        <xsl:value-of select="el[@pos='4']"/>
+                    </xsl:element>
+                </disk>
+            </xsl:for-each>
         </raport:df>
         <!--<xsl:copy-of select="$df_output"/>-->
     </xsl:template>

+ 3 - 0
SE/schema/ant-url_action/procesy5_status/temp_procesy5_status/storage_free.xml

@@ -0,0 +1,3 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<storage_free.xml>Filesystem   1M-blocks   Used Available Capacity iused      ifree %iused  Mounted on
+/dev/disk0s2    238552 217254     21048    92% 2649581 4292317698    0%   /</storage_free.xml>