From 6e2f256f0895930f0a8f10c747b8244cd5da421d Mon Sep 17 00:00:00 2001 From: Chris Peterson Date: Tue, 19 Mar 2024 09:28:55 -0700 Subject: [PATCH] progress: show log-like reporting events Allows for warning and error type events to be printed to the progress view. --- subiquity/client/controllers/progress.py | 4 ++++ subiquity/ui/views/installprogress.py | 22 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/subiquity/client/controllers/progress.py b/subiquity/client/controllers/progress.py index 0cb21b35b..0bd3c910f 100644 --- a/subiquity/client/controllers/progress.py +++ b/subiquity/client/controllers/progress.py @@ -46,6 +46,10 @@ def event(self, event): ) 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"] diff --git a/subiquity/ui/views/installprogress.py b/subiquity/ui/views/installprogress.py index 253316116..6517fdf09 100644 --- a/subiquity/ui/views/installprogress.py +++ b/subiquity/ui/views/installprogress.py @@ -111,6 +111,28 @@ def event_finish(self, context_id): 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)