aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/presentation/generator_report.py
diff options
context:
space:
mode:
authorTibor Frank <tifrank@cisco.com>2018-03-01 14:52:47 +0100
committerTibor Frank <tifrank@cisco.com>2018-03-21 15:43:10 +0000
commitefdcf6470f6e15dcc918c70e5a61d10e10653f1e (patch)
treeb2d5a5a2163b56d12f300c06119e925377674187 /resources/tools/presentation/generator_report.py
parent70068307d35abcd40abbcd9275bcb836d2cdbae6 (diff)
CSIT-913: Continuous Trending, Analysis and Change Detection
- CSIT-915: LLD - CSIT-917: Functions to evaluate the results according to the PASS / FAIL criteria - CSIT-918: Sphinx configuration - CSIT-948: Statistical functions - CSIT-949: Data models for trending plots - CSIT-950: Code trending plots - CSIT-951: Static content - CSIT-984: PAL Specification file - CSIT-996: Download data from nexus Change-Id: Icb9305945bb0f142135bb177cb8781ba0096280e Signed-off-by: Tibor Frank <tifrank@cisco.com>
Diffstat (limited to 'resources/tools/presentation/generator_report.py')
-rw-r--r--resources/tools/presentation/generator_report.py73
1 files changed, 6 insertions, 67 deletions
diff --git a/resources/tools/presentation/generator_report.py b/resources/tools/presentation/generator_report.py
index cf8a8d1675..55ac76bd1d 100644
--- a/resources/tools/presentation/generator_report.py
+++ b/resources/tools/presentation/generator_report.py
@@ -22,7 +22,7 @@ from os import makedirs, environ
from os.path import isdir
from shutil import copy, Error, make_archive
-from utils import get_files
+from utils import get_files, execute_command, archive_input_data
from errors import PresentationError
@@ -82,7 +82,7 @@ def generate_report(release, spec):
"pdf": generate_pdf_report
}
- for report_format, versions in spec.output.items():
+ for report_format, versions in spec.output["format"].items():
report[report_format](release, spec, versions)
archive_input_data(spec)
@@ -110,7 +110,7 @@ def generate_html_report(release, spec, versions):
date=datetime.date.today().strftime('%d-%b-%Y'),
working_dir=spec.environment["paths"]["DIR[WORKING,SRC]"],
build_dir=spec.environment["paths"]["DIR[BUILD,HTML]"])
- _execute_command(cmd)
+ execute_command(cmd)
with open(spec.environment["paths"]["DIR[CSS_PATCH_FILE]"], "w") as \
css_file:
@@ -146,7 +146,7 @@ def generate_pdf_report(release, spec, versions):
for plot in plots:
file_name = "{0}".format(plot.rsplit(".", 1)[0])
cmd = convert_plots.format(html=plot, pdf=file_name)
- _execute_command(cmd)
+ execute_command(cmd)
# Generate the LaTeX documentation
build_dir = spec.environment["paths"]["DIR[BUILD,LATEX]"]
@@ -155,7 +155,7 @@ def generate_pdf_report(release, spec, versions):
date=datetime.date.today().strftime('%d-%b-%Y'),
working_dir=spec.environment["paths"]["DIR[WORKING,SRC]"],
build_dir=build_dir)
- _execute_command(cmd)
+ execute_command(cmd)
# Build pdf documentation
archive_dir = spec.environment["paths"]["DIR[STATIC,ARCH]"]
@@ -174,7 +174,7 @@ def generate_pdf_report(release, spec, versions):
]
for cmd in cmds:
- _execute_command(cmd)
+ execute_command(cmd)
logging.info(" Done.")
@@ -193,64 +193,3 @@ def archive_report(spec):
base_dir=spec.environment["paths"]["DIR[BUILD,HTML]"])
logging.info(" Done.")
-
-
-def archive_input_data(spec):
- """Archive the report.
-
- :param spec: Specification read from the specification file.
- :type spec: Specification
- :raises PresentationError: If it is not possible to archive the input data.
- """
-
- logging.info(" Archiving the input data files ...")
-
- if spec.is_debug:
- extension = spec.debug["input-format"]
- else:
- extension = spec.input["file-format"]
- data_files = get_files(spec.environment["paths"]["DIR[WORKING,DATA]"],
- extension=extension)
- dst = spec.environment["paths"]["DIR[STATIC,ARCH]"]
- logging.info(" Destination: {0}".format(dst))
-
- try:
- if not isdir(dst):
- makedirs(dst)
-
- for data_file in data_files:
- logging.info(" Copying the file: {0} ...".format(data_file))
- copy(data_file, dst)
-
- except (Error, OSError) as err:
- raise PresentationError("Not possible to archive the input data.",
- str(err))
-
- logging.info(" Done.")
-
-
-def _execute_command(cmd):
- """Execute the command in a subprocess and log the stdout and stderr.
-
- :param cmd: Command to execute.
- :type cmd: str
- :returns: Return code of the executed command.
- :rtype: int
- """
-
- env = environ.copy()
- proc = subprocess.Popen(
- [cmd],
- stdout=subprocess.PIPE,
- stderr=subprocess.PIPE,
- shell=True,
- env=env)
-
- stdout, stderr = proc.communicate()
-
- logging.info(stdout)
- logging.info(stderr)
-
- if proc.returncode != 0:
- logging.error(" Command execution failed.")
- return proc.returncode