[Merge] ~nteodosio/software-properties:drivers-hang into software-properties:ubuntu/master

Nathan Teodosio mp+470812 at code.launchpad.net
Wed Aug 14 21:01:28 UTC 2024



Diff comments:

> diff --git a/softwareproperties/gtk/SoftwarePropertiesGtk.py b/softwareproperties/gtk/SoftwarePropertiesGtk.py
> index 0cced00..251f7b4 100644
> --- a/softwareproperties/gtk/SoftwarePropertiesGtk.py
> +++ b/softwareproperties/gtk/SoftwarePropertiesGtk.py
> @@ -1403,22 +1423,61 @@ class SoftwarePropertiesGtk(SoftwareProperties, SimpleGtkbuilderApp):
>          self.nonfree_drivers = 0
>          self.ui_building = False
>  
> +    def on_detect_drivers_cancel(self, button_cancel):
> +        self.search_process.terminate()
> +        button_cancel.set_sensitive(False)
> +        self.button_detect_drivers_retry.set_sensitive(True)
> +
> +    def on_detect_drivers_retry(self, button_retry):
> +        button_retry.set_sensitive(False)
> +        self.button_detect_drivers_cancel.set_sensitive(True)
> +        self.detect_called = False
> +        self.on_main_notebook_page_switched(None, self.vbox_drivers, None)
> +
> +    def wrapper_system_device_drivers(self, queue, cache):
> +        devices = detect.system_device_drivers(cache)
> +        queue.put_nowait(devices)
> +
>      def detect_drivers(self):
>          # WARNING: This is run in a separate thread.
>          self.detect_called = True
> +        queue = multiprocessing.Queue()
> +        self.search_process = Process(
> +            target=self.wrapper_system_device_drivers,
> +            args=(queue, self.apt_cache,)
> +        )
> +        self.search_process.daemon = True
> +        self.search_process.start()
> +        error = None
>          try:
> -            self.devices = detect.system_device_drivers(self.apt_cache)
> -        except:
> +            self.search_process.join()
> +            if self.search_process.exception:
> +                raise(self.search_process.exception)
> +            if self.search_process.exitcode == 0:
> +                self.devices = queue.get_nowait()
> +            elif self.search_process.exitcode == -15:
> +                error = _("The search for drivers was cancelled.")
> +            else:
> +                error = _("An error occurred while searching for drivers.") + \
> +                    _(" Exit status: ") + str(self.search_process.exitcode) + "."

> I'd keep that string and that's it then.

With that you mean you would keep only "An error occurred while searching for drivers." and not show the exit code, correct?

> We shouldn't bother informing the UI about such technical details, while we indeed should print to stderr what happened in detail.

Very true!

I'm pushing a commit to address this comment and your other one about hardcoding -15, please let me know if I interpreted your remarks incorrectly.

> +        except Exception as e:
>              # Catch all exceptions and feed them to apport.
> -            GLib.idle_add(self.label_driver_detail.set_text,
> -                          _("An error occurred while searching for drivers."))
> +            error = _("An error occurred while searching for drivers: %s") % e
>  
>              # For apport to catch this exception. See
>              # http://bugs.python.org/issue1230540
>              sys.excepthook(*sys.exc_info())
> +
> +        GLib.idle_add(lambda: self.on_detect_drivers_done(error))
> +
> +    def on_detect_drivers_done(self, err=None):
> +        if err is None:
> +            self.show_drivers()
>              return
>  
> -        GLib.idle_add(self.show_drivers)
> +        self.label_driver_detail.set_text(err)
> +        self.button_detect_drivers_retry.set_sensitive(True)
> +        self.button_detect_drivers_cancel.set_sensitive(False)
>  
>      def on_driver_selection_changed(self, button, modalias, pkg_name=None):
>          if self.ui_building:


-- 
https://code.launchpad.net/~nteodosio/software-properties/+git/software-properties/+merge/470812
Your team Ubuntu Core Development Team is requested to review the proposed merge of ~nteodosio/software-properties:drivers-hang into software-properties:ubuntu/master.




More information about the Ubuntu-reviews mailing list