summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim MacArthur <jim.macarthur@codethink.co.uk>2018-02-28 18:01:28 +0000
committerJim MacArthur <jim.macarthur@codethink.co.uk>2018-03-01 14:36:08 +0000
commitc3f1a2e1e1f7aa7d01f263ba3b2eb644f5bdb638 (patch)
treec77fd6cadb278f36b34244b36ad93da78eb50563
parent14234ccce3e7eec1153e810fab75afb2e90a2b22 (diff)
downloadbuildstream-c3f1a2e1e1f7aa7d01f263ba3b2eb644f5bdb638.tar.gz
Add the FixedText and WallclockTime widgets
WallclockTime is set at the time a message is created. Since messages can be placed in queues before being rendered, this is not always the same time as the wallclock time when rendering the message, so it needs to be stored in the message. widget.py: Add the two new widgets _message.py: record system time when a message is created.
-rw-r--r--buildstream/_frontend/widget.py21
-rw-r--r--buildstream/_message.py2
2 files changed, 23 insertions, 0 deletions
diff --git a/buildstream/_frontend/widget.py b/buildstream/_frontend/widget.py
index 0f431cec9..a0e3ac451 100644
--- a/buildstream/_frontend/widget.py
+++ b/buildstream/_frontend/widget.py
@@ -85,6 +85,27 @@ class Space(Widget):
return ' '
+# Used to add fixed text between columns
+class FixedText(Widget):
+
+ def __init__(self, text, content_profile, format_profile):
+ super(FixedText, self).__init__(content_profile, format_profile)
+ self.text = text
+
+ def render(self, message):
+ return self.format_profile.fmt(self.text)
+
+
+# Used to add the wallclock time this message was created at
+class WallclockTime(Widget):
+ def render(self, message):
+ fields = [self.content_profile.fmt("{:02d}".format(x)) for x in
+ [message.creation_time.hour,
+ message.creation_time.minute,
+ message.creation_time.second]]
+ return self.format_profile.fmt(":").join(fields)
+
+
# A widget for rendering the debugging column
class Debug(Widget):
diff --git a/buildstream/_message.py b/buildstream/_message.py
index 5183a0df2..0cf7fb385 100644
--- a/buildstream/_message.py
+++ b/buildstream/_message.py
@@ -18,6 +18,7 @@
# Authors:
# Tristan Van Berkom <tristan.vanberkom@codethink.co.uk>
+import datetime
import os
@@ -74,5 +75,6 @@ class Message():
self.task_id = task_id # The plugin object ID of the task
self.scheduler = scheduler # Whether this is a scheduler level message
self.sequence_id = sequence_id # Unique ID for a task, so we can track all messages per task
+ self.creation_time = datetime.datetime.now()
if message_type in (MessageType.SUCCESS, MessageType.FAIL):
assert(elapsed is not None)