record current and new versions of snap
This commit is contained in:
parent
23b246caf1
commit
0ce5a6bc2e
|
@ -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": "ubuntu-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"
|
||||
}
|
||||
}
|
|
@ -56,12 +56,34 @@ class RefreshController(BaseController):
|
|||
self.check_state = CheckState.NOT_STARTED
|
||||
self.switch_state = SwitchState.NOT_STARTED
|
||||
self.network_state = "down"
|
||||
|
||||
self.current_snap_version = "unknown"
|
||||
self.new_snap_version = ""
|
||||
|
||||
self.view = None
|
||||
self.offered_first_time = False
|
||||
self.answers = self.all_answers.get("Refresh", {})
|
||||
|
||||
def start(self):
|
||||
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()
|
||||
self.run_in_bg(
|
||||
lambda: self._bg_switch_snap(channel),
|
||||
|
@ -172,6 +194,10 @@ class RefreshController(BaseController):
|
|||
for snap in result["result"]:
|
||||
if snap["name"] == self.snap_name:
|
||||
self.check_state = CheckState.AVAILABLE
|
||||
self.new_snap_version = snap["version"]
|
||||
log.debug(
|
||||
"new version of snap available: %r",
|
||||
self.new_snap_version)
|
||||
break
|
||||
else:
|
||||
self.check_state = CheckState.UNAVAILABLE
|
||||
|
|
Loading…
Reference in New Issue