summaryrefslogtreecommitdiff
path: root/buildstream/_frontend/widget.py
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-05-01 15:41:18 +0900
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2017-05-01 15:56:10 +0900
commitb690cc2ade23960e884082a55e1020eaff45fefa (patch)
tree94ad74938ab133a4a70872458e55a3f445989146 /buildstream/_frontend/widget.py
parent79b14b357c5d4fcca6ae1252640282c1f0c2eec2 (diff)
downloadbuildstream-b690cc2ade23960e884082a55e1020eaff45fefa.tar.gz
widget.py: TimeCode widget support to render without brackets
Also fix to CacheKey widget, fix display for elements before pipeline is fully resolved (avoids exceptions thrown in debug mode)
Diffstat (limited to 'buildstream/_frontend/widget.py')
-rw-r--r--buildstream/_frontend/widget.py21
1 files changed, 18 insertions, 3 deletions
diff --git a/buildstream/_frontend/widget.py b/buildstream/_frontend/widget.py
index 18b094a20..835f1ac78 100644
--- a/buildstream/_frontend/widget.py
+++ b/buildstream/_frontend/widget.py
@@ -98,6 +98,10 @@ class Debug(Widget):
# A widget for rendering the time codes
class TimeCode(Widget):
+ def __init__(self, content_profile, format_profile, brackets=True):
+ self.brackets = brackets
+ super(TimeCode, self).__init__(content_profile, format_profile)
+
def render(self, message):
return self.render_time(message.elapsed)
@@ -115,9 +119,15 @@ class TimeCode(Widget):
for field in [hours, minutes, seconds]
]
- return self.format_profile.fmt('[') + \
- self.format_profile.fmt(':').join(fields) + \
- self.format_profile.fmt(']')
+ text = ''
+ if self.brackets:
+ text += self.format_profile.fmt('[')
+
+ text += self.format_profile.fmt(':').join(fields)
+ if self.brackets:
+ text += self.format_profile.fmt(']')
+
+ return text
# A widget for rendering the action name
@@ -202,12 +212,17 @@ class CacheKey(Widget):
super(CacheKey, self).__init__(content_profile, format_profile)
self.err_profile = err_profile
+ self.key_length = 0
def size_request(self, pipeline):
self.key_length = pipeline.context.log_key_length
def render(self, message):
+ # This can only happen when logging before initialization in debug mode
+ if not self.key_length:
+ return self.format_profile.fmt('[') + (' ' * 8) + self.format_profile.fmt(']')
+
key = ' ' * self.key_length
if message.unique_id is not None:
plugin = _plugin_lookup(message.unique_id)