def format_revlist(revlist, name=None):
    table = tags.table(class_='inner')
    if name:
        table(tags.thead(tags.tr(tags.th(name, colspan="2"))))
    revs = tags.tbody()
    table(revs)
    for rev, revno in revlist:
        r = tags.tr()
        r(tags.td(str(revno)))
        r(tags.td(rev.message.splitlines()[0][:100], style="text-align: left"))
        revs(r)
    return table
def format_revlist(revlist, name=None):
    table = tags.table(class_='inner')
    if name:
        table(tags.thead(tags.tr(tags.th(name, colspan="2"))))
    revs = tags.tbody()
    table(revs)
    for rev, revno in revlist:
        r = tags.tr()
        r(tags.td(str(revno)))
        r(tags.td(rev.message.splitlines()[0][:100],
                  style="text-align: left"))
        revs(r)
    return table
Exemplo n.º 3
0
    def incidents_as_rows(incidents):
        attrs_incident = {"class": "incident"}
        attrs_number = {"class": "incident_number"}
        attrs_priority = {"class": "incident_priority"}
        attrs_rangers = {"class": "incident_rangers"}
        attrs_location = {"class": "incident_location"}
        attrs_types = {"class": "incident_types"}
        attrs_summary  = {"class": "incident_summary"}

        yield tags.thead(
            tags.tr(
                tags.th(u"#", **attrs_number),
                tags.th(u"Priority", **attrs_priority),
                tags.th(u"Rangers", **attrs_rangers),
                tags.th(u"Location", **attrs_location),
                tags.th(u"Types", **attrs_types),
                tags.th(u"Summary", **attrs_summary),
                **attrs_incident
            ),
            **attrs_activity
        )

        yield tags.tbody(
            tags.tr(
                tags.td(
                    u"{0}".format(incident.number), **attrs_number
                ),
                tags.td(
                    u"{0}".format(incident.priority), **attrs_priority
                ),
                tags.td(u"{0}".format(
                    u", ".join(ranger.handle for ranger in incident.rangers)
                ), **attrs_rangers),
                tags.td(u"{0}".format(
                    str(incident.location).decode("utf-8")
                ), **attrs_location),
                tags.td(u"{0}".format(
                    u", ".join(incident.incident_types)
                ), **attrs_types),
                tags.td(u"{0}".format(
                    incident.summaryFromReport()
                ), **attrs_summary),
                onclick=(
                    'window.open("/queue/incidents/{0}");'
                    .format(incident.number)
                ),
                **attrs_incident
            )
            for incident in sorted(incidents)
        )
def make_html(components, instances):
    table = tags.table(class_='main')
    heading_row = tags.tr()
    for heading in  'component', 'tip revno', 'unreleased revisions', 'latest release':
        heading_row(tags.th(heading))
    for instance_name in sorted(instances):
        heading_row(tags.th(instance_name, class_="instance-name"))
    table(tags.thead(heading_row))
    tbody = tags.tbody()
    for name, component in sorted(components.items()):
        row = tags.tr(class_="component")
        revs_between_ids = {}
        extra_rows = []
        def td(*args, **kwargs):
            row(tags.td(*args, **kwargs))
        td(name)
        td(str(component.tip_revno), class_='version')
        unreleased_count = len(component.unreleased_revisions)
        if unreleased_count:
            id_ = get_id()
            td(
                tags.a(str(unreleased_count), href='#', class_='highlight'),
                class_='version clickable', id=id_)
            sub_name = 'revs between %s (r%s) and tip (r%s)' % (
                component.last_release, component.released_revno,
                component.tip_revno)
            extra_rows.append(
                tags.tr(
                    tags.td(
                        format_revlist(component.unreleased_revisions, name=sub_name),
                        colspan=str(4 + len(instances))),
                    class_='hidden',
                    id="show-" + id_))
        elif not component.last_release:
            td(u'\N{EM DASH}', class_='version')
        else:
            td(str(unreleased_count), class_='version')
        if component.last_release:
            td(component.last_release, class_='version')
        else:
            td(u'???', class_='version')
        for instance_name, instance in sorted(instances.items()):
            ver, location = instance.get(name, (None, None))
            if ver is None:
                td(u'\N{EM DASH}', class_='version')
            elif ver == component.last_release:
                td(ver, class_='version')
            elif ver in component.release2revno:
                revno_low = component.release2revno[ver]
                sub_name = 'revs between %s (r%s) and %s (r%s)' % (
                    ver, revno_low,
                    component.last_release, component.released_revno)
                revlist = []
                for rev, revno in component.mainline_revs:
                    if revno_low < revno < component.released_revno:
                        revlist.append((rev, revno))
                if revlist:
                    id_ = get_id()
                    revs_between_ids[revno_low] = id_
                    extra_rows.append(
                        tags.tr(
                            tags.td(
                                format_revlist(revlist, name=sub_name),
                                colspan=str(4 + len(instances))),
                            class_='hidden branch-diff',
                            id="show-" + id_))
                    td(
                        tags.a(ver, href='#', class_='highlight'),
                        class_='version clickable', id=id_)
                else:
                    td(tags.span(ver, class_='highlight'), class_='version')
            elif location:
                try:
                    branch = bzrlib.branch.Branch.open(location)
                except bzrlib.errors.NoSuchBranch:
                    td(tags.span(ver, class_='highlight'), class_='version')
                else:
                    branch.lock_read()
                    try:
                        # This utterly half-assed version of bzr missing
                        # doesn't take merges into account!
                        revno, revid = branch.last_revision_info()
                        ver = ver.split('dev')[0] + 'dev' + str(revno)
                        mainline_revids = dict(
                            (rev.revision_id, revno)
                            for rev, revno in component.mainline_revs)
                        in_branch_revs = []
                        while revid not in mainline_revids:
                            rev = branch.repository.get_revision(revid)
                            if rev.message != 'post release bump':
                                in_branch_revs.append((rev, revno))
                            revno -= 1
                            if not rev.parent_ids:
                                break
                            revid = rev.parent_ids[0]
                        tables = []
                        if in_branch_revs:
                            tables.append(
                                format_revlist(
                                    in_branch_revs,
                                    'in branch (with nick %s) but not tip' % branch.nick))
                        in_trunk_revs = []
                        lca_revno = revno
                        for rev, revno in component.mainline_revs:
                            if revno > lca_revno:
                                in_trunk_revs.append((rev, revno))
                        if in_trunk_revs:
                            tables.append(
                                format_revlist(
                                    in_trunk_revs,
                                    'in tip but not branch'))
                        if tables:
                            id_ = get_id()
                            td(
                                tags.a(ver, href='#', class_='highlight'),
                                class_='version clickable', id=id_)
                            extra_rows.append(
                                tags.tr(
                                    tags.td(
                                        tables,
                                        colspan=str(4 + len(instances))),
                                    class_='hidden branch-diff',
                                    id="show-" + id_))
                        else:
                            if branch.last_revision() == component.tip_revno:
                                td(ver, class_='highlight version')
                            else:
                                td(ver, class_='version')
                    finally:
                        branch.unlock()
            else:
                td(tags.span(ver, class_='highlight'), class_='version')
        tbody(row, *extra_rows)
    table(tbody)
    html = tags.html(
        tags.head(
            tags.title("Deployment report"),
            tags.script(
                src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',
                type='text/javascript'),
            tags.script(
                src='https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js',
                type='text/javascript'),
            tags.script(CDATA(js), type='text/javascript'),
            tags.style(CDATA(css), type="text/css"),
            ),
        tags.body(
            tags.h1("Deployment report"),
            table,
            ),
        )
    html(xmlns="http://www.w3.org/1999/xhtml")
    return DOCTYPE + flatten(html)
def make_html(components, instances):
    table = tags.table(class_='main')
    heading_row = tags.tr()
    for heading in 'component', 'tip revno', 'unreleased revisions', 'latest release':
        heading_row(tags.th(heading))
    for instance_name in sorted(instances):
        heading_row(tags.th(instance_name, class_="instance-name"))
    table(tags.thead(heading_row))
    tbody = tags.tbody()
    for name, component in sorted(components.items()):
        row = tags.tr(class_="component")
        revs_between_ids = {}
        extra_rows = []

        def td(*args, **kwargs):
            row(tags.td(*args, **kwargs))

        td(name)
        td(str(component.tip_revno), class_='version')
        unreleased_count = len(component.unreleased_revisions)
        if unreleased_count:
            id_ = get_id()
            td(tags.a(str(unreleased_count), href='#', class_='highlight'),
               class_='version clickable',
               id=id_)
            sub_name = 'revs between %s (r%s) and tip (r%s)' % (
                component.last_release, component.released_revno,
                component.tip_revno)
            extra_rows.append(
                tags.tr(tags.td(format_revlist(component.unreleased_revisions,
                                               name=sub_name),
                                colspan=str(4 + len(instances))),
                        class_='hidden',
                        id="show-" + id_))
        elif not component.last_release:
            td(u'\N{EM DASH}', class_='version')
        else:
            td(str(unreleased_count), class_='version')
        if component.last_release:
            td(component.last_release, class_='version')
        else:
            td(u'???', class_='version')
        for instance_name, instance in sorted(instances.items()):
            ver, location = instance.get(name, (None, None))
            if ver is None:
                td(u'\N{EM DASH}', class_='version')
            elif ver == component.last_release:
                td(ver, class_='version')
            elif ver in component.release2revno:
                revno_low = component.release2revno[ver]
                sub_name = 'revs between %s (r%s) and %s (r%s)' % (
                    ver, revno_low, component.last_release,
                    component.released_revno)
                revlist = []
                for rev, revno in component.mainline_revs:
                    if revno_low < revno < component.released_revno:
                        revlist.append((rev, revno))
                if revlist:
                    id_ = get_id()
                    revs_between_ids[revno_low] = id_
                    extra_rows.append(
                        tags.tr(tags.td(format_revlist(revlist, name=sub_name),
                                        colspan=str(4 + len(instances))),
                                class_='hidden branch-diff',
                                id="show-" + id_))
                    td(tags.a(ver, href='#', class_='highlight'),
                       class_='version clickable',
                       id=id_)
                else:
                    td(tags.span(ver, class_='highlight'), class_='version')
            elif location:
                try:
                    branch = bzrlib.branch.Branch.open(location)
                except bzrlib.errors.NoSuchBranch:
                    td(tags.span(ver, class_='highlight'), class_='version')
                else:
                    branch.lock_read()
                    try:
                        # This utterly half-assed version of bzr missing
                        # doesn't take merges into account!
                        revno, revid = branch.last_revision_info()
                        ver = ver.split('dev')[0] + 'dev' + str(revno)
                        mainline_revids = dict(
                            (rev.revision_id, revno)
                            for rev, revno in component.mainline_revs)
                        in_branch_revs = []
                        while revid not in mainline_revids:
                            rev = branch.repository.get_revision(revid)
                            if rev.message != 'post release bump':
                                in_branch_revs.append((rev, revno))
                            revno -= 1
                            if not rev.parent_ids:
                                break
                            revid = rev.parent_ids[0]
                        tables = []
                        if in_branch_revs:
                            tables.append(
                                format_revlist(
                                    in_branch_revs,
                                    'in branch (with nick %s) but not tip' %
                                    branch.nick))
                        in_trunk_revs = []
                        lca_revno = revno
                        for rev, revno in component.mainline_revs:
                            if revno > lca_revno:
                                in_trunk_revs.append((rev, revno))
                        if in_trunk_revs:
                            tables.append(
                                format_revlist(in_trunk_revs,
                                               'in tip but not branch'))
                        if tables:
                            id_ = get_id()
                            td(tags.a(ver, href='#', class_='highlight'),
                               class_='version clickable',
                               id=id_)
                            extra_rows.append(
                                tags.tr(tags.td(tables,
                                                colspan=str(4 +
                                                            len(instances))),
                                        class_='hidden branch-diff',
                                        id="show-" + id_))
                        else:
                            if branch.last_revision() == component.tip_revno:
                                td(ver, class_='highlight version')
                            else:
                                td(ver, class_='version')
                    finally:
                        branch.unlock()
            else:
                td(tags.span(ver, class_='highlight'), class_='version')
        tbody(row, *extra_rows)
    table(tbody)
    html = tags.html(
        tags.head(
            tags.title("Deployment report"),
            tags.script(
                src=
                'https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js',
                type='text/javascript'),
            tags.script(
                src=
                'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.18/jquery-ui.min.js',
                type='text/javascript'),
            tags.script(CDATA(js), type='text/javascript'),
            tags.style(CDATA(css), type="text/css"),
        ),
        tags.body(
            tags.h1("Deployment report"),
            table,
        ),
    )
    html(xmlns="http://www.w3.org/1999/xhtml")
    return DOCTYPE + flatten(html)
Exemplo n.º 6
0
    def incidents_as_rows(incidents):
        attrs_incident = {"class": "incident"}
        attrs_number = {"class": "incident_number"}
        attrs_priority = {"class": "incident_priority"}
        attrs_created = {"class": "incident_created"}
        attrs_state = {"class": "incident_state"}
        attrs_rangers = {"class": "incident_rangers"}
        attrs_location = {"class": "incident_location"}
        attrs_types = {"class": "incident_types"}
        attrs_summary  = {"class": "incident_summary"}

        yield tags.thead(
            tags.tr(
                tags.th(u"#", **attrs_number),
                tags.th(u"Priority", **attrs_priority),
                tags.th(u"Created", **attrs_created),
                tags.th(u"State", **attrs_state),
                tags.th(u"Rangers", **attrs_rangers),
                tags.th(u"Location", **attrs_location),
                tags.th(u"Types", **attrs_types),
                tags.th(u"Summary", **attrs_summary),
                **attrs_incident
            ),
            **attrs_activity
        )

        yield tags.tbody(
            tags.tr(
                tags.td(
                    u"{0}".format(incident.number),
                    **attrs_number
                ),
                tags.td(
                    u"{0}".format(priority_name(incident.priority)),
                    **attrs_priority
                ),
                tags.td(
                    u"{0}".format(formatTime(
                        incident.created, tz=tz, format=u"%d/%H:%M"
                    )),
                    **attrs_number
                ),
                tags.td(
                    u"{0}".format(IncidentState.describe(incident.state)),
                    **attrs_number
                ),
                tags.td(
                    u"{0}".format(
                        u", ".join(
                            ranger.handle for ranger in incident.rangers
                        )
                    ),
                    **attrs_rangers
                ),
                tags.td(
                    u"{0}".format(str(incident.location).decode("utf-8")),
                    **attrs_location
                ),
                tags.td(
                    u"{0}".format(u", ".join(incident.incident_types)),
                    **attrs_types
                ),
                tags.td(
                    u"{0}".format(incident.summaryFromReport()),
                    **attrs_summary
                ),
                onclick=(
                    u'window.open("/queue/incidents/{0}");'
                    .format(incident.number)
                ),
                **attrs_incident
            )
            for incident in sorted(incidents)
        )