summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJürg Billeter <j@bitron.ch>2019-08-28 14:17:49 +0200
committerbst-marge-bot <marge-bot@buildstream.build>2019-09-05 05:09:53 +0000
commit45a177a305ec5babd6b1e3ac3fea2459f143eab2 (patch)
treee63a5635c59b2d1fb91dfd6b3b3b1092b38874e0
parent878da241e5d9b7d7d5a1adcf18f7953323f65cff (diff)
downloadbuildstream-45a177a305ec5babd6b1e3ac3fea2459f143eab2.tar.gz
_frontend/status.py: Readd cache usage to status bar
This was removed with the switch to buildbox-casd. Readd it now that cache usage tracking is supported again.
-rw-r--r--src/buildstream/_frontend/status.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/buildstream/_frontend/status.py b/src/buildstream/_frontend/status.py
index d0070cef0..a68d0d04e 100644
--- a/src/buildstream/_frontend/status.py
+++ b/src/buildstream/_frontend/status.py
@@ -350,7 +350,7 @@ class _StatusHeader():
#
# Public members
#
- self.lines = 2
+ self.lines = 3
#
# Private members
@@ -413,7 +413,38 @@ class _StatusHeader():
line2 = self._centered(text, size, line_length, ' ')
- return line1 + '\n' + line2
+ #
+ # 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
###################################################
# Private Methods #