Merge "Add export functions to reporting"
authorMorgan Richomme <morgan.richomme@orange.com>
Tue, 11 Oct 2016 06:55:01 +0000 (06:55 +0000)
committerGerrit Code Review <gerrit@opnfv.org>
Tue, 11 Oct 2016 06:55:01 +0000 (06:55 +0000)
utils/test/reporting/css/default.css
utils/test/reporting/functest/reporting-status.py
utils/test/reporting/functest/template/index-status-tmpl.html

index a9fa69d..e32fa5f 100644 (file)
@@ -108,3 +108,87 @@ h2 {
   stroke: steelblue;
   stroke-width: 1.5px;
 }
+
+.myButtonPdf {
+       -moz-box-shadow:inset 0px 1px 0px 0px #f29c93;
+       -webkit-box-shadow:inset 0px 1px 0px 0px #f29c93;
+       box-shadow:inset 0px 1px 0px 0px #f29c93;
+       background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #fe1a00), color-stop(1, #ce0100));
+       background:-moz-linear-gradient(top, #fe1a00 5%, #ce0100 100%);
+       background:-webkit-linear-gradient(top, #fe1a00 5%, #ce0100 100%);
+       background:-o-linear-gradient(top, #fe1a00 5%, #ce0100 100%);
+       background:-ms-linear-gradient(top, #fe1a00 5%, #ce0100 100%);
+       background:linear-gradient(to bottom, #fe1a00 5%, #ce0100 100%);
+       filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#fe1a00', endColorstr='#ce0100',GradientType=0);
+       background-color:#fe1a00;
+       -moz-border-radius:6px;
+       -webkit-border-radius:6px;
+       border-radius:6px;
+       border:1px solid #d83526;
+       display:inline-block;
+       cursor:pointer;
+       color:#ffffff;
+       font-family:Arial;
+       font-size:15px;
+       font-weight:bold;
+       padding:6px 24px;
+       text-decoration:none;
+       text-shadow:0px 1px 0px #b23e35;
+}
+.myButtonPdf:hover {
+       background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ce0100), color-stop(1, #fe1a00));
+       background:-moz-linear-gradient(top, #ce0100 5%, #fe1a00 100%);
+       background:-webkit-linear-gradient(top, #ce0100 5%, #fe1a00 100%);
+       background:-o-linear-gradient(top, #ce0100 5%, #fe1a00 100%);
+       background:-ms-linear-gradient(top, #ce0100 5%, #fe1a00 100%);
+       background:linear-gradient(to bottom, #ce0100 5%, #fe1a00 100%);
+       filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ce0100', endColorstr='#fe1a00',GradientType=0);
+       background-color:#ce0100;
+}
+.myButtonPdf:active {
+       position:relative;
+       top:1px;
+}
+
+
+.myButtonCSV {
+       -moz-box-shadow:inset 0px 1px 0px 0px #bbdaf7;
+       -webkit-box-shadow:inset 0px 1px 0px 0px #bbdaf7;
+       box-shadow:inset 0px 1px 0px 0px #bbdaf7;
+       background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #79bbff), color-stop(1, #378de5));
+       background:-moz-linear-gradient(top, #79bbff 5%, #378de5 100%);
+       background:-webkit-linear-gradient(top, #79bbff 5%, #378de5 100%);
+       background:-o-linear-gradient(top, #79bbff 5%, #378de5 100%);
+       background:-ms-linear-gradient(top, #79bbff 5%, #378de5 100%);
+       background:linear-gradient(to bottom, #79bbff 5%, #378de5 100%);
+       filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#79bbff', endColorstr='#378de5',GradientType=0);
+       background-color:#79bbff;
+       -moz-border-radius:6px;
+       -webkit-border-radius:6px;
+       border-radius:6px;
+       border:1px solid #84bbf3;
+       display:inline-block;
+       cursor:pointer;
+       color:#ffffff;
+       font-family:Arial;
+       font-size:15px;
+       font-weight:bold;
+       padding:6px 24px;
+       text-decoration:none;
+       text-shadow:0px 1px 0px #528ecc;
+}
+.myButtonCSV:hover {
+       background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #378de5), color-stop(1, #79bbff));
+       background:-moz-linear-gradient(top, #378de5 5%, #79bbff 100%);
+       background:-webkit-linear-gradient(top, #378de5 5%, #79bbff 100%);
+       background:-o-linear-gradient(top, #378de5 5%, #79bbff 100%);
+       background:-ms-linear-gradient(top, #378de5 5%, #79bbff 100%);
+       background:linear-gradient(to bottom, #378de5 5%, #79bbff 100%);
+       filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#378de5', endColorstr='#79bbff',GradientType=0);
+       background-color:#378de5;
+}
+.myButtonCSV:active {
+       position:relative;
+       top:1px;
+}
+
index 9df6996..b527b78 100755 (executable)
@@ -8,6 +8,7 @@
 #
 import datetime
 import jinja2
+import pdfkit
 import requests
 import sys
 import time
@@ -186,8 +187,7 @@ for version in conf.versions:
             s_score = str(scenario_score) + "/" + str(scenario_criteria)
             s_score_percent = 0.0
             try:
-                s_score_percent = float(
-                scenario_score) / float(scenario_criteria) * 100
+                s_score_percent = float(scenario_score) / float(scenario_criteria) * 100
             except:
                 logger.error("cannot calculate the score percent")
 
@@ -200,7 +200,7 @@ for version in conf.versions:
                 logger.info(">>>>> scenario OK, save the information")
                 s_status = "OK"
                 path_validation_file = (conf.REPORTING_PATH +
-                                        "/release/" + version +
+                                        "/functest/release/" + version +
                                         "/validated_scenario_history.txt")
                 with open(path_validation_file, "a") as f:
                     time_format = "%Y-%m-%d %H:%M"
@@ -210,7 +210,7 @@ for version in conf.versions:
 
             # Save daily results in a file
             path_validation_file = (conf.REPORTING_PATH +
-                                    "/release/" + version +
+                                    "/functest/release/" + version +
                                     "/scenario_history.txt")
             with open(path_validation_file, "a") as f:
                 info = (reportingDate + "," + s + "," + installer +
@@ -228,7 +228,7 @@ for version in conf.versions:
         templateEnv = jinja2.Environment(
             loader=templateLoader, autoescape=True)
 
-        TEMPLATE_FILE = "/template/index-status-tmpl.html"
+        TEMPLATE_FILE = "/functest/template/index-status-tmpl.html"
         template = templateEnv.get_template(TEMPLATE_FILE)
 
         outputText = template.render(scenario_stats=scenario_stats,
@@ -239,6 +239,34 @@ for version in conf.versions:
                                      version=version,
                                      date=reportingDate)
 
-        with open(conf.REPORTING_PATH + "/release/" + version +
-                  "/index-status-" + installer + ".html", "wb") as fh:
-            fh.write(outputText)
+    with open(conf.REPORTING_PATH + "/functest/release/" + version +
+              "/index-status-" + installer + ".html", "wb") as fh:
+        fh.write(outputText)
+
+    # Generate outputs for export
+    # pdf
+    try:
+        pdf_path = ("http://testresults.opnfv.org/reporting/" +
+                    "functest/release/" + version +
+                    "/index-status-" + installer + ".html")
+        pdf_doc_name = (conf.REPORTING_PATH +
+                        "/functest/release/" + version +
+                        "/status-" + installer + ".pdf")
+        pdfkit.from_url(pdf_path, pdf_doc_name)
+    except IOError:
+        logger.info("pdf generated anyway...")
+    except:
+        logger.error("impossible to generate PDF")
+    # csv
+    # generate sub files based on scenario_history.txt
+    scenario_installer_file_name = (conf.REPORTING_PATH +
+                                    "/functest/release/" + version +
+                                    "/scenario_history_" +
+                                    installer + ".txt")
+    scenario_installer_file = open(scenario_installer_file_name, "w")
+    with open(path_validation_file, "r") as f:
+        for line in f:
+            if installer in line:
+                scenario_installer_file.write(line)
+    scenario_installer_file.close
index 2beb912..e3c9c5f 100644 (file)
@@ -148,6 +148,9 @@ $(document).ready(function (){
         </div>
         {%- endfor %}
     see <a href="https://wiki.opnfv.org/pages/viewpage.action?pageId=6828617">Functest scoring wiki page</a> for details on scenario scoring
+     <div> <br>
+    <a href="./status-{{installer}}.pdf" class="myButtonPdf">Export to PDF</a>   <a href="./scenario_history_{{installer}}.txt" class="myButtonCSV">Export to CSV</a>
+    </div>
     </div>
     <div class="col-md-1"></div>
 </div>