Skip to content

Commit

Permalink
progress: show log-like reporting events
Browse files Browse the repository at this point in the history
Allows for warning and error type events to be printed to the progress
view.
  • Loading branch information
Chris-Peterson444 committed Mar 26, 2024
1 parent 735771a commit 6e2f256
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions subiquity/client/controllers/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
22 changes: 22 additions & 0 deletions subiquity/ui/views/installprogress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 6e2f256

Please sign in to comment.