Example #1
0
def init_cnchi():
    """ This function initialises Cnchi """

    # Configures gettext to be able to translate messages, using _()
    setup_gettext()
    
    if not check_for_files():
        sys.exit(1)
        
    # Check installed GTK version
    if not check_gtk_version():
        sys.exit(1)

    # Command line options
    global cmd_line
    cmd_line = parse_options()

    if cmd_line.update is not None:
        update_cnchi()
    
    # Drop root privileges
    misc.drop_privileges()
    
    # Init PyObject Threads
    threads_init()

    # Setup our logging framework
    setup_logging()
Example #2
0
def init_cnchi():
    """ This function initialises Cnchi """

    # Configures gettext to be able to translate messages, using _()
    setup_gettext()

    if not check_for_files():
        sys.exit(1)

    # Check installed GTK version
    if not check_gtk_version():
        sys.exit(1)

    # Command line options
    global cmd_line
    cmd_line = parse_options()

    if cmd_line.update is not None:
        update_cnchi()

    # Drop root privileges
    misc.drop_privileges()

    # Init PyObject Threads
    threads_init()

    # Setup our logging framework
    setup_logging()
Example #3
0
def init_thus():
    """ This function initialises Thus """

    # Command line options
    global cmd_line

    if not check_gtk_version():
        sys.exit(1)

    # Command line options
    global cmd_line
    cmd_line = parse_options()

    #setup_logging()

    if cmd_line.update is not None:
        force = False
        if cmd_line.update == 2:
            force = True
        upd = updater.Updater(force)
        if upd.update():
            # Remove /tmp/.setup-running to be able to run another
            # instance of Thus
            remove_temp_files()
            if force:
                # Remove -uu option
                new_argv = []
                for argv in sys.argv:
                    if argv != "-uu":
                        new_argv.append(argv)
            else:
                new_argv = sys.argv
            print("Program updated! Restarting...")
            # Run another instance of Thus (which will be the new version)
            os.execl(sys.executable, *([sys.executable] + new_argv))
            sys.exit(0)

    # Drop root privileges
    misc.drop_privileges()

    # Start Gdk stuff and main window app
    GObject.threads_init()

    myapp = Main()

    Gtk.main()
Example #4
0
def init_thus():
    """ This function initialises Thus """

    # Command line options
    global cmd_line

    if not check_gtk_version():
        sys.exit(1)

    # Command line options
    global cmd_line
    cmd_line = parse_options()

    #setup_logging()

    if cmd_line.update is not None:
        force = False
        if cmd_line.update == 2:
            force = True
        upd = updater.Updater(force)
        if upd.update():
            # Remove /tmp/.setup-running to be able to run another
            # instance of Thus
            remove_temp_files()
            if force:
                # Remove -uu option
                new_argv = []
                for argv in sys.argv:
                    if argv != "-uu":
                        new_argv.append(argv)
            else:
                new_argv = sys.argv
            print("Program updated! Restarting...")
            # Run another instance of Thus (which will be the new version)
            os.execl(sys.executable, *([sys.executable] + new_argv))
            sys.exit(0)

    # Drop root privileges
    misc.drop_privileges()

    # Start Gdk stuff and main window app
    GObject.threads_init()

    myapp = Main()

    Gtk.main()
Example #5
0
    def manage_events_from_cb_queue(self):
        """ We should do as less as possible here, we want to maintain our
            queue message as empty as possible """
        
        if self.fatal_error:
            return False

        while self.callback_queue.empty() == False:
            try:
                event = self.callback_queue.get_nowait()
            except queue.Empty:
                return True

            if event[0] == 'percent':
                self.progress_bar.set_fraction(event[1])
            elif event[0] == 'text':
                if event[1] == 'hide':
                    self.progress_bar.set_show_text(False)
                    self.progress_bar.set_text("")
                else:
                    self.progress_bar.set_show_text(True)
                    self.progress_bar.set_text(event[1])
            elif event[0] == 'pulse':
                if event[1] == 'stop':
                    self.stop_pulse()
                elif event[1] == 'start':
                    self.start_pulse()
            elif event[0] == 'progress_bar':
                if event[1] == 'hide':
                    self.progress_bar.hide()
            elif event[0] == 'finished':
                logging.info(event[1])
                if not self.settings.get('bootloader_ok'):
                    # Warn user about GRUB and ask if we should open wiki page.
                    boot_warn = _("IMPORTANT: There may have been a problem with the Grub(2) bootloader\n"
                                  "installation which could prevent your system from booting properly. Before\n"
                                  "rebooting, you may want to verify whether or not GRUB(2) is installed and\n"
                                  "configured. The Arch Linux Wiki contains troubleshooting information:\n"
                                  "\thttps://wiki.archlinux.org/index.php/GRUB\n"
                                  "\nWould you like to view the wiki page now?")
                    response = show.question(boot_warn)
                    if response == Gtk.ResponseType.YES:
                        import webbrowser
                        misc.drop_privileges()
                        webbrowser.open('https://wiki.archlinux.org/index.php/GRUB')

                install_ok = _("Installation Complete!\nDo you want to restart your system now?")
                response = show.question(install_ok)
                self.remove_temp_files()
                self.settings.set('stop_all_threads', True)
                #while Gtk.events_pending():
                #    Gtk.main_iteration()
                logging.shutdown()
                if response == Gtk.ResponseType.YES:
                    self.reboot()
                else:
                    sys.exit(0)
                return False
            elif event[0] == 'error':
                self.callback_queue.task_done()
                # A fatal error has been issued. We empty the queue
                self.empty_queue()

                # Show the error
                show.fatal_error(event[1])

                # Ask if user wants to retry
                res = show.question(_("Do you want to retry the installation using the same configuration?"))
                if res == GTK_RESPONSE_YES:
                    # Restart installation process
                    logging.debug(_("Restarting installation process..."))
                    p = self.settings.get('installer_thread_call')

                    self.process = installation_process.InstallationProcess(self.settings, self.callback_queue,
                        p['mount_devices'], p['fs_devices'], p['ssd'], p['alternate_package_list'], p['blvm'])

                    self.process.start()
                    return True
                else:
                    self.fatal_error = True
                    return False
            elif event[0] == 'info':
                logging.info(event[1])
                if self.should_pulse:
                    self.progress_bar.set_text(event[1])
                else:
                    self.set_message(event[1])

            self.callback_queue.task_done()

        return True
Example #6
0
    def manage_events_from_cb_queue(self):
        """ We should do as less as possible here, we want to maintain our
            queue message as empty as possible """

        if self.fatal_error:
            return False

        while self.callback_queue.empty() == False:
            try:
                event = self.callback_queue.get_nowait()
            except queue.Empty:
                return True

            if event[0] == 'percent':
                self.progress_bar.set_fraction(event[1])
            elif event[0] == 'text':
                if event[1] == 'hide':
                    self.progress_bar.set_show_text(False)
                    self.progress_bar.set_text("")
                else:
                    self.progress_bar.set_show_text(True)
                    self.progress_bar.set_text(event[1])
            elif event[0] == 'pulse':
                if event[1] == 'stop':
                    self.stop_pulse()
                elif event[1] == 'start':
                    self.start_pulse()
            elif event[0] == 'progress_bar':
                if event[1] == 'hide':
                    self.progress_bar.hide()
            elif event[0] == 'finished':
                logging.info(event[1])
                if not self.settings.get('bootloader_ok'):
                    # Warn user about GRUB and ask if we should open wiki page.
                    boot_warn = _(
                        "IMPORTANT: There may have been a problem with the Grub(2) bootloader\n"
                        "installation which could prevent your system from booting properly. Before\n"
                        "rebooting, you may want to verify whether or not GRUB(2) is installed and\n"
                        "configured. The Arch Linux Wiki contains troubleshooting information:\n"
                        "\thttps://wiki.archlinux.org/index.php/GRUB\n"
                        "\nWould you like to view the wiki page now?")
                    response = show.question(boot_warn)
                    if response == Gtk.ResponseType.YES:
                        import webbrowser
                        misc.drop_privileges()
                        webbrowser.open(
                            'https://wiki.archlinux.org/index.php/GRUB')

                install_ok = _(
                    "Installation Complete!\nDo you want to restart your system now?"
                )
                response = show.question(install_ok)
                self.remove_temp_files()
                self.settings.set('stop_all_threads', True)
                logging.shutdown()
                if response == Gtk.ResponseType.YES:
                    self.reboot()
                else:
                    sys.exit(0)
                return False
            elif event[0] == 'error':
                self.callback_queue.task_done()
                # A fatal error has been issued. We empty the queue
                self.empty_queue()

                # Show the error
                show.fatal_error(event[1])

                # Ask if user wants to retry
                res = show.question(
                    _("Do you want to retry the installation using the same configuration?"
                      ))
                if res == GTK_RESPONSE_YES:
                    # Restart installation process
                    logging.debug(_("Restarting installation process..."))
                    p = self.settings.get('installer_thread_call')

                    self.process = installation_process.InstallationProcess(
                        self.settings, self.callback_queue, p['mount_devices'],
                        p['fs_devices'], p['ssd'], p['alternate_package_list'],
                        p['blvm'])

                    self.process.start()
                    return True
                else:
                    self.fatal_error = True
                    return False
            elif event[0] == 'info':
                logging.info(event[1])
                if self.should_pulse:
                    self.progress_bar.set_text(event[1])
                else:
                    self.set_message(event[1])

            self.callback_queue.task_done()

        return True