Skip to content

Commit

Permalink
Merge pull request #651 from mwhudson/restart-after-fail-snafu
Browse files Browse the repository at this point in the history
fix various restarting snafus
  • Loading branch information
xnox authored Mar 16, 2020
2 parents f9a5046 + b4ab4d8 commit 828febd
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion subiquity/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def configured(self):
self.app.base_model.configured(self.model_name)

def deserialize(self, state):
self.configured()
pass

def make_autoinstall(self):
return {}
Expand Down
1 change: 0 additions & 1 deletion subiquity/controllers/mirror.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ def serialize(self):
return self.model.get_mirror()

def deserialize(self, data):
super().deserialize(data)
self.model.set_mirror(data)

def done(self, mirror):
Expand Down
1 change: 0 additions & 1 deletion subiquity/controllers/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def serialize(self):
return self.model.proxy

def deserialize(self, data):
super().deserialize(data)
self.model.proxy = data

def done(self, proxy):
Expand Down
2 changes: 1 addition & 1 deletion subiquity/controllers/refresh.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ async def apply_autoinstall_config(self, index=1):
if change['status'] == 'Done':
# Clearly if we got here we didn't get restarted by
# snapd/systemctl (dry-run mode or logged in via SSH)
self.app.restart()
self.app.restart(remove_last_screen=False)
if change['status'] not in ['Do', 'Doing']:
raise Exception("update failed")
await asyncio.sleep(0.1)
Expand Down
1 change: 0 additions & 1 deletion subiquity/controllers/welcome.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ def serialize(self):
return self.model.selected_language

def deserialize(self, data):
super().deserialize(data)
self.model.switch_language(data)

def make_autoinstall(self):
Expand Down
5 changes: 4 additions & 1 deletion subiquity/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ def exit(self):
else:
super().exit()

def restart(self):
def restart(self, remove_last_screen=True):
if remove_last_screen:
self._remove_last_screen()
self.urwid_loop.screen.stop()
cmdline = ['snap', 'run', 'subiquity']
if self.opts.dry_run:
Expand Down Expand Up @@ -168,6 +170,7 @@ def run(self):
report = self.make_apport_report(
ErrorReportKind.UI, "Installer UI", interrupt=False, wait=True)
print("report saved to {}".format(report.path))
self._remove_last_screen()
raise

def report_start_event(self, name, description, level="INFO"):
Expand Down
8 changes: 7 additions & 1 deletion subiquitycore/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,10 +485,13 @@ def report_finish_event(self, name, description, status, level):

# EventLoop -------------------------------------------------------------------

def exit(self):
def _remove_last_screen(self):
state_path = os.path.join(self.state_dir, 'last-screen')
if os.path.exists(state_path):
os.unlink(state_path)

def exit(self):
self._remove_last_screen()
self.aio_loop.stop()

def run_scripts(self, scripts):
Expand Down Expand Up @@ -597,6 +600,9 @@ def load_serialized_state(self):
for i, controller in enumerate(self.controllers.instances):
if controller.name == last_screen:
controller_index = i
# Screens that have already been seen should be marked as configured.
for controller in self.controllers.instances[:controller_index]:
controller.configured()
return controller_index

def setraw(self):
Expand Down

0 comments on commit 828febd

Please sign in to comment.