diff options
author | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-01-20 16:28:19 -0500 |
---|---|---|
committer | Tristan Van Berkom <tristan.vanberkom@codethink.co.uk> | 2019-04-14 16:54:30 +0900 |
commit | 5db6aea8584039725d9a2f92d2baa37f3b9dc242 (patch) | |
tree | 0a4ff05f201ad496de02ebd1328065b9f0c7359c | |
parent | 9aaa0b0d7e33637ef9b60678b97f9f346489dd88 (diff) | |
download | buildstream-5db6aea8584039725d9a2f92d2baa37f3b9dc242.tar.gz |
_frontend/status.py: Added Cache size usage indicator to status bar
This also adds some comments around the main status bar heading
rendering function.
-rw-r--r-- | buildstream/_frontend/status.py | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/buildstream/_frontend/status.py b/buildstream/_frontend/status.py index fd1a5acf1..9ec7d75e0 100644 --- a/buildstream/_frontend/status.py +++ b/buildstream/_frontend/status.py @@ -353,13 +353,17 @@ class _StatusHeader(): def render(self, line_length, elapsed): project = self._context.get_toplevel_project() line_length = max(line_length, 80) - size = 0 - text = '' + # + # 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)) - # Format and calculate size for target and overall time code + 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 @@ -372,6 +376,12 @@ class _StatusHeader(): self._format_profile.fmt(')') line1 = self._centered(text, size, line_length, '=') + + # + # Line 2: Dynamic list of queue status reports + # + # (Fetched:0 117 0)→ (Built:4 0 0) + # size = 0 text = '' @@ -389,10 +399,28 @@ class _StatusHeader(): line2 = self._centered(text, size, line_length, ' ') - size = 24 - text = self._format_profile.fmt("~~~~~ ") + \ - self._content_profile.fmt('Active Tasks') + \ - self._format_profile.fmt(" ~~~~~") + # + # Line 3: Cache usage percentage report + # + # ~~~~~~ cache: 69% ~~~~~~ + # + usage = self._context.get_artifact_cache_usage() + usage_percent = '{}%'.format(usage.used_percent) + + size = 21 + size += len(usage_percent) + if usage.used_percent >= 95: + formatted_usage_percent = self._error_profile.fmt(usage_percent) + elif usage.used_percent >= 80: + formatted_usage_percent = self._content_profile.fmt(usage_percent) + else: + formatted_usage_percent = self._success_profile.fmt(usage_percent) + + text = self._format_profile.fmt("~~~~~~ ") + \ + self._content_profile.fmt('cache') + \ + self._format_profile.fmt(': ') + \ + formatted_usage_percent + \ + self._format_profile.fmt(' ~~~~~~') line3 = self._centered(text, size, line_length, ' ') return line1 + '\n' + line2 + '\n' + line3 |