Merge lp:~marcustomlinson/update-manager/update-manager into lp:update-manager

Proposed by Marcus Tomlinson on 2020-04-16
Status: Merged
Approved by: Łukasz Zemczak on 2020-04-16
Approved revision: no longer in the source branch.
Merged at revision: 2880
Proposed branch: lp:~marcustomlinson/update-manager/update-manager
Merge into: lp:update-manager
Diff against target: 112 lines (+56/-7)
2 files modified
UpdateManager/backend/__init__.py (+49/-7)
debian/changelog (+7/-0)
To merge this branch: bzr merge lp:~marcustomlinson/update-manager/update-manager
Reviewer Review Type Date Requested Status
Łukasz Zemczak 2020-04-16 Approve on 2020-04-16
Review via email: mp+382410@code.launchpad.net

Commit message

Display progress on snap updates and error out on failure

To post a comment you must log in.
2879. By Łukasz Zemczak on 2020-04-16

Adjust dates in hwe-support-status for focal.

Łukasz Zemczak (sil2100) wrote :

Ok, this looks good. I have one nitpick but we can leave it as-is. Not big of a deal.

review: Approve
2880. By Łukasz Zemczak on 2020-04-16

Display progress on snap updates and error out on failure

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UpdateManager/backend/__init__.py'
2--- UpdateManager/backend/__init__.py 2020-04-15 12:37:26 +0000
3+++ UpdateManager/backend/__init__.py 2020-04-16 10:38:34 +0000
4@@ -204,6 +204,28 @@
5
6 return snap_list
7
8+ def update_snap_cb(self, client, change, _, user_data):
9+ index, count, progress_bar = user_data
10+ if not progress_bar:
11+ return
12+
13+ # determine how much of this change has been done
14+ task_total = 0
15+ task_done = 0
16+ for task in change.get_tasks():
17+ task_total += task.get_progress_total()
18+ task_done += task.get_progress_done()
19+
20+ task_fraction = task_done / task_total
21+
22+ # determine how much total progress has been made
23+ total_fraction = (task_fraction / count) + (index / count)
24+
25+ # change.get_tasks() can increase between callbacks so we must
26+ # avoid jumping backward in progress here
27+ if total_fraction > progress_bar.get_fraction():
28+ progress_bar.set_fraction(total_fraction)
29+
30 def update_snaps(self):
31 # update status and progress bar
32 def update_status(status):
33@@ -215,37 +237,57 @@
34
35 update_status(_("Updating snaps"))
36
37+ progress_bar = None
38 progress_timer = None
39+
40 progress_bars = self.progressbar_slot.get_children()
41 if progress_bars and isinstance(progress_bars[0], Gtk.ProgressBar):
42+ progress_bar = progress_bars[0]
43 progress_timer = GLib.timeout_add(100, update_progress,
44- progress_bars[0])
45+ progress_bar)
46
47 # populate snap_list with deb2snap transitions
48 snap_list = self.get_snap_transitions()
49
50+ if progress_timer:
51+ GLib.source_remove(progress_timer)
52+ progress_bar.set_fraction(0)
53+
54 # (un)install (un)seeded snap(s)
55 try:
56 client = Snapd.Client()
57 client.connect_sync()
58+ index = 0
59+ count = len(snap_list)
60 for snap, snap_object in snap_list.items():
61 command = snap_object['command']
62 if command == 'refresh':
63 update_status(_("Refreshing %s snap" % snap))
64- client.refresh_sync(snap, snap_object['channel'])
65+ client.refresh_sync(snap, snap_object['channel'],
66+ self.update_snap_cb,
67+ progress_callback_data=(index, count,
68+ progress_bar))
69 elif command == 'remove':
70 update_status(_("Removing %s snap" % snap))
71- client.remove_sync(snap)
72+ client.remove_sync(snap, self.update_snap_cb,
73+ progress_callback_data=(index, count,
74+ progress_bar))
75 else:
76 update_status(_("Installing %s snap" % snap))
77- client.install_sync(snap, snap_object['channel'])
78+ client.install_sync(snap, snap_object['channel'],
79+ self.update_snap_cb,
80+ progress_callback_data=(index, count,
81+ progress_bar))
82+ index += 1
83 except GLib.Error as e:
84 logging.debug("error updating snaps (%s)" % e)
85+ GLib.idle_add(self.window_main.start_error, False,
86+ _("Upgrade only partially completed."),
87+ _("An error occurred while updating snaps. "
88+ "Please check your network connection."))
89+ return
90
91 # continue with the rest of the updates
92- if progress_timer:
93- GLib.source_remove(progress_timer)
94-
95 GLib.idle_add(self.window_main.start_available)
96
97 def _action_done(self, action, authorized, success, error_string,
98
99=== modified file 'debian/changelog'
100--- debian/changelog 2020-04-15 12:37:26 +0000
101+++ debian/changelog 2020-04-16 10:38:34 +0000
102@@ -1,3 +1,10 @@
103+update-manager (1:20.04.7) UNRELEASED; urgency=medium
104+
105+ * Show progress of snap updates (LP: #1871099).
106+ * Display an error message when snap updates fail (LP: #1871100).
107+
108+ -- Marcus Tomlinson <marcus.tomlinson@canonical.com> Thu, 16 Apr 2020 09:46:56 +0100
109+
110 update-manager (1:20.04.6) focal; urgency=medium
111
112 * deb2snap: Don't replace debs that were manually installed via

Subscribers

People subscribed via source and target branches

to status/vote changes: