Beispiel #1
0
    def on_btnInstall_clicked(self, widget):
        actionNr = self.pages[self.currentPage][0]
        if actionNr > 0:
            # Check if there is an internet connection
            if not hasInternetConnection():
                title = _("No internet connection")
                msg = _(
                    "You need an internet connection to install the additional software.\n"
                    "Please, connect to the internet and try again.")
                MessageDialogSafe(title, msg, Gtk.MessageType.WARNING,
                                  self.window).show()
                return

            self.set_buttons_state(False)

            # Check for installation script
            msg = _("Please enter your password")
            page = self.pages[self.currentPage][1]
            script = join(self.scriptDir, "scripts/{}".format(page))
            if exists(script):
                if actionNr == 1:
                    self.exec_command(
                        "gksudo -m \"{}\" \"/bin/sh -c {}\"".format(
                            msg, script))
                elif actionNr == 2:
                    os.system("/bin/sh -c \"{}\" &".format(script))
                    self.set_buttons_state(True)
            else:
                msg = _("Cannot install the requested software:\n"
                        "Script not found: {}".format(script))
                MessageDialogSafe(self.btnInstall.get_label(), msg,
                                  Gtk.MessageType.ERROR, self.window).show()
    def on_btnInstall_clicked(self, widget):
        actionNr = self.pages[self.currentPage][0]
        if actionNr > 0:
            # Check if there is an internet connection
            if not hasInternetConnection():
                title = _("No internet connection")
                msg = _("You need an internet connection to install the additional software.\n"
                        "Please, connect to the internet and try again.")
                MessageDialogSafe(title, msg, Gtk.MessageType.WARNING, self.window).show()
                return

            self.set_buttons_state(False)

            # Check for installation script
            msg = _("Please enter your password")
            page = self.pages[self.currentPage][1]
            script = join(self.scriptDir, "scripts/{}".format(page))
            if exists(script):
                if actionNr == 1:
                    self.exec_command("gksudo -m \"{}\" \"/bin/sh -c {}\"".format(msg, script))
                elif actionNr == 2:
                    os.system("/bin/sh -c \"{}\" &".format(script))
                    self.set_buttons_state(True)
            else:
                msg = _("Cannot install the requested software:\n"
                        "Script not found: {}".format(script))
                MessageDialogSafe(self.btnInstall.get_label(), msg, Gtk.MessageType.ERROR, self.window).show()
    def on_btnSave_clicked(self, widget):
        # Save selected hardware
        arguments = []

        model = self.tvDDM.get_model()
        itr = model.get_iter_first()
        while itr is not None:
            action = 'no change'
            selected = model.get_value(itr, 0)
            device = model.get_value(itr, 2)
            manufacturerId = ''

            # Check currently selected state with initial state
            # This decides whether we should install or purge the drivers
            for hw in self.hardware:
                self.log.write("Device = {} in {}".format(device, hw[2]), 'on_btnSave_clicked')
                if device in hw[2]:
                    manufacturerId = hw[4]
                    if hw[0] and not selected:
                        action = 'purge'
                    elif not hw[0] and selected:
                        action = 'install'
                    break

            self.log.write("{}: {} ({})".format(action, device, manufacturerId), 'on_btnSave_clicked')

            # Install/purge selected driver
            option = ""
            if action == 'install':
                option = "-i"
            elif action == 'purge':
                option = "-p"

            if option:
                driver = ''
                # Run the manufacturer specific bash script
                if manufacturerId == '1002':
                    driver = 'ati'
                elif manufacturerId == '10de':
                    driver = 'nvidia '
                elif manufacturerId == '14e4':
                    driver = 'broadcom '
                elif 'pae' in manufacturerId:
                    driver = 'pae '
                if driver:
                    arguments.append("{} {}".format(option, driver))

            # Get the next in line
            itr = model.iter_next(itr)

        # Execute the command
        if arguments:
            if '-i' in arguments and not hasInternetConnection():
                title = _("No internet connection")
                msg = _("You need an internet connection to install the additional software.\n"
                        "Please, connect to the internet and try again.")
                WarningDialog(title, msg)
            else:
                # Warn for use of Backports
                if self.chkBackports.get_active():
                    answer = QuestionDialog(self.chkBackports.get_label(),
                            _("You have selected to install drivers from the backports repository whenever they are available.\n\n"
                              "Although you can run more up to date software using the backports repository,\n"
                              "you introduce a greater risk of breakage doing so.\n\n"
                              "Are you sure you want to continue?"))
                    if not answer:
                        self.chkBackports.set_active(False)
                        return True
                    arguments.append("-b")

                # Testing
                if self.test:
                    arguments.append("-t")

                command = "ddm {}".format(" ".join(arguments))
                self.log.write("Command to execute: {}".format(command), 'on_btnSave_clicked')
                self.exec_command(command)
Beispiel #4
0
    def on_btnSave_clicked(self, widget):
        # Save selected hardware
        arguments = []

        model = self.tvDDM.get_model()
        itr = model.get_iter_first()
        while itr is not None:
            action = 'no change'
            selected = model.get_value(itr, 0)
            device = model.get_value(itr, 2)
            manufacturerId = ''

            # Check currently selected state with initial state
            # This decides whether we should install or purge the drivers
            for hw in self.hardware:
                self.log.write("Device = {} in {}".format(device, hw[2]),
                               'on_btnSave_clicked')
                if device in hw[2]:
                    manufacturerId = hw[4]
                    if hw[0] and not selected:
                        action = 'purge'
                    elif not hw[0] and selected:
                        action = 'install'
                    break

            self.log.write(
                "{}: {} ({})".format(action, device, manufacturerId),
                'on_btnSave_clicked')

            # Install/purge selected driver
            option = ""
            if action == 'install':
                option = "-i"
            elif action == 'purge':
                option = "-p"

            if option:
                driver = ''
                # Run the manufacturer specific bash script
                if manufacturerId == '1002':
                    driver = 'ati'
                elif manufacturerId == '10de':
                    driver = 'nvidia '
                elif manufacturerId == '14e4':
                    driver = 'broadcom '
                elif 'pae' in manufacturerId:
                    driver = 'pae '
                if driver:
                    arguments.append("{} {}".format(option, driver))

            # Get the next in line
            itr = model.iter_next(itr)

        # Execute the command
        if arguments:
            if '-i' in arguments and not hasInternetConnection():
                title = _("No internet connection")
                msg = _(
                    "You need an internet connection to install the additional software.\n"
                    "Please, connect to the internet and try again.")
                WarningDialog(title, msg)
            else:
                # Warn for use of Backports
                if self.chkBackports.get_active():
                    answer = QuestionDialog(
                        self.chkBackports.get_label(),
                        _("You have selected to install drivers from the backports repository whenever they are available.\n\n"
                          "Although you can run more up to date software using the backports repository,\n"
                          "you introduce a greater risk of breakage doing so.\n\n"
                          "Are you sure you want to continue?"))
                    if not answer:
                        self.chkBackports.set_active(False)
                        return True
                    arguments.append("-b")

                # Testing
                if self.test:
                    arguments.append("-t")

                command = "ddm {}".format(" ".join(arguments))
                self.log.write("Command to execute: {}".format(command),
                               'on_btnSave_clicked')
                self.exec_command(command)