示例#1
0
def generate_cpta(spec, data):
    """Generate all formats and versions of the Continuous Performance Trending
    and Analysis.

    :param spec: Specification read from the specification file.
    :param data: Full data set.
    :type spec: Specification
    :type data: InputData
    """

    logging.info(u"Generating the Continuous Performance Trending and Analysis "
                 u"...")

    ret_code = _generate_all_charts(spec, data)

    cmd = HTML_BUILDER.format(
        date=datetime.utcnow().strftime(u'%Y-%m-%d %H:%M UTC'),
        working_dir=spec.environment[u'paths'][u'DIR[WORKING,SRC]'],
        build_dir=spec.environment[u'paths'][u'DIR[BUILD,HTML]'])
    execute_command(cmd)

    with open(spec.environment[u'paths'][u'DIR[CSS_PATCH_FILE]'], u'w') as \
            css_file:
        css_file.write(THEME_OVERRIDES)

    with open(spec.environment[u'paths'][u'DIR[CSS_PATCH_FILE2]'], u'w') as \
            css_file:
        css_file.write(THEME_OVERRIDES)

    if spec.configuration.get(u"archive-inputs", True):
        archive_input_data(spec)

    logging.info(u"Done.")

    return ret_code
示例#2
0
def _convert_all_svg_to_pdf(path):
    """Convert all svg files on path "path" to pdf.

    :param path: Path to the root directory with svg files to convert.
    :type path: str
    """

    svg_files = get_files(path, u"svg", full_path=True)
    for svg_file in svg_files:
        pdf_file = f"{svg_file.rsplit(u'.', 1)[0]}.pdf"
        logging.info(f"Converting {svg_file} to {pdf_file}")
        execute_command(
            f"inkscape -D -z --file={svg_file} --export-pdf={pdf_file}")
示例#3
0
def generate_pdf_report(release, spec, report_week):
    """Generate html format of the report.

    :param release: Release string of the product.
    :param spec: Specification read from the specification file.
    :param report_week: Calendar week when the report is published.
    :type release: str
    :type spec: Specification
    :type report_week: str
    """

    logging.info(u"  Generating the pdf report, give me a few minutes, please "
                 u"...")

    working_dir = spec.environment[u"paths"][u"DIR[WORKING,SRC]"]

    execute_command(f"cd {working_dir} && mv -f index.pdf.template index.rst")

    _convert_all_svg_to_pdf(spec.environment[u"paths"][u"DIR[WORKING,SRC]"])

    # Convert PyPLOT graphs in HTML format to PDF.
    convert_plots = u"xvfb-run -a wkhtmltopdf {html} {pdf}"
    plots = get_files(spec.environment[u"paths"][u"DIR[STATIC,VPP]"], u"html")
    plots.extend(
        get_files(spec.environment[u"paths"][u"DIR[STATIC,DPDK]"], u"html"))
    for plot in plots:
        file_name = f"{plot.rsplit(u'.', 1)[0]}.pdf"
        logging.info(f"Converting {plot} to {file_name}")
        execute_command(convert_plots.format(html=plot, pdf=file_name))

    # Generate the LaTeX documentation
    build_dir = spec.environment[u"paths"][u"DIR[BUILD,LATEX]"]
    cmd = PDF_BUILDER.format(
        release=release,
        date=datetime.datetime.utcnow().strftime(u'%Y-%m-%d %H:%M UTC'),
        working_dir=working_dir,
        build_dir=build_dir)
    execute_command(cmd)

    # Build pdf documentation
    archive_dir = spec.environment[u"paths"][u"DIR[STATIC,ARCH]"]
    cmds = [
        f'cd {build_dir} && '
        f'pdflatex -shell-escape -interaction nonstopmode csit.tex || true',
        f'cd {build_dir} && '
        f'pdflatex -interaction nonstopmode csit.tex || true',
        f'cd {build_dir} && '
        f'cp csit.pdf ../{archive_dir}/csit_{release}.{report_week}.pdf &&'
        f'cp csit.pdf ../{archive_dir}/csit_{release}.pdf'
    ]

    for cmd in cmds:
        execute_command(cmd)

    logging.info(u"  Done.")
示例#4
0
def generate_html_report(release, spec, report_version):
    """Generate html format of the report.

    :param release: Release string of the product.
    :param spec: Specification read from the specification file.
    :param report_version: Version of the report.
    :type release: str
    :type spec: Specification
    :type report_version: str
    """

    _ = report_version

    logging.info(
        u"  Generating the html report, give me a few minutes, please "
        u"...")

    working_dir = spec.environment[u"paths"][u"DIR[WORKING,SRC]"]

    execute_command(f"cd {working_dir} && mv -f index.html.template index.rst")

    cmd = HTML_BUILDER.format(
        release=release,
        date=datetime.datetime.utcnow().strftime(u'%Y-%m-%d %H:%M UTC'),
        working_dir=working_dir,
        build_dir=spec.environment[u"paths"][u"DIR[BUILD,HTML]"])
    execute_command(cmd)

    with open(spec.environment[u"paths"][u"DIR[CSS_PATCH_FILE]"], u"wt") as \
            css_file:
        css_file.write(THEME_OVERRIDES)

    with open(spec.environment[u"paths"][u"DIR[CSS_PATCH_FILE2]"], u"wt") as \
            css_file:
        css_file.write(THEME_OVERRIDES)

    logging.info(u"  Done.")