progress: show log-like reporting events

Allows for warning and error type events to be printed to the progress
view.
This commit is contained in:
Chris Peterson 2024-03-19 09:28:55 -07:00
parent 735771a494
commit 6e2f256f08
2 changed files with 26 additions and 0 deletions

View File

@ -46,6 +46,10 @@ class ProgressController(SubiquityTuiController):
)
elif event["SUBIQUITY_EVENT_TYPE"] == "finish":
self.progress_view.event_finish(event["SUBIQUITY_CONTEXT_ID"])
else:
event_type = event["SUBIQUITY_EVENT_TYPE"]
message = event["MESSAGE"]
self.progress_view.event_other(message, event_type)
def log_line(self, event):
log_line = event["MESSAGE"]

View File

@ -111,6 +111,28 @@ class ProgressView(BaseView):
spinner.stop()
walker[index] = walker[index][0]
def event_other(self, message: str, event_type: str) -> None:
"""Print events that aren't start or finish events"""
# Events which aren't start or finish events (info, warning, or error)
# are usually structured like:
#
# subiquity/controller/blah: event description
#
# and we want to insert the event type between the colon and the
# event description
context, text = message.split(":")
text = text.lstrip()
message = f"{context}: {event_type.upper()}: {text}"
new_line = Columns(
[
("pack", Text(message)),
],
dividechars=1,
)
self._add_line(self.event_listbox, new_line)
def finish_all(self):
for context_id in list(self.ongoing):
self.event_finish(context_id)