Support 'accept-default' and 'country-code' in mirror answers

This commit is contained in:
Michael Hudson-Doyle 2019-04-04 12:12:50 +13:00
parent 2840e3d8fc
commit 194137a151
2 changed files with 8 additions and 1 deletions

View File

@ -11,7 +11,7 @@ Network:
Proxy:
proxy: ""
Mirror:
mirror: "http://us.archive.ubuntu.com"
country-code: us
Filesystem:
guided: yes
guided-index: 0

View File

@ -42,6 +42,9 @@ class MirrorController(BaseController):
self.model = self.base_model.mirror
self.check_state = CheckState.NOT_STARTED
self.answers = self.all_answers.get('Mirror', {})
if 'country-code' in self.answers:
self.check_state = CheckState.DONE
self.model.set_country(self.answers['country-code'])
def snapd_network_changed(self):
if self.check_state != CheckState.DONE:
@ -77,6 +80,7 @@ class MirrorController(BaseController):
log.debug("bogus CountryCode found in %r", response.text)
self.check_state = CheckState.FAILED
return
self.check_state = CheckState.DONE
self.model.set_country(cc)
def default(self):
@ -84,6 +88,9 @@ class MirrorController(BaseController):
self.ui.set_body(MirrorView(self.model, self))
if 'mirror' in self.answers:
self.done(self.answers['mirror'])
elif 'country-code' in self.answers \
or 'accept-default' in self.answers:
self.done(self.model.mirror)
def cancel(self):
self.signal.emit_signal('prev-screen')