Merge lp:~robert-ancell/update-manager/ua-updates-api into lp:update-manager

Proposed by Robert Ancell
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 2957
Merged at revision: 2959
Proposed branch: lp:~robert-ancell/update-manager/ua-updates-api
Merge into: lp:update-manager
Diff against target: 46 lines (+5/-19)
1 file modified
UpdateManager/UpdateManager.py (+5/-19)
To merge this branch: bzr merge lp:~robert-ancell/update-manager/ua-updates-api
Reviewer Review Type Date Requested Status
Sebastien Bacher Approve
Grant Orndorff Pending
Review via email: mp+436096@code.launchpad.net

Description of the change

Use uaclient library instead of calling ua tool directly. This simplifies parsing errors. The API is blocking however, so we hold up the UI.

To post a comment you must log in.
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thanks, makes sense, that's what the pro client team suggested using, it would also have avoided the recently issue when the parsing wasn't working anymore due to them changing one of the key names

review: Approve
Revision history for this message
Kiwinote (kiwinote) wrote :

Hi there - just wanted to let you know that this change might have caused a regression in update-manager as described at https://bugs.launchpad.net/ubuntu/+source/update-manager/+bug/2008280 - if you're able to take a quick look that would be much appreciated - thanks!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UpdateManager/UpdateManager.py'
2--- UpdateManager/UpdateManager.py 2022-10-17 06:26:07 +0000
3+++ UpdateManager/UpdateManager.py 2023-01-19 23:22:09 +0000
4@@ -36,12 +36,12 @@
5
6 import distro_info
7 import fnmatch
8-import json
9 import os
10 import subprocess
11 import sys
12 import time
13 from gettext import gettext as _
14+from uaclient.api.u.pro.packages.updates.v1 import updates
15
16 import dbus
17 import dbus.service
18@@ -272,24 +272,10 @@
19
20 def _get_ua_security_status(self):
21 self.ua_security_packages = []
22- try:
23- p = subprocess.Popen(['ua', 'security-status', '--format=json'],
24- stdout=subprocess.PIPE)
25- except OSError:
26- pass
27- else:
28- while p.poll() is None:
29- while Gtk.events_pending():
30- Gtk.main_iteration()
31- time.sleep(0.05)
32- s = json.load(p.stdout)
33- for package in s.get('packages', []):
34- status = package.get('status', '')
35- if status == 'pending_attach':
36- name = package.get('name', '')
37- version = package.get('version', '')
38- size = package.get('download_size', 0)
39- self.ua_security_packages.append((name, version, size))
40+ update_result = updates()
41+ for info in update_result.updates:
42+ if info.status == 'pending_attach':
43+ self.ua_security_packages.append((info.name, info.version, info.download_size))
44
45 def _make_available_pane(self, install_count, need_reboot=False,
46 cancelled_update=False, error_occurred=False):

Subscribers

People subscribed via source and target branches

to status/vote changes: