in src/buildstream/_frontend/status.py [0:0]
def render(self, line_length, elapsed):
project = self._context.get_toplevel_project()
line_length = max(line_length, 80)
#
# Line 1: Session time, project name, session / total elements
#
# ========= 00:00:00 project-name (143/387) =========
#
session = str(len(self._stream.session_elements))
total = str(len(self._stream.total_elements))
size = 0
text = ""
size += len(total) + len(session) + 4 # Size for (N/N) with a leading space
size += 8 # Size of time code
size += len(project.name) + 1
text += self._time_code.render_time(elapsed)
text += " " + self._content_profile.fmt(project.name)
text += (
" "
+ self._format_profile.fmt("(")
+ self._content_profile.fmt(session)
+ self._format_profile.fmt("/")
+ self._content_profile.fmt(total)
+ self._format_profile.fmt(")")
)
line1 = self._centered(text, size, line_length, "=")
#
# Line 2: Dynamic list of queue status reports
#
# (Sources Fetched:0 117 0)→ (Built:4 0 0)
#
size = 0
text = ""
# Format and calculate size for each queue progress
for index, task_group in enumerate(self._state.task_groups.values()):
# Add spacing
if index > 0:
size += 2
text += self._format_profile.fmt("→ ")
group_text, group_size = self._render_task_group(task_group)
size += group_size
text += group_text
line2 = self._centered(text, size, line_length, " ")
#
# Line 3: Cache usage percentage report
#
# ~~~~~~ cache: 44.2G / 64G (69%) ~~~~~~
#
cas = self._context.get_cascache()
usage = cas.get_cache_usage()
usage_string = str(usage)
if usage.used_size is None:
# Cache usage is unknown
size = 0
text = ""
else:
size = 21
size += len(usage_string)
if usage.used_percent >= 95:
formatted_usage = self._error_profile.fmt(usage_string)
elif usage.used_percent >= 80:
formatted_usage = self._content_profile.fmt(usage_string)
else:
formatted_usage = self._success_profile.fmt(usage_string)
text = (
self._format_profile.fmt("~~~~~~ ")
+ self._content_profile.fmt("cache")
+ self._format_profile.fmt(": ")
+ formatted_usage
+ self._format_profile.fmt(" ~~~~~~")
)
line3 = self._centered(text, size, line_length, " ")
return line1 + "\n" + line2 + "\n" + line3