예제 #1
0
    def _pageHeader(self):
        cssPath = CaduceusHelper.getHtmlPathToResource(self._reportPath, self._rootPath, "caduceus.css")
        logoPath = CaduceusHelper.getHtmlPathToResource(self._reportPath, self._rootPath, "caduceus-mini.png")

        img = ["success.png", "failure.png"][self._result.hasFailed()]
        resultImgPath = CaduceusHelper.getHtmlPathToResource(self._reportPath, self._rootPath, img)
        favicoPath = CaduceusHelper.getHtmlPathToResource(self._reportPath, self._rootPath, "favicon.ico")

        html = "<html>\n<head>\n"
        html += "    <meta http-equiv='Content-Type' content='Type=text/html; charset=utf-8'>"
        html += '    <link rel="stylesheet" href="%s" type="text/css" />\n' % cssPath
        html += '    <link rel="shortcut icon" href="%s">' % favicoPath
        html += '</head>\n<body class="caduceus">\n'
        html += ReportHtml._createTag(
            "div",
            [
                ReportHtml._createTag("img", None, {"src": resultImgPath, "class": "result"}),
                ReportHtml._createTag("h1", "Execution Report"),
                ReportHtml._createTag("img", None, {"src": logoPath, "class": "caduceus_logo"}),
                ReportHtml._createTag("br", None, {"style": "clear: both"}),
            ],
            {"class": "caduceus_report_head"},
        )
        html += '<div class="caduceus_report">\n'
        return html
예제 #2
0
    def render(self, dictGlob, dictLoc, results):
        if self._caduceusPath:
            # Template is document root (ie: not a partial)

            cssPath = CaduceusHelper.getHtmlPathToResource(self._path, self._rootPath, "caduceus.css")

            stylesheetToken = CaduceusTemplateHtmlTag(
                "link", [("rel", "stylesheet"), ("href", cssPath), ("type", "text/css")], True
            )

            if self._refHeadTag:
                # Insert Caduceus style sheet as first child
                self._refHeadTag.addTokenFirst(stylesheetToken)
            elif self._refHtmlTag:
                head = self._refHeadTag.addTokenFirst(CaduceusTemplateHtmlTag("head", []))
                head.addTokenFirst(stylesheetToken)

            return "<!-- Generated By Caduceus (%s) -->\n\n%s" % (
                strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()),
                CaduceusTemplateEntity.render(self, dictGlob, dictLoc, results),
            )
        else:
            # Template is a partial
            # Find head tag
            head = self.findFirstTag("head")
            if head:
                cssPath = CaduceusHelper.getHtmlPathToResource(self._path, self._rootPath, "caduceus.css")
                # print("#### css path %s / %s / %s" % (self._path, self._rootPath, cssPath))
                stylesheetToken = CaduceusTemplateHtmlTag(
                    "link", [("rel", "stylesheet"), ("href", cssPath), ("type", "text/css")], True
                )
                head.addTokenFirst(stylesheetToken)

                # return "<!-- Generated By Caduceus (%s) -->\n\n%s" % \
                # 		(	strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime()),
                # 			CaduceusTemplateEntity.render(self, dictGlob, dictLoc, results))

        return CaduceusTemplateEntity.render(self, dictGlob, dictLoc, results)