~ubuntu-core-dev/update-manager/main

« back to all changes in this revision

Viewing changes to UpdateManager/UpdateManager.py

Use uaclient library instead of calling ua tool directly

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
import distro_info
38
38
import fnmatch
39
 
import json
40
39
import os
41
40
import subprocess
42
41
import sys
43
42
import time
44
43
from gettext import gettext as _
 
44
from uaclient.api.u.pro.packages.updates.v1 import updates
45
45
 
46
46
import dbus
47
47
import dbus.service
272
272
 
273
273
    def _get_ua_security_status(self):
274
274
        self.ua_security_packages = []
275
 
        try:
276
 
            p = subprocess.Popen(['pro', 'security-status', '--format=json'],
277
 
                                 stdout=subprocess.PIPE)
278
 
        except OSError:
279
 
            pass
280
 
        else:
281
 
            while p.poll() is None:
282
 
                while Gtk.events_pending():
283
 
                    Gtk.main_iteration()
284
 
                time.sleep(0.05)
285
 
            s = json.load(p.stdout)
286
 
            for package in s.get('packages', []):
287
 
                status = package.get('status', '')
288
 
                if status == 'pending_attach':
289
 
                    name = package.get('package', '')
290
 
                    version = package.get('version', '')
291
 
                    size = package.get('download_size', 0)
292
 
                    self.ua_security_packages.append((name, version, size))
 
275
        update_result = updates()
 
276
        for info in update_result.updates:
 
277
            if info.status == 'pending_attach':
 
278
                self.ua_security_packages.append((info.name, info.version, info.download_size))
293
279
 
294
280
    def _make_available_pane(self, install_count, need_reboot=False,
295
281
                             cancelled_update=False, error_occurred=False):