mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2024-12-25 15:41:06 +00:00
Use twisted web tags in ResultsBase
This commit is contained in:
parent
8e37bb1ebb
commit
d2540b89d3
@ -107,32 +107,35 @@ class ResultsBase(object):
|
|||||||
sb = c.get_storage_broker()
|
sb = c.get_storage_broker()
|
||||||
r = []
|
r = []
|
||||||
def add(name, value):
|
def add(name, value):
|
||||||
r.append(T.li[name + ": ", value])
|
r.append(tags.li(name + ": ", value))
|
||||||
|
|
||||||
|
add("Report", tags.pre("\n".join(self._html(cr.get_report()))))
|
||||||
|
|
||||||
add("Report", T.pre["\n".join(self._html(cr.get_report()))])
|
|
||||||
add("Share Counts",
|
add("Share Counts",
|
||||||
"need %d-of-%d, have %d" % (cr.get_encoding_needed(),
|
"need %d-of-%d, have %d" % (cr.get_encoding_needed(),
|
||||||
cr.get_encoding_expected(),
|
cr.get_encoding_expected(),
|
||||||
cr.get_share_counter_good()))
|
cr.get_share_counter_good()))
|
||||||
add("Happiness Level", cr.get_happiness())
|
add("Happiness Level", str(cr.get_happiness()))
|
||||||
add("Hosts with good shares", cr.get_host_counter_good_shares())
|
add("Hosts with good shares", str(cr.get_host_counter_good_shares()))
|
||||||
|
|
||||||
|
rrr = cr.get_corrupt_shares()
|
||||||
|
|
||||||
if cr.get_corrupt_shares():
|
if cr.get_corrupt_shares():
|
||||||
badsharemap = []
|
badsharemap = []
|
||||||
for (s, si, shnum) in cr.get_corrupt_shares():
|
for (s, si, shnum) in cr.get_corrupt_shares():
|
||||||
d = T.tr[T.td["sh#%d" % shnum],
|
d = tags.tr(tags.td("sh#%d" % shnum),
|
||||||
T.td[T.div(class_="nickname")[s.get_nickname()],
|
tags.td(tags.div(s.get_nickname(), class_="nickname"),
|
||||||
T.div(class_="nodeid")[T.tt[s.get_name()]]],
|
tags.div(tags.tt(s.get_name()), class_="nodeid")),)
|
||||||
]
|
|
||||||
badsharemap.append(d)
|
badsharemap.append(d)
|
||||||
add("Corrupt shares", T.table()[
|
add("Corrupt shares",
|
||||||
T.tr[T.th["Share ID"],
|
tags.table(
|
||||||
T.th(class_="nickname-and-peerid")[T.div["Nickname"], T.div(class_="nodeid")["Node ID"]]],
|
tags.tr(tags.th("Share ID"),
|
||||||
badsharemap])
|
tags.th((tags.div("Nickname"), tags.div("Node ID", class_="nodeid")), class_="nickname-and-peerid")),
|
||||||
|
badsharemap))
|
||||||
else:
|
else:
|
||||||
add("Corrupt shares", "none")
|
add("Corrupt shares", "none")
|
||||||
|
|
||||||
add("Wrong Shares", cr.get_share_counter_wrong())
|
add("Wrong Shares", str(cr.get_share_counter_wrong()))
|
||||||
|
|
||||||
sharemap_data = []
|
sharemap_data = []
|
||||||
shares_on_server = dictutil.DictOfSets()
|
shares_on_server = dictutil.DictOfSets()
|
||||||
@ -147,18 +150,19 @@ class ResultsBase(object):
|
|||||||
shareid_s = ""
|
shareid_s = ""
|
||||||
if i == 0:
|
if i == 0:
|
||||||
shareid_s = shareid
|
shareid_s = shareid
|
||||||
d = T.tr[T.td[shareid_s],
|
d = tags.tr(tags.td(shareid_s),
|
||||||
T.td[T.div(class_="nickname")[s.get_nickname()],
|
tags.td(tags.div(s.get_nickname(), class_="nickname"),
|
||||||
T.div(class_="nodeid")[T.tt[s.get_name()]]]
|
tags.div(tags.tt(s.get_name()), class_="nodeid")))
|
||||||
]
|
|
||||||
sharemap_data.append(d)
|
sharemap_data.append(d)
|
||||||
|
|
||||||
add("Good Shares (sorted in share order)",
|
add("Good Shares (sorted in share order)",
|
||||||
T.table()[T.tr[T.th["Share ID"], T.th(class_="nickname-and-peerid")[T.div["Nickname"], T.div(class_="nodeid")["Node ID"]]],
|
tags.table(tags.tr(tags.th("Share ID"),
|
||||||
sharemap_data])
|
tags.th(tags.div("Nickname"),
|
||||||
|
tags.div("Node ID", class_="nodeid"), class_="nickname-and-peerid")),
|
||||||
|
sharemap_data))
|
||||||
|
|
||||||
|
add("Recoverable Versions", str(cr.get_version_counter_recoverable()))
|
||||||
add("Recoverable Versions", cr.get_version_counter_recoverable())
|
add("Unrecoverable Versions", str(cr.get_version_counter_unrecoverable()))
|
||||||
add("Unrecoverable Versions", cr.get_version_counter_unrecoverable())
|
|
||||||
|
|
||||||
# this table is sorted by permuted order
|
# this table is sorted by permuted order
|
||||||
permuted_servers = [s
|
permuted_servers = [s
|
||||||
@ -171,20 +175,23 @@ class ResultsBase(object):
|
|||||||
for s in permuted_servers:
|
for s in permuted_servers:
|
||||||
shareids = list(shares_on_server.get(s, []))
|
shareids = list(shares_on_server.get(s, []))
|
||||||
shareids.reverse()
|
shareids.reverse()
|
||||||
shareids_s = [ T.tt[shareid, " "] for shareid in sorted(shareids) ]
|
shareids_s = [tags.tt(shareid, " ") for shareid in sorted(shareids)]
|
||||||
d = T.tr[T.td[T.div(class_="nickname")[s.get_nickname()],
|
|
||||||
T.div(class_="nodeid")[T.tt[s.get_name()]]],
|
d = tags.tr(tags.td(tags.div(s.get_nickname(), class_="nickname"),
|
||||||
T.td[shareids_s],
|
tags.div(tags.tt(s.get_name()), class_="nodeid")),
|
||||||
]
|
tags.td(shareids_s), )
|
||||||
servermap.append(d)
|
servermap.append(d)
|
||||||
num_shares_left -= len(shareids)
|
num_shares_left -= len(shareids)
|
||||||
if not num_shares_left:
|
if not num_shares_left:
|
||||||
break
|
break
|
||||||
add("Share Balancing (servers in permuted order)",
|
|
||||||
T.table()[T.tr[T.th(class_="nickname-and-peerid")[T.div["Nickname"], T.div(class_="nodeid")["Node ID"]], T.th["Share IDs"]],
|
|
||||||
servermap])
|
|
||||||
|
|
||||||
return T.ul[r]
|
add("Share Balancing (servers in permuted order)",
|
||||||
|
tags.table(tags.tr(tags.th(tags.div("Nickname"),
|
||||||
|
tags.div("Node ID", class_="nodeid"), class_="nickname-and-peerid"),
|
||||||
|
tags.th("Share IDs")),
|
||||||
|
servermap))
|
||||||
|
|
||||||
|
return tags.ul(r)
|
||||||
|
|
||||||
def _html(self, s):
|
def _html(self, s):
|
||||||
if isinstance(s, (str, unicode)):
|
if isinstance(s, (str, unicode)):
|
||||||
@ -206,7 +213,7 @@ class ResultsBase(object):
|
|||||||
output = get_arg(ctx, "output")
|
output = get_arg(ctx, "output")
|
||||||
if output:
|
if output:
|
||||||
target = target + "?output=%s" % output
|
target = target + "?output=%s" % output
|
||||||
return T.a(href=target)[si_s]
|
return tags.a(si_s, href=target)
|
||||||
|
|
||||||
|
|
||||||
class LiteralCheckResultsRenderer(MultiFormatResource, ResultsBase):
|
class LiteralCheckResultsRenderer(MultiFormatResource, ResultsBase):
|
||||||
|
Loading…
Reference in New Issue
Block a user