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

Nathan Teodosio mp+456088 at code.launchpad.net
Mon Dec 4 08:25:28 UTC 2023


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

Diff comments:

> diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py
> index 2e6aed4..9c4219d 100644
> --- a/UpdateManager/UpdateManager.py
> +++ b/UpdateManager/UpdateManager.py
> @@ -276,36 +277,34 @@ class UpdateManager(Gtk.Window):
>              if fnmatch.fnmatch(pkg.name, "oem-*-meta") and pkg.installed:
>                  self.oem_metapackages.add(pkg)
>  
> +    def _fetch_ua_updates(self):
> +        self.ua_updates = ua.updates().updates
> +

I often overlook that, so thanks for the reminder. I think it would be better to do that in a separate merge request indeed.

>      def _get_ua_security_status(self):
>          self.ua_security_packages = []
> -        try:
> -            p = subprocess.Popen(['pro', 'security-status', '--format=json'],
> -                                 stdout=subprocess.PIPE)
> -        except OSError:
> -            pass
> -        else:
> -            while p.poll() is None:
> -                while Gtk.events_pending():
> -                    Gtk.main_iteration()
> -                time.sleep(0.05)
> -            s = json.load(p.stdout)
> -            for package in s.get('packages', []):
> -                if package.get('service_name', '') == 'standard-security':
> -                    continue
> -                status = package.get('status', '')
> -                if (
> -                    status == 'pending_attach'
> -                    or status == 'pending_enable'
> -                    or status == 'upgrade_available'
> -                ):
> -                    name = package.get('package', '')
> -                    version = package.get('version', '')
> -                    size = package.get('download_size', 0)
> -                    downloadable = status == 'upgrade_available'
> -                    self.ua_security_packages.append(
> -                        (name, version, size, downloadable)
> -                    )
> -            self.cache.create_pro_cache(self.ua_security_packages)
> +        t = threading.Thread(target=self._fetch_ua_updates, daemon=True)
> +        t.start()
> +        while t.is_alive():
> +            while Gtk.events_pending():
> +                Gtk.main_iteration()
> +            time.sleep(0.05)
> +        for package in self.ua_updates:
> +            if package.provided_by == 'standard-security':

Are all the possible strings documented somewhere? If I remember correctly I inferred by looking at 'ua security-status --format=json' what were the strings that this routine would not be interested in. I presume they would be the same when using the API too.

> +                continue
> +            status = package.status
> +            if (
> +                status == 'pending_attach'
> +                or status == 'pending_enable'
> +                or status == 'upgrade_available'
> +            ):
> +                name = package.package
> +                version = package.version
> +                size = package.download_size
> +                downloadable = status == 'upgrade_available'

This is indeed used later to label available updates as coming from pro.

> +                self.ua_security_packages.append(
> +                    (name, version, size, downloadable)
> +                )
> +        self.cache.create_pro_cache(self.ua_security_packages)
>  
>      def _make_available_pane(
>          self,


-- 
https://code.launchpad.net/~nteodosio/update-manager/+git/update-manager/+merge/456088
Your team Ubuntu Core Development Team is subscribed to branch update-manager:main.




More information about the Ubuntu-reviews mailing list