Beispiel #1
0
 def fill(self):
     super(HPage, self).fill()
     self.menubar[:] = html.ul(
         html.li(html.a("home", href="index.html", class_="menu")),
         html.li(html.a("install", href="install.html", class_="menu")),
         html.li(html.a("usage", href="usage.html", class_="menu")),
         id="menubar",
     )
Beispiel #2
0
def make_html_report(path, report):
    def tabelize(value):
        try:
            rows = []
            for key in value.keys():
                rows.append(html.tr(html.td(html.pre(key)), html.td(tabelize(value[key]))))
            return html.table(rows)
        except AttributeError:
            if type(value) == type([]):
                return html.table(map(tabelize, value))
            else:
                return html.pre(value)

    body_els = []
    keys = report.keys()
    keys.sort()
    links = []
    for key in keys:
        links.append(html.li(html.a(key, href="#" + key)))
    body_els.append(html.ul(links))
    for key in keys:
        body_els.append(html.a(html.h1(key), id=key))
        body_els.append(tabelize(report[key]))
    with open(path, 'w') as f:
        doc = html.html(html.head(html.style('table, td {border: 1px solid;}')), html.body(body_els))
        f.write(str(doc))
Beispiel #3
0
    def version_get(self, user, index, name, version):
        stage = self.getstage(user, index)
        name = ensure_unicode(name)
        version = ensure_unicode(version)
        metadata = stage.get_projectconfig(name)
        if not metadata:
            abort(404, "project %r does not exist" % name)
        verdata = metadata.get(version, None)
        if not verdata:
            abort(404, "version %r does not exist" % version)
        if json_preferred():
            apireturn(200, type="versiondata", result=verdata)

        # if html show description and metadata
        rows = []
        for key, value in sorted(verdata.items()):
            if key == "description":
                continue
            if isinstance(value, list):
                value = html.ul([html.li(x) for x in value])
            rows.append(html.tr(html.td(key), html.td(value)))
        title = "%s/: %s-%s metadata and description" % (
                stage.name, name, version)

        content = stage.get_description(name, version)
        #css = "https://pypi.python.org/styles/styles.css"
        return simple_html_body(title,
            [html.table(*rows), py.xml.raw(content)],
            extrahead=
            [html.link(media="screen", type="text/css",
                rel="stylesheet", title="text",
                href="https://pypi.python.org/styles/styles.css")]
        ).unicode(indent=2)
Beispiel #4
0
    def indexroot(self, user, index):
        stage = self.getstage(user, index)
        bases = html.ul()
        for base in stage.ixconfig["bases"]:
            bases.append(html.li(
                html.a("%s" % base, href="/%s/" % base),
                " (",
                html.a("simple", href="/%s/simple/" % base),
                " )",
            ))
        if bases:
            bases = [html.h2("inherited bases"), bases]

        return simple_html_body("%s index" % stage.name, [
            html.ul(
                html.li(html.a("simple index", href="simple/")),
            ),
            bases,
        ]).unicode()
Beispiel #5
0
def version_get(context, request):
    context = ContextWrapper(context)
    user, index = context.username, context.index
    name, version = context.name, context.version
    stage, verdata = context.stage, context.verdata
    infos = []
    skipped_keys = frozenset(
        ("description", "home_page", "name", "summary", "version"))
    for key, value in sorted(verdata.items()):
        if key in skipped_keys or key.startswith('+'):
            continue
        if isinstance(value, list):
            if not len(value):
                continue
            value = html.ul([html.li(x) for x in value]).unicode()
        else:
            if not value:
                continue
            value = py.xml.escape(value)
        infos.append((py.xml.escape(key), value))
    show_toxresults = not (user == 'root' and index == 'pypi')
    linkstore = stage.get_linkstore_perstage(name, version)
    files = get_files_info(request, linkstore, show_toxresults)
    docs = get_docs_info(request, stage, verdata)
    home_page = verdata.get("home_page")
    nav_links = []
    if docs:
        nav_links.append(dict(
            title="Documentation",
            url=docs['url']))
    if home_page:
        nav_links.append(dict(
            title="Homepage",
            url=home_page))
    nav_links.append(dict(
        title="Simple index",
        url=request.route_url(
            "/{user}/{index}/+simple/{name}",
            user=context.username, index=context.index, name=context.name)))
    return dict(
        title="%s/: %s-%s metadata and description" % (stage.name, name, version),
        content=get_description(stage, name, version),
        summary=verdata.get("summary"),
        nav_links=nav_links,
        infos=infos,
        files=files,
        show_toxresults=show_toxresults,
        make_toxresults_url=functools.partial(
            request.route_url, "toxresults",
            user=context.username, index=context.index,
            name=context.name, version=context.version),
        make_toxresult_url=functools.partial(
            request.route_url, "toxresult",
            user=context.username, index=context.index,
            name=context.name, version=context.version))
Beispiel #6
0
    def make_table_rows(self, results):
        rv = []
        for key in results.keys():
            result = results[key]['results']
            cells = [html.td(key, class_="col-subsuite")]
            if result.has_errors:
                cells.append(html.td(
                    len(result.errors),
                    class_="condition FAIL col-subsuite",
                ))
            else:
                cells.append(html.td("0",
                                     class_="condition PASS"))
            style = ''
            if result.has_fails or result.has_errors:
                style = 'background-color: darkblue;'
            if result.has_regressions:
                num_regressions = sum(len(item) for item in result.regressions.itervalues())
                cells.append(html.td(num_regressions, class_="condition PASS", style=style))
            else:
                cells.append(html.td("0", class_="condition PASS"))
            
            details_link = 'data:text/html;charset=utf-8;base64,%s' % base64.b64encode(results[key]['html_str'])
            ulbody = [html.li(html.a("subsuite report", href=details_link, target='_blank'))]
            files = results[key]['files']
            for fname in files.keys():
                href = '%s/%s' % (key, fname)
                #if key[-4:] == 'html' or key[-3:] == 'htm':
                #    href = 'data:text/html;charset=utf-8;base64,%s' % base64.b64encode(files[key])
                #else:
                #    href = 'data:text/plain;charset=utf-8;base64,%s' % base64.b64encode(files[key])
                ulbody.append(html.li(html.a(fname, href=href, target='_blank')))
            
            cells.append(html.td(html.ul(ulbody), class_="details"))
            rv.append(html.tr(cells, class_='results-table-row'))

        return rv
Beispiel #7
0
    def make_body(self):
        body_parts = [html.div(
             html.script(raw(pkg_resources.resource_string(
                rcname, os.path.sep.join(['resources', 'htmlreport', 
                    'jquery.js']))),
                type='text/javascript'),
            html.script(raw(pkg_resources.resource_string(
                rcname, os.path.sep.join(['resources', 'htmlreport', 
                    'main.js']))),
                type='text/javascript'),
            html.h1("FirefoxOS Certification Suite Report"),
            html.p("Run at %s" % self.time.strftime("%Y-%m-%d %H:%M:%S"))
            )]
        if self.logs:
            device_profile_object = None
            with open(self.logs[-1]) as f:
                device_profile_object = json.load(f)['result']['contact']
            device_profile = [html.h2('Device Information')]
            device_table = html.table()
            for key in device_profile_object:
                device_table.append(
                    html.tr(
                        html.td(key),
                        html.td(device_profile_object[key])
                    )
                )
                #device_profile.append(html.p("%s, %s"% (key, device_profile_object[key])))
            device_profile.append(device_table)
            body_parts.extend(device_profile);

        if self.summary_results.has_errors:
            body_parts.append(html.h2("Errors During Run"))
            body_parts.append(self.make_errors_table(self.summary_results.errors))
        body_parts.append(html.h2("Test Results"))
        body_parts.append(self.make_result_table())

        if self.logs:
            ulbody = [];
            for log_path in self.logs:
                details_log = ''
                with open(log_path, 'r') as f:
                    details_log = f.read()
                href = 'data:text/plain;charset=utf-8;base64,%s' % base64.b64encode(details_log)
                ulbody.append(html.li(html.a(os.path.basename(log_path), href=href, target='_blank')))
            device_profile_object = None
            body_parts.append(html.h2("Details log information"))
            body_parts.append(html.ul(ulbody))
        return html.body(body_parts)
Beispiel #8
0
 def startListItem(self, type, startlist):
     if startlist:
         nodename = type == 'o' and 'ol' or 'ul'
         self._push(getattr(html, nodename)())
     self._push(html.li())
Beispiel #9
0
    def indexroot(self, user, index):
        stage = self.getstage(user, index)
        if json_preferred():
            projectlist = stage.getprojectnames_perstage()
            projectlist = sorted(projectlist)
            apireturn(200, type="list:projectconfig", result=projectlist)
        if stage.name == "root/pypi":
            return simple_html_body("%s index" % stage.name, [
                html.ul(
                    html.li(html.a("simple index", href="+simple/")),
                ),
            ]).unicode()


        # XXX this should go to a template
        if hasattr(stage, "ixconfig"):
            bases = html.ul()
            for base in stage.ixconfig["bases"]:
                bases.append(html.li(
                    html.a("%s" % base, href="/%s/" % base),
                    " (",
                    html.a("simple", href="/%s/+simple/" % base),
                    " )",
                ))
            if bases:
                bases = [html.h2("inherited bases"), bases]
        else:
            bases = []
        latest_packages = html.table(
            html.tr(html.td("info"), html.td("file"), html.td("docs")))

        for projectname in stage.getprojectnames_perstage():
            metadata = stage.get_metadata_latest(projectname)
            try:
                name, ver = metadata["name"], metadata["version"]
            except KeyError:
                log.error("metadata for project %r empty: %s, skipping",
                          projectname, metadata)
                continue
            dockey = stage._doc_key(name, ver)
            if dockey.exists():
                docs = [html.a("%s-%s docs" %(name, ver),
                        href="%s/%s/+doc/index.html" %(name, ver))]
            else:
                docs = []
            files = metadata.get("+files", {})
            if not files:
                log.warn("project %r version %r has no files", projectname,
                         metadata.get("version"))
            baseurl = URL(request.path)
            for basename, relpath in files.items():
                latest_packages.append(html.tr(
                    html.td(html.a("%s-%s info page" % (name, ver),
                           href="%s/%s/" % (name, ver))),
                    html.td(html.a(basename,
                                   href=baseurl.relpath("/" + relpath))),
                    html.td(*docs),
                ))
                break  # could present more releasefiles

        latest_packages = [
            html.h2("in-stage latest packages, at least as recent as bases"),
            latest_packages]

        return simple_html_body("%s index" % stage.name, [
            html.ul(
                html.li(html.a("simple index", href="+simple/")),
            ),
            latest_packages,
            bases,
        ]).unicode()
Beispiel #10
0
def html_for_module(module):
    from py.xml import html
    out = file_for_module(module)
    ourlink = link_for_module('', module)
    head = [html.title(module.name)]
    body = [html.h1(module.name)]
    body.append(html.p('This module defines these names:'))
    listbody = []
    defuses = {}
    for d in module.definitions:
        uses = []
        for n in sorted(module.importers):
            N = module.system.modules[n]
            if N._imports[module.name].get(d) == True:
                uses.append(n)

        if not d.startswith('_'):
            if uses:
                listbody.append(html.li(
                    html.a(d, href=link_for_name(ourlink, module, d))))
                defuses[d] = uses
            else:
                listbody.append(html.li(d))

    body.append(html.ul(listbody))
    body.append(html.p('This module imports the following:'))
    listbody1 = []
    for n in sorted(module._imports):
        if n in ('autopath', '__future__'):
            continue
        if n in module.system.modules:
            listbody2 = [html.a(
                n, href=link_for_module(ourlink, module.system.modules[n]))]
        else:
            listbody2 = [n]
        listbody3 = []
        for o in sorted(module._imports[n]):
            if module._imports[n][o] == True:
                if n in module.system.modules:
                    listbody3.append(
                        html.li(html.a(
                        o, href=link_for_name(ourlink, module.system.modules[n], o))))
                else:
                    listbody3.append(html.li(o))
        if listbody3:
            listbody2.append(html.ul(listbody3))
        listbody1.append(html.li(listbody2))
    body.append(html.ul(listbody1))
    body.append(html.p('This module is imported by the following:'))
    listbody1 = []
    for n in module.importers:
        licontents = [html.a(n, href=link_for_module(ourlink, module.system.modules[n]))]
        contents = []
        for o in sorted(module.system.modules[n]._imports[module.name]):
            contents.append(html.li(html.a(o, href=link_for_name(ourlink, module, o))))
        if contents:
            licontents.append(html.ul(contents))
        listbody1.append(html.li(licontents))
    body.append(html.ul(listbody1))

    out.write(html.html(head, body).unicode())

    for d in defuses:
        out = file_for_name(module, d)
        ourlink = link_for_name('', module, d)
        head = [html.title(module.name + '.' + d)]
        body = [html.h1([html.a(module.name, href=link_for_module(ourlink, module)), '.' + d])]
        
        contents = []

        for n in defuses[d]: 
            N = module.system.modules[n]
            contents.append(html.li(html.a(n, href=link_for_module(ourlink, N))))

        body.append(html.p('This name is used in'))
        body.append(html.ul(contents))

        out.write(html.html(head, body).unicode())