diff --git a/subiquity/controllers/installprogress.py b/subiquity/controllers/installprogress.py index 01aeee85..5a4472f4 100644 --- a/subiquity/controllers/installprogress.py +++ b/subiquity/controllers/installprogress.py @@ -125,15 +125,19 @@ class InstallProgressController(SubiquityTuiController): msg = context.full_name() if description: msg += ': ' + description - self.progress_view.event_start(context, msg) if context.get('is-install-context'): - self.progress_view.event_start(context, context.description) + indent = context.full_name().count('/') - 2 + if context.get('is-install-context'): + indent -= 1 + msg = ' ' * indent + context.description + else: + return + if context.parent: + self.progress_view.event_finish(context.parent.id) + self.progress_view.event_start(context.id, msg) def report_finish_event(self, context, description, status): - if self._push_to_progress(context): - self.progress_view.event_finish(context) - if context.get('is-install-context'): - self.progress_view.event_finish(context) + self.progress_view.event_finish(context.id) def tpath(self, *path): return os.path.join(self.model.target, *path) diff --git a/subiquity/ui/views/installprogress.py b/subiquity/ui/views/installprogress.py index 75fbce32..3d481a4a 100644 --- a/subiquity/ui/views/installprogress.py +++ b/subiquity/ui/views/installprogress.py @@ -51,7 +51,7 @@ class ProgressView(BaseView): def __init__(self, controller): self.controller = controller - self.ongoing = {} # context -> line containing a spinner + self.ongoing = {} # context_id -> line containing a spinner self.reboot_btn = Toggleable(ok_btn( _("Reboot Now"), on_press=self.reboot)) @@ -93,23 +93,19 @@ class ProgressView(BaseView): lb.set_focus(len(walker) - 1) lb.set_focus_valign('bottom') - def event_start(self, context, message): - self.event_finish(context.parent) + def event_start(self, context_id, message): walker = self.event_listbox.base_widget.body - indent = context.full_name().count('/') - 2 - if context.get('is-install-context'): - indent -= 1 spinner = Spinner(self.controller.app.aio_loop) spinner.start() new_line = Columns([ - ('pack', Text(' ' * indent + message)), + ('pack', Text(message)), ('pack', spinner), ], dividechars=1) - self.ongoing[context] = len(walker) + self.ongoing[context_id] = len(walker) self._add_line(self.event_listbox, new_line) - def event_finish(self, context): - index = self.ongoing.pop(context, None) + def event_finish(self, context_id): + index = self.ongoing.pop(context_id, None) if index is None: return walker = self.event_listbox.base_widget.body @@ -118,8 +114,8 @@ class ProgressView(BaseView): walker[index] = walker[index][0] def finish_all(self): - for context in self.ongoing.copy(): - self.event_finish(context) + for context_id in list(self.ongoing): + self.event_finish(context_id) def add_log_line(self, text): self._add_line(self.log_listbox, Text(text)) diff --git a/subiquitycore/context.py b/subiquitycore/context.py index 2743d751..0ed9c399 100644 --- a/subiquitycore/context.py +++ b/subiquitycore/context.py @@ -25,6 +25,9 @@ class Status(enum.Enum): WARN = enum.auto() +context_id = 0 + + class Context: """Class to report when things start and finish. @@ -48,6 +51,9 @@ class Context: """ def __init__(self, app, name, description, parent, level, childlevel=None): + global context_id + self.id = context_id + context_id += 1 self.app = app self.name = name self.description = description