Merge pull request #446 from mwhudson/show-subiquity-versions

show subiquity versions in upgrade screen
This commit is contained in:
Michael Hudson-Doyle 2019-04-12 11:22:35 +12:00 committed by GitHub
commit 74f5533742
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 103 additions and 4 deletions

View File

@ -17,7 +17,7 @@
"developer": "canonical", "developer": "canonical",
"status": "available", "status": "available",
"type": "app", "type": "app",
"version": "0+git.04f1ff0d", "version": "19.07.2",
"channel": "", "channel": "",
"ignore-validation": false, "ignore-validation": false,
"revision": "424242", "revision": "424242",

View File

@ -0,0 +1,62 @@
{
"type": "sync",
"status-code": 200,
"status": "OK",
"result": {
"id": "ba2aj8guta0zSRlT3QM5aJNAUXPlBtf9",
"title": "subiquity",
"summary": "Ubuntu installer",
"description": "The Ubuntu server installer",
"installed-size": 51191808,
"name": "subiquity",
"publisher": {
"id": "canonical",
"username": "canonical",
"display-name": "Canonical",
"validation": "verified"
},
"developer": "canonical",
"status": "active",
"type": "app",
"version": "19.04.2",
"channel": "stable",
"ignore-validation": false,
"revision": "804",
"confinement": "classic",
"private": false,
"devmode": false,
"jailmode": false,
"apps": [
{
"snap": "subiquity",
"name": "console-conf"
},
{
"snap": "subiquity",
"name": "probert"
},
{
"snap": "subiquity",
"name": "subiquity"
},
{
"snap": "subiquity",
"name": "subiquity-configure-apt"
},
{
"snap": "subiquity",
"name": "subiquity-loadkeys"
},
{
"snap": "subiquity",
"name": "subiquity-service",
"daemon": "simple",
"enabled": true,
"active": true
}
],
"contact": "mailto:mathieu.trudel-lapierre@canonical.com",
"mounted-from": "/var/lib/snapd/snaps/subiquity_804.snap",
"install-date": "2019-04-09T23:06:31.014843014+12:00"
}
}

View File

@ -56,12 +56,34 @@ class RefreshController(BaseController):
self.check_state = CheckState.NOT_STARTED self.check_state = CheckState.NOT_STARTED
self.switch_state = SwitchState.NOT_STARTED self.switch_state = SwitchState.NOT_STARTED
self.network_state = "down" self.network_state = "down"
self.current_snap_version = "unknown"
self.new_snap_version = ""
self.view = None self.view = None
self.offered_first_time = False self.offered_first_time = False
self.answers = self.all_answers.get("Refresh", {}) self.answers = self.all_answers.get("Refresh", {})
def start(self): def start(self):
self.switch_state = SwitchState.SWITCHING self.switch_state = SwitchState.SWITCHING
self.run_in_bg(self._bg_get_snap_details, self._got_snap_details)
def _bg_get_snap_details(self):
return self.snapd_connection.get(
'v2/snaps/{snap_name}'.format(snap_name=self.snap_name))
def _got_snap_details(self, fut):
try:
response = fut.result()
response.raise_for_status()
except requests.exceptions.RequestException:
log.exception("_got_snap_details")
else:
r = response.json()
self.current_snap_version = r['result']['version']
log.debug(
"current version of snap is: %r",
self.current_snap_version)
channel = self.get_refresh_channel() channel = self.get_refresh_channel()
self.run_in_bg( self.run_in_bg(
lambda: self._bg_switch_snap(channel), lambda: self._bg_switch_snap(channel),
@ -173,6 +195,10 @@ class RefreshController(BaseController):
for snap in result["result"]: for snap in result["result"]:
if snap["name"] == self.snap_name: if snap["name"] == self.snap_name:
self.check_state = CheckState.AVAILABLE self.check_state = CheckState.AVAILABLE
self.new_snap_version = snap["version"]
log.debug(
"new version of snap available: %r",
self.new_snap_version)
break break
else: else:
self.check_state = CheckState.UNAVAILABLE self.check_state = CheckState.UNAVAILABLE

View File

@ -105,7 +105,8 @@ class RefreshView(BaseView):
available_title = _("Installer update available") available_title = _("Installer update available")
available_excerpt = _( available_excerpt = _(
"A new version of the installer is available." "Version {new} of the installer is now available ({current} is "
"currently running)."
) )
progress_title = _("Downloading update...") progress_title = _("Downloading update...")
@ -159,10 +160,16 @@ class RefreshView(BaseView):
self.spinner.stop() self.spinner.stop()
rows = [ rows = [
Text("You can read the release notes for each version at:"),
Text(""),
Text(
"https://github.com/CanonicalLtd/subiquity/releases",
align='center'),
Text(""),
Text( Text(
_("If you choose to update, the update will be downloaded " _("If you choose to update, the update will be downloaded "
"and the installation will continue from here."), "and the installation will continue from here."),
) ),
] ]
buttons = button_pile([ buttons = button_pile([
@ -172,9 +179,13 @@ class RefreshView(BaseView):
]) ])
buttons.base_widget.focus_position = 1 buttons.base_widget.focus_position = 1
excerpt = _(self.available_excerpt).format(
current=self.controller.current_snap_version,
new=self.controller.new_snap_version)
self.title = self.available_title self.title = self.available_title
self.controller.ui.set_header(self.available_title) self.controller.ui.set_header(self.available_title)
self._w = screen(rows, buttons, excerpt=_(self.available_excerpt)) self._w = screen(rows, buttons, excerpt=excerpt)
def check_state_failed(self): def check_state_failed(self):
self.spinner.stop() self.spinner.stop()