Generate HTML report.

        :return: Report body
        :rtype: str
506389
def format(self, result):
        
        css = "\n".join(self.css)
        content = "{}{}".format(self._header(), self._body(result))
        if self._email:
            text = """<!DOCTYPE html>
            <html>
            <div width="100%" style="{sty}">{content}</div>
            </html>
            """.format(css=css, content=content, sty=self.styles["content"]["_"])
        else:
            text = """<html>
            <head><style>{css}</style></head>
            <body>{content}</body>
            </html>
            """.format(css=css, content=content)
        return text
63071
def _print_html(self):
        
        cur_path = os.path.dirname(os.path.realpath(sys.argv[0]))
        shutil.copytree(cur_path+'webpage/template/', '')
606472
def create(self):
        
        logger.info("Generating the report from %s to %s", self.start, self.end)

        self.create_data_figs()
        self.create_pdf()

        logger.info("Report completed")
718468
def generate(self):
        
        exp_name = self.exp_name()

        fname = os.path.basename(self.out_path)
        fname = "{exp}_{prefix}_{name}{ending}".format(
            exp=exp_name,
            prefix=os.path.splitext(fname)[0],
            ending=os.path.splitext(fname)[-1],
            name="full")
        first = True
        for chunk in self.report():
            print("Writing chunk to :'{0}'".format(fname))
            chunk.to_csv(fname, header=first, mode='a')
            first = False
799119
def get_report(self):
        '''
        
        '''
        report_dict = self._meta_get_report()
        report = Report.from_dict(report_dict)
        return report
490404
def html(self, data=None, template=None):
        
        if data is None:
            data = {}
        if template:
            return render(self.request, template, data)
        return HttpResponse(data)
1315369
def to_html(self):
        
        row = '<tr%s>\n' % self.html_attributes()
        for cell in self.cells:
            row += cell.to_html()
        row += '</tr>\n'

        return row
67
def get_html_content(self):
        

        # Extract full element node content (including subelements)
        html_content = ''
        if hasattr(self, 'xml_element'):
            xml = self.xml_element
            content_list = ["" if xml.text is None else xml.text]

            def to_string(xml):
                if isinstance(xml, _Comment):
                    return str(xml)
                else:
                    return ElementTree.tostring(xml).decode('utf-8')

            content_list += [to_string(e) for e in xml.getchildren()]

            full_xml_content = "".join(content_list)

            # Parse tags to generate HTML valid content
            first_regex = r'html:'
            second_regex = r' xmlns:html=(["\'])(?:(?=(\\?))\2.)*?\1'
            html_content = re.sub(first_regex, '',
                                  re.sub(second_regex, '', full_xml_content))

        return html_content
941918
def to_xml(self):
        
        body = ''
        for k in ['warning', 'error', 'notice']:
            for msg in self.__dict__[k + 's']:
                body += '\n  <%s>%s</%s>' % (k, msg, k)
        return '<report valid="%s">%s\n</report>' % ("true" if self.is_valid else "false", body)
1027156
def descriptionHtml(self):
        
        if self.cls is None:
            return None
        elif hasattr(self.cls, 'descriptionHtml'):
            return self.cls.descriptionHtml()
        else:
            return ''
233960
def _header(self):
        
        html = """
		<!DOCTYPE html>
		<html lang="en">
		<head>
			<meta charset="utf-8">
			<title>Report</title>
		"""
        if "bokeh" in self.report_engines:
            html += self.bokeh_header_()
        if "altair" in self.report_engines:
            html += self.altair_header_()
        if "chartjs" in self.report_engines:
            html += self.chartjs_header_()
        html += """
		</head>
		<body>
		"""
        return html
120268
def pdfFromPOST(self):
        
        html = self.request.form.get('html')
        style = self.request.form.get('style')
        reporthtml = "<html><head>%s</head><body><div id='report'>%s</body></html>" % (style, html)
        return self.printFromHTML(safe_unicode(reporthtml).encode('utf-8'))
976198
def render_html_report(summary, report_template=None, report_dir=None):
    
    if not report_template:
        report_template = os.path.join(
            os.path.abspath(os.path.dirname(__file__)),
            "templates",
            "report_template.html"
        )
        logger.log_debug("No html report template specified, use default.")
    else:
        logger.log_info("render with html report template: {}".format(report_template))

    logger.log_info("Start to render Html report ...")

    report_dir = report_dir or os.path.join(os.getcwd(), "reports")
    if not os.path.isdir(report_dir):
        os.makedirs(report_dir)

    start_at_timestamp = int(summary["time"]["start_at"])
    summary["time"]["start_datetime"] = datetime.fromtimestamp(start_at_timestamp).strftime('%Y-%m-%d %H:%M:%S')

    report_path = os.path.join(report_dir, "{}.html".format(start_at_timestamp))

    with io.open(report_template, "r", encoding='utf-8') as fp_r:
        template_content = fp_r.read()
        with io.open(report_path, 'w', encoding='utf-8') as fp_w:
            rendered_content = Template(
                template_content,
                extensions=["jinja2.ext.loopcontrols"]
            ).render(summary)
            fp_w.write(rendered_content)

    logger.log_info("Generated Html report: {}".format(report_path))

    return report_path
365867
def get_body_text(self):
        
        if self.body_type != 'HTML':
            return self.body

        try:
            soup = bs(self.body, 'html.parser')
        except RuntimeError:
            return self.body
        else:
            return soup.body.text
1014220
def report(self):
        
        # make this prettier
        html = u'<hr/><a name="%s"></a>\n' % self.name()

        # Intro
        html = html + "<h2> Plugin <em>" + self.name() + "</em></h2>\n"

        # Files
        if len(self.copied_files):
            html = html + "<p>Files copied:<br><ul>\n"
            for afile in self.copied_files:
                html = html + '<li><a href="%s">%s</a>' % \
                    (u'..' + _to_u(afile['dstpath']), _to_u(afile['srcpath']))
                if afile['symlink'] == "yes":
                    html = html + " (symlink to %s)" % _to_u(afile['pointsto'])
                html = html + '</li>\n'
            html = html + "</ul></p>\n"

        # Command Output
        if len(self.executed_commands):
            html = html + "<p>Commands Executed:<br><ul>\n"
            # convert file name to relative path from our root
            # don't use relpath - these are HTML paths not OS paths.
            for cmd in self.executed_commands:
                if cmd["file"] and len(cmd["file"]):
                    cmd_rel_path = u"../" + _to_u(self.commons['cmddir']) \
                        + "/" + _to_u(cmd['file'])
                    html = html + '<li><a href="%s">%s</a></li>\n' % \
                        (cmd_rel_path, _to_u(cmd['exe']))
                else:
                    html = html + '<li>%s</li>\n' % (_to_u(cmd['exe']))
            html = html + "</ul></p>\n"

        # Alerts
        if len(self.alerts):
            html = html + "<p>Alerts:<br><ul>\n"
            for alert in self.alerts:
                html = html + '<li>%s</li>\n' % _to_u(alert)
            html = html + "</ul></p>\n"

        # Custom Text
        if self.custom_text != "":
            html = html + "<p>Additional Information:<br>\n"
            html = html + _to_u(self.custom_text) + "</p>\n"

        if six.PY2:
            return html.encode('utf8')
        else:
            return html
930795
def html_result(html: str,
                extraheaders: TYPE_WSGI_RESPONSE_HEADERS = None) \
        -> WSGI_TUPLE_TYPE:
    
    extraheaders = extraheaders or []
    return 'text/html; charset=utf-8', extraheaders, html.encode("utf-8")
1099621
def pdf_from_post(self):
        
        html = self.request.form.get("html")
        style = self.request.form.get("style")
        reporthtml = "<html><head>{0}</head><body>{1}</body></html>"
        reporthtml = reporthtml.format(style, html)
        reporthtml = safe_unicode(reporthtml).encode("utf-8")
        pdf_fn = tempfile.mktemp(suffix=".pdf")
        pdf_file = createPdf(htmlreport=reporthtml, outfile=pdf_fn)
        return pdf_file