Merge ~nteodosio/update-manager:no-ua-shell into update-manager:main

Proposed by Nathan Teodosio
Status: Merged
Approved by: Sebastien Bacher
Approved revision: 9706d15486bd1b61190426df2aed8ec8714ccd3c
Merged at revision: 9706d15486bd1b61190426df2aed8ec8714ccd3c
Proposed branch: ~nteodosio/update-manager:no-ua-shell
Merge into: update-manager:main
Diff against target: 90 lines (+31/-29)
1 file modified
UpdateManager/UpdateManager.py (+31/-29)
Reviewer Review Type Date Requested Status
Grant Orndorff (community) Approve
Sebastien Bacher Approve
Review via email: mp+456088@code.launchpad.net

Description of the change

Drop call to ua security-status --format=json. Use uaclient.api.u.pro.packages.updates.v1.updates instead.

To post a comment you must log in.
Revision history for this message
Grant Orndorff (orndorffgrant) wrote :

Some small questions and comments but generally looks good!

Revision history for this message
Nathan Teodosio (nteodosio) wrote :

Thanks for the review, Grant, I responded to your comments.

Revision history for this message
Grant Orndorff (orndorffgrant) :
Revision history for this message
Nathan Teodosio (nteodosio) :
Revision history for this message
Sebastien Bacher (seb128) wrote :

Seems fine from my perspective, I think Grant's comment also got addressed so we should be good to go ... Grant can you confirm it's now fine for you?

review: Approve
Revision history for this message
Nathan Teodosio (nteodosio) wrote :

By the way, I submited this to build in a PPA for subsequent autopkgtesting, as I'm no match for the linters.

Revision history for this message
Nathan Teodosio (nteodosio) wrote :

Autopkgtests ran successfully.

Revision history for this message
Grant Orndorff (orndorffgrant) wrote :

LGTM Thanks!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py
2index 2e6aed4..efe654e 100644
3--- a/UpdateManager/UpdateManager.py
4+++ b/UpdateManager/UpdateManager.py
5@@ -25,6 +25,7 @@ from gi.repository import Gdk, GdkX11
6 from gi.repository import Gio
7 from gi.repository import GLib
8 from gi.repository import GObject
9+import uaclient.api.u.pro.packages.updates.v1 as ua
10
11 GdkX11 # pyflakes
12
13@@ -36,10 +37,10 @@ warnings.filterwarnings(
14
15 import distro_info
16 import fnmatch
17-import json
18 import os
19 import subprocess
20 import sys
21+import threading
22 import time
23 from gettext import gettext as _
24
25@@ -276,36 +277,37 @@ class UpdateManager(Gtk.Window):
26 if fnmatch.fnmatch(pkg.name, "oem-*-meta") and pkg.installed:
27 self.oem_metapackages.add(pkg)
28
29+ def _fetch_ua_updates(self):
30+ self.ua_updates = ua.updates().updates
31+
32 def _get_ua_security_status(self):
33 self.ua_security_packages = []
34- try:
35- p = subprocess.Popen(['pro', 'security-status', '--format=json'],
36- stdout=subprocess.PIPE)
37- except OSError:
38- pass
39- else:
40- while p.poll() is None:
41- while Gtk.events_pending():
42- Gtk.main_iteration()
43- time.sleep(0.05)
44- s = json.load(p.stdout)
45- for package in s.get('packages', []):
46- if package.get('service_name', '') == 'standard-security':
47- continue
48- status = package.get('status', '')
49- if (
50- status == 'pending_attach'
51- or status == 'pending_enable'
52- or status == 'upgrade_available'
53- ):
54- name = package.get('package', '')
55- version = package.get('version', '')
56- size = package.get('download_size', 0)
57- downloadable = status == 'upgrade_available'
58- self.ua_security_packages.append(
59- (name, version, size, downloadable)
60- )
61- self.cache.create_pro_cache(self.ua_security_packages)
62+ t = threading.Thread(target=self._fetch_ua_updates, daemon=True)
63+ t.start()
64+ while t.is_alive():
65+ while Gtk.events_pending():
66+ Gtk.main_iteration()
67+ time.sleep(0.05)
68+ for package in self.ua_updates:
69+ if (
70+ package.provided_by == 'standard-security'
71+ or package.provided_by == 'standard-updates'
72+ ):
73+ continue
74+ status = package.status
75+ if (
76+ status == 'pending_attach'
77+ or status == 'pending_enable'
78+ or status == 'upgrade_available'
79+ ):
80+ name = package.package
81+ version = package.version
82+ size = package.download_size
83+ downloadable = status == 'upgrade_available'
84+ self.ua_security_packages.append(
85+ (name, version, size, downloadable)
86+ )
87+ self.cache.create_pro_cache(self.ua_security_packages)
88
89 def _make_available_pane(
90 self,

Subscribers

People subscribed via source and target branches