예제 #1
0
 def is_pertinent(self):
     # Defines whether this report should show up
     self.drivers = []
     try:
         from UbuntuDrivers import detect
         devices = detect.system_device_drivers()
         for device_id in devices:
             device = devices[device_id]
             device_name = "%s %s" % (device['vendor'], device['model'])
             if "virtualbox" in device_name.lower(
             ) or "vmware" in device_name.lower():
                 print("Ignoring %s" % device_name)
                 # Ignore them, they're not recommended
                 continue
             packages = []
             for driver_name in device['drivers']:
                 driver = device['drivers'][driver_name]
                 if 'builtin' in driver.keys(
                 ) and driver['builtin'] == True:
                     continue
                 packages.append(driver_name)
             any_installed = False
             for pkg in packages:
                 # Check if the package is installed
                 if os.path.exists("/var/lib/dpkg/info/%s.list" % pkg):
                     any_installed = True
                     break
             if not any_installed:
                 self.drivers.append(device_name)
         return (len(self.drivers) > 0)
     except Exception as e:
         print("Failed to assess drivers availability: %s" % e)
         return False
예제 #2
0
def showdrivers():
    apt_cache = apt.Cache()
    devices = detect.system_device_drivers()
    nonfree_drivers = 0
    for device in devices:
        for pkg_name in devices[device]['drivers']:
            if not apt_cache[pkg_name].is_installed:
                nonfree_drivers += 1

    if nonfree_drivers > 0:
        return True
    else:
        return False
예제 #3
0
    def init_drivers(self):
        """Additional Drivers tab"""

        self.button_driver_revert = Gtk.Button(label=_("Re_vert"),
                                               use_underline=True)
        self.button_driver_revert.connect("clicked",
                                          self.on_driver_changes_revert)
        self.button_driver_apply = Gtk.Button(label=_("_Apply Changes"),
                                              use_underline=True)
        self.button_driver_apply.connect("clicked",
                                         self.on_driver_changes_apply)
        self.button_driver_cancel = Gtk.Button(label=_("_Cancel"),
                                               use_underline=True)
        self.button_driver_cancel.connect("clicked",
                                          self.on_driver_changes_cancel)
        self.button_driver_restart = Gtk.Button(label=_("_Restart..."),
                                                use_underline=True)
        self.button_driver_restart.connect("clicked",
                                           self.on_driver_restart_clicked)
        self.button_driver_revert.set_sensitive(False)
        self.button_driver_revert.set_visible(True)
        self.button_driver_apply.set_sensitive(False)
        self.button_driver_apply.set_visible(True)
        self.button_driver_cancel.set_visible(False)
        self.button_driver_restart.set_visible(False)
        self.box_driver_action.pack_end(self.button_driver_apply, False, False,
                                        0)
        self.box_driver_action.pack_end(self.button_driver_revert, False,
                                        False, 0)
        self.box_driver_action.pack_end(self.button_driver_restart, False,
                                        False, 0)
        self.box_driver_action.pack_end(self.button_driver_cancel, False,
                                        False, 0)

        self.progress_bar = Gtk.ProgressBar()
        self.box_driver_action.pack_end(self.progress_bar, False, False, 0)
        self.progress_bar.set_visible(False)

        self.devices = detect.system_device_drivers()
        self.driver_changes = []
        self.orig_selection = {}
        # HACK: the case where the selection is actually "Do not use"; is a little
        #       tricky to implement because you can't check for whether a package is
        #       installed or any such thing. So let's keep a list of all the
        #       "Do not use" radios, set those active first, then iterate through
        #       orig_selection when doing a Reset.
        self.no_drv = []
        self.nonfree_drivers = 0
        self.ui_building = False
예제 #4
0
 def have_nvidia_graphics_card(self):
     self.devices = detect.system_device_drivers()
     for device in sorted(self.devices.keys()):
         (overall_status, icon,
          drivers) = self.gather_device_data(self.devices[device])
         model_name = self.devices[device].get('model', None)
         vendor_name = self.devices[device].get('vendor', None)
         if vendor_name is None and model_name is None:
             device_name = _("Unknown")
         elif vendor_name is None:
             device_name = model_name
         elif model_name is None:
             device_name = vendor_name
         else:
             device_name = "%s: %s" % (vendor_name, model_name)
         if "NVIDIA" in device_name:
             return True
         else:
             return False
예제 #5
0
  def init_drivers(self):
    """Additional Drivers tab"""

    self.button_driver_revert = Gtk.Button(label=_("Re_vert"), use_underline=True)
    self.button_driver_revert.connect("clicked", self.on_driver_changes_revert)
    self.button_driver_apply = Gtk.Button(label=_("_Apply Changes"), use_underline=True)
    self.button_driver_apply.connect("clicked", self.on_driver_changes_apply)
    self.button_driver_cancel = Gtk.Button(label=_("_Cancel"), use_underline=True)
    self.button_driver_cancel.connect("clicked", self.on_driver_changes_cancel)
    self.button_driver_restart = Gtk.Button(label=_("_Restart..."), use_underline=True)
    self.button_driver_restart.connect("clicked", self.on_driver_restart_clicked)
    self.button_driver_revert.set_sensitive(False)
    self.button_driver_revert.set_visible(True)
    self.button_driver_apply.set_sensitive(False)
    self.button_driver_apply.set_visible(True)
    self.button_driver_cancel.set_visible(False)
    self.button_driver_restart.set_visible(False)
    self.box_driver_action.pack_end(self.button_driver_apply, False, False, 0)
    self.box_driver_action.pack_end(self.button_driver_revert, False, False, 0)
    self.box_driver_action.pack_end(self.button_driver_restart, False, False, 0)
    self.box_driver_action.pack_end(self.button_driver_cancel, False, False, 0)

    self.progress_bar = Gtk.ProgressBar()
    self.box_driver_action.pack_end(self.progress_bar, False, False, 0)
    self.progress_bar.set_visible(False)

    self.devices = detect.system_device_drivers()
    self.driver_changes = []
    self.orig_selection = {}
    # HACK: the case where the selection is actually "Do not use"; is a little
    #       tricky to implement because you can't check for whether a package is
    #       installed or any such thing. So let's keep a list of all the 
    #       "Do not use" radios, set those active first, then iterate through
    #       orig_selection when doing a Reset.
    self.no_drv = []
    self.nonfree_drivers = 0
    self.ui_building = False
예제 #6
0
    def show_drivers(self):
        self.apt_cache = apt.Cache()
        self.devices = detect.system_device_drivers()
        self.driver_changes = []
        self.orig_selection = {}
        # HACK: the case where the selection is actually "Do not use"; is a little
        #       tricky to implement because you can't check for whether a package is
        #       installed or any such thing. So let's keep a list of all the
        #       "Do not use" radios, set those active first, then iterate through
        #       orig_selection when doing a Reset.
        self.no_drv = []
        self.nonfree_drivers = 0
        self.ui_building = True
        self.dynamic_device_status = {}
        if len(self.devices) != 0:
            for device in sorted(self.devices.keys()):
                (overall_status, icon,
                 drivers) = self.gather_device_data(self.devices[device])
                is_cpu = False
                if "intel-microcode" in self.devices[device][
                        'drivers'] or "amd64-microcode" in self.devices[
                            device]['drivers']:
                    is_cpu = True
                    overall_status = _("Processor microcode")
                brand_icon = Gtk.Image()
                brand_icon.set_valign(Gtk.Align.START)
                brand_icon.set_halign(Gtk.Align.CENTER)
                brand_icon.set_from_pixbuf(
                    self.get_device_icon(self.devices[device]))
                driver_status = Gtk.Image()
                driver_status.set_valign(Gtk.Align.START)
                driver_status.set_halign(Gtk.Align.CENTER)
                driver_status.set_from_icon_name(icon, Gtk.IconSize.MENU)
                device_box = Gtk.Box(spacing=6,
                                     orientation=Gtk.Orientation.HORIZONTAL)
                device_box.pack_start(brand_icon, False, False, 6)
                device_detail = Gtk.Box(spacing=6,
                                        orientation=Gtk.Orientation.VERTICAL)
                device_box.pack_start(device_detail, True, True, 0)
                model_name = self.devices[device].get('model', None)
                vendor_name = self.devices[device].get('vendor', None)
                if is_cpu:
                    device_name = self.get_cpu_name()
                elif vendor_name is None and model_name is None:
                    device_name = _("Unknown")
                elif vendor_name is None:
                    device_name = model_name
                elif model_name is None:
                    device_name = vendor_name
                else:
                    device_name = "%s: %s" % (vendor_name, model_name)
                if "vmware" in device_name.lower(
                ) or "virtualbox" in device_name.lower():
                    print("Ignoring device %s" % device_name)
                    continue
                if drivers["manually_installed"]:
                    print("Ignoring device: %s (manually_installed)" %
                          device_name)
                    continue
                widget = Gtk.Label(device_name)
                widget.set_halign(Gtk.Align.START)
                device_detail.pack_start(widget, True, False, 0)
                widget = Gtk.Label("<small>{}</small>".format(overall_status))
                widget.set_halign(Gtk.Align.START)
                widget.set_use_markup(True)
                device_detail.pack_start(widget, True, False, 0)
                self.dynamic_device_status[device] = (driver_status, widget)

                option_group = None
                # define the order of introspection
                for section in ('recommended', 'alternative',
                                'manually_installed', 'no_driver'):
                    for driver in sorted(drivers[section],
                                         key=lambda x: self.sort_string(
                                             drivers[section], x)):
                        radio_button = Gtk.RadioButton.new(None)
                        label = Gtk.Label()
                        label.set_markup(
                            drivers[section][driver]['description'])
                        radio_button.add(label)
                        if option_group:
                            radio_button.join_group(option_group)
                        else:
                            option_group = radio_button
                        device_detail.pack_start(radio_button, True, False, 0)
                        radio_button.set_active(
                            drivers[section][driver]['selected'])

                        if section == 'no_driver':
                            self.no_drv.append(radio_button)
                            if is_cpu:
                                label.set_markup(
                                    _("Do not update the CPU microcode"))
                        if section in ('manually_install', 'no_driver') or (
                                'builtin' in drivers[section][driver]
                                and drivers[section][driver]['builtin']):
                            radio_button.connect(
                                "toggled", self.on_driver_selection_changed,
                                device)
                        else:
                            radio_button.connect(
                                "toggled", self.on_driver_selection_changed,
                                device, driver)
                        if drivers[
                                'manually_installed'] and section != 'manually_installed' and "firmware" not in str(
                                    driver):
                            radio_button.set_sensitive(False)

                self.box_driver_detail.pack_start(device_box, False, False, 6)
        else:
            print("Your computer does not need any additional drivers")
            device_box = Gtk.Box(spacing=0,
                                 orientation=Gtk.Orientation.VERTICAL)

            device_detail = Gtk.Box(spacing=0,
                                    orientation=Gtk.Orientation.VERTICAL)
            device_box.pack_start(device_detail, True, True, 0)

            NO_DRIVERS_MSG = _(
                "Your computer does not need any additional drivers")
            self.builder.get_object("label_no_drivers").set_text(
                NO_DRIVERS_MSG)
            self.builder.get_object("no_drivers_status").set_from_icon_name(
                "object-select-symbolic", 96)
            device_detail.pack_start(self.builder.get_object("no_drivers"),
                                     True, True, 0)

            self.box_driver_detail.pack_start(device_box, True, True, 0)

        self.ui_building = False
        self.box_driver_detail.show_all()
        self.set_driver_action_status()
예제 #7
0
    def show_drivers(self):
        self.apt_cache = apt.Cache()
        self.devices = detect.system_device_drivers()
        self.driver_changes = []
        self.orig_selection = {}
        # HACK: the case where the selection is actually "Do not use"; is a little
        #       tricky to implement because you can't check for whether a package is
        #       installed or any such thing. So let's keep a list of all the
        #       "Do not use" radios, set those active first, then iterate through
        #       orig_selection when doing a Reset.
        self.no_drv = []
        self.nonfree_drivers = 0
        self.ui_building = True
        self.dynamic_device_status = {}
        for device in sorted(self.devices.keys()):
            (overall_status, icon, drivers) = self.gather_device_data(self.devices[device])
            brand_icon = Gtk.Image()
            brand_icon.set_valign(Gtk.Align.START)
            brand_icon.set_halign(Gtk.Align.CENTER)
            brand_icon.set_from_file(self.get_device_icon(self.devices[device]))
            driver_status = Gtk.Image()
            driver_status.set_valign(Gtk.Align.START)
            driver_status.set_halign(Gtk.Align.CENTER)
            driver_status.set_from_icon_name(icon, Gtk.IconSize.MENU)
            device_box = Gtk.Box(spacing=6, orientation=Gtk.Orientation.HORIZONTAL)
            device_box.pack_start(brand_icon, False, False, 6)
            device_detail = Gtk.Box(spacing=6, orientation=Gtk.Orientation.VERTICAL)
            device_box.pack_start(device_detail, True, True, 0)
            model_name = self.devices[device].get('model', None)
            vendor_name = self.devices[device].get('vendor', None)
            if vendor_name is None and model_name is None:
                device_name = _("Unknown")
            elif vendor_name is None:
                device_name = model_name
            elif model_name is None:
                device_name = vendor_name
            else:
                device_name = "%s: %s" % (vendor_name, model_name)
            widget = Gtk.Label(device_name)
            widget.set_halign(Gtk.Align.START)
            device_detail.pack_start(widget, True, False, 0)
            widget = Gtk.Label("<small>{}</small>".format(overall_status))
            widget.set_halign(Gtk.Align.START)
            widget.set_use_markup(True)
            device_detail.pack_start(widget, True, False, 0)
            self.dynamic_device_status[device] = (driver_status, widget)

            option_group = None
            # define the order of introspection
            for section in ('recommended', 'alternative', 'manually_installed', 'no_driver'):
                for driver in sorted(drivers[section], key=lambda x: self.sort_string(drivers[section], x)):
                    radio_button = Gtk.RadioButton.new(None)
                    label = Gtk.Label()
                    label.set_markup(drivers[section][driver]['description'])
                    radio_button.add(label)
                    if option_group:
                        radio_button.join_group(option_group)
                    else:
                        option_group = radio_button
                    device_detail.pack_start(radio_button, True, False, 0)
                    radio_button.set_active(drivers[section][driver]['selected'])

                    if section == 'no_driver':
                        self.no_drv.append(radio_button)
                    if section in ('manually_install', 'no_driver') or ('builtin' in drivers[section][driver] and drivers[section][driver]['builtin']):
                        radio_button.connect("toggled", self.on_driver_selection_changed, device)
                    else:
                        radio_button.connect("toggled", self.on_driver_selection_changed, device, driver)
                    if drivers['manually_installed'] and section != 'manually_installed' and "firmware" not in str(driver):
                        radio_button.set_sensitive(False)

            self.box_driver_detail.pack_start(device_box, False, False, 6)

        self.ui_building = False
        self.box_driver_detail.show_all()
        self.set_driver_action_status()
예제 #8
0
    def show_drivers(self):
        self.apt_cache = apt.Cache()
        self.devices = detect.system_device_drivers()
        self.driver_changes = []
        self.orig_selection = {}
        # HACK: the case where the selection is actually "Do not use"; is a little
        #       tricky to implement because you can't check for whether a package is
        #       installed or any such thing. So let's keep a list of all the
        #       "Do not use" radios, set those active first, then iterate through
        #       orig_selection when doing a Reset.
        self.no_drv = []
        self.nonfree_drivers = 0
        self.ui_building = True
        self.dynamic_device_status = {}
        #print(self.devices.keys())
        for device in sorted(self.devices):
            (overall_status, icon,
             drivers) = self.gather_device_data(self.devices[device])
            print(self.devices[device])
            print("overall_status is %s" % overall_status)
            print("icon is %s" % icon)
            print("drivers is %s" % drivers)
            print("device is %s" % device)
            brand_icon = Gtk.Image()
            brand_icon.set_valign(Gtk.Align.START)
            brand_icon.set_halign(Gtk.Align.CENTER)
            brand_icon.set_from_file(self.get_device_icon(
                self.devices[device]))
            driver_status = Gtk.Image()
            driver_status.set_valign(Gtk.Align.START)
            driver_status.set_halign(Gtk.Align.CENTER)
            driver_status.set_from_icon_name(icon, Gtk.IconSize.MENU)
            device_box = Gtk.Box(spacing=6,
                                 orientation=Gtk.Orientation.HORIZONTAL)
            device_box.pack_start(brand_icon, False, False, 6)
            device_detail = Gtk.Box(spacing=6,
                                    orientation=Gtk.Orientation.VERTICAL)
            device_box.pack_start(device_detail, True, True, 0)
            model_name = self.devices[device].get('model', None)
            vendor_name = self.devices[device].get('vendor', None)
            if vendor_name is None and model_name is None:
                device_name = _("Unknown")
            elif vendor_name is None:
                device_name = model_name
            elif model_name is None:
                device_name = vendor_name
            else:
                device_name = "%s: %s" % (vendor_name, model_name)
            if device == "bumblebee_device":
                device_name = "Bumblebee"
                overall_status = _(
                    "We detected you have an Optimus notebook, bumblebee-nvidia will be installed with nvidia-driver."
                )
            widget = Gtk.Label(device_name)
            widget.set_halign(Gtk.Align.START)
            device_detail.pack_start(widget, True, False, 0)
            widget = Gtk.Label("<small>{}</small>".format(overall_status))
            widget.set_halign(Gtk.Align.START)
            widget.set_use_markup(True)
            device_detail.pack_start(widget, True, False, 0)
            self.dynamic_device_status[device] = (driver_status, widget)

            option_group = None
            # define the order of introspection
            for section in ('recommended', 'alternative', 'manually_installed',
                            'no_driver'):
                for driver in sorted(
                        drivers[section],
                        key=lambda x: self.sort_string(drivers[section], x)):
                    radio_button = Gtk.RadioButton.new(None)
                    label = Gtk.Label()
                    label.set_markup(drivers[section][driver]['description'])
                    radio_button.add(label)
                    if option_group:
                        radio_button.join_group(option_group)
                    else:
                        option_group = radio_button
                    device_detail.pack_start(radio_button, True, False, 0)
                    radio_button.set_active(
                        drivers[section][driver]['selected'])

                    if section == 'no_driver':
                        self.no_drv.append(radio_button)
                    if section in ('manually_install', 'no_driver') or (
                            'builtin' in drivers[section][driver]
                            and drivers[section][driver]['builtin']):
                        radio_button.connect("toggled",
                                             self.on_driver_selection_changed,
                                             device)
                    else:
                        radio_button.connect("toggled",
                                             self.on_driver_selection_changed,
                                             device, driver)
                    if drivers[
                            'manually_installed'] and section != 'manually_installed' and "firmware" not in str(
                                driver):
                        radio_button.set_sensitive(False)

            self.box_driver_detail.pack_start(device_box, False, False, 6)

        self.ui_building = False
        self.box_driver_detail.show_all()
        self.set_driver_action_status()
예제 #9
0
 def get_drivers_async(self):
     self.apt_cache = apt.Cache()
     self.devices = detect.system_device_drivers()
     self.show_drivers()