shuffle run loop around

This commit is contained in:
Michael Hudson-Doyle 2020-03-30 10:17:22 +13:00
parent 0012c5ff70
commit caf713d289
2 changed files with 31 additions and 14 deletions

View File

@ -33,6 +33,9 @@ class SubiquityController(BaseController):
def __init__(self, app):
super().__init__(app)
self.autoinstall_applied = False
self.setup_autoinstall()
def setup_autoinstall(self):
if app.autoinstall_config:
ai_data = app.autoinstall_config.get(
self.autoinstall_key,

View File

@ -17,6 +17,7 @@ import asyncio
import logging
import os
import platform
import signal
import sys
import traceback
import urwid
@ -152,18 +153,24 @@ class Subiquity(Application):
return s
def run(self):
try:
if self.opts.autoinstall is not None:
with open(self.opts.autoinstall) as fp:
self.autoinstall_config = yaml.safe_load(fp)
self.controllers.load("Reporting")
self.controllers.load("Early")
self.controllers.Reporting.start()
self.aio_loop.run_until_complete(self.controllers.Early.run())
self.controllers.load("Error")
self.controllers.load("Early")
if self.controllers.Early.cmds:
self.aio_loop.run_until_complete(
self.controllers.Early.run())
self.new_event_loop()
with open(self.opts.autoinstall) as fp:
self.autoinstall_config = yaml.safe_load(fp)
try:
for controller in self.controllers.instances:
controller.setup_autoinstall()
super().run()
if self.controllers.Late.cmds:
self.new_event_loop()
self.aio_loop.run_until_complete(self.controllers.Late.run())
except Exception:
@ -171,8 +178,15 @@ class Subiquity(Application):
report = self.make_apport_report(
ErrorReportKind.UI, "Installer UI", interrupt=False, wait=True)
print("report saved to {}".format(report.path))
Error = getattr(self.controllers, "Error", None)
if Error is not None and Error.cmds:
self.new_event_loop()
self.aio_loop.run_until_complete(Error.run())
if self.interactive():
self._remove_last_screen()
raise
else:
signal.pause()
def report_start_event(self, name, description, level="INFO"):
self.controllers.Reporting.report_start_event(