Use simpler syntax to update map

This commit is contained in:
Sajith Sasidharan 2020-06-24 08:15:18 -04:00
parent d3f43d31d9
commit f9e864c51c

View File

@ -1250,15 +1250,14 @@ class StatusElement(Element):
result = dict() result = dict()
started_s = render_time(op.get_started()) started_s = render_time(op.get_started())
result.update({"started": started_s}) result["started"] = started_s
si_s = base32.b2a_or_none(op.get_storage_index()) si_s = base32.b2a_or_none(op.get_storage_index())
if si_s is None: if si_s is None:
si_s = "(None)" si_s = "(None)"
result.update({"si": si_s}) result["si"] = si_s
result.update({"helper": result["helper"] = {True: "Yes", False: "No"}[op.using_helper()]
{True: "Yes", False: "No"}[op.using_helper()]})
size = op.get_size() size = op.get_size()
if size is None: if size is None:
@ -1266,38 +1265,38 @@ class StatusElement(Element):
elif isinstance(size, (int, long, float)): elif isinstance(size, (int, long, float)):
size = abbreviate_size(size) size = abbreviate_size(size)
result.update({"total_size": size}) result["total_size"] = size
progress = op.get_progress() progress = op.get_progress()
if IUploadStatus.providedBy(op): if IUploadStatus.providedBy(op):
link = "up-%d" % op.get_counter() link = "up-%d" % op.get_counter()
result.update({"type": "upload"}) result["type"] = "upload"
# TODO: make an ascii-art bar # TODO: make an ascii-art bar
(chk, ciphertext, encandpush) = progress (chk, ciphertext, encandpush) = progress
progress_s = ("hash: %.1f%%, ciphertext: %.1f%%, encode: %.1f%%" % progress_s = ("hash: %.1f%%, ciphertext: %.1f%%, encode: %.1f%%" %
((100.0 * chk), ((100.0 * chk),
(100.0 * ciphertext), (100.0 * ciphertext),
(100.0 * encandpush))) (100.0 * encandpush)))
result.update({"progress": progress_s}) result["progress"] = progress_s
elif IDownloadStatus.providedBy(op): elif IDownloadStatus.providedBy(op):
link = "down-%d" % op.get_counter() link = "down-%d" % op.get_counter()
result.update({"type": "download"}) result["type"] = "download"
result.update({"progress": "%.1f%%" % (100.0 * progress)}) result["progress"] = "%.1f%%" % (100.0 * progress)
elif IPublishStatus.providedBy(op): elif IPublishStatus.providedBy(op):
link = "publish-%d" % op.get_counter() link = "publish-%d" % op.get_counter()
result.update({"type": "publish"}) result["type"] = "publish"
result.update({"progress": "%.1f%%" % (100.0 * progress)}) result["progress"] = "%.1f%%" % (100.0 * progress)
elif IRetrieveStatus.providedBy(op): elif IRetrieveStatus.providedBy(op):
result.update({"type": "retrieve"}) result["type"] = "retrieve"
link = "retrieve-%d" % op.get_counter() link = "retrieve-%d" % op.get_counter()
result.update({"progress": "%.1f%%" % (100.0 * progress)}) result["progress"] = "%.1f%%" % (100.0 * progress)
else: else:
assert IServermapUpdaterStatus.providedBy(op) assert IServermapUpdaterStatus.providedBy(op)
result.update({"type": "mapupdate %s" % op.get_mode()}) result["type"] = "mapupdate %s" % op.get_mode()
link = "mapupdate-%d" % op.get_counter() link = "mapupdate-%d" % op.get_counter()
result.update({"progress": "%.1f%%" % (100.0 * progress)}) result["progress"] = "%.1f%%" % (100.0 * progress)
result.update({"status": tags.a(op.get_status(), href=link)}) result["status"] = tags.a(op.get_status(), href=link)
return result return result