Esempio n. 1
0
def update_cnchi():
    """ Runs updater function to update cnchi to the latest version if necessary """
    upd = updater.Updater(
        force_update=cmd_line.update,
        local_cnchi_version=info.CNCHI_VERSION)

    if upd.update():
        logging.info("Program updated! Restarting...")
        misc.remove_temp_files()
        if cmd_line.update:
            # Remove -u and --update options from new call
            new_argv = []
            for argv in sys.argv:
                if argv != "-u" and argv != "--update":
                    new_argv.append(argv)
        else:
            new_argv = sys.argv

        # Do not try to update again now
        new_argv.append("--disable-update")

        # Run another instance of Cnchi (which will be the new version)
        with misc.raised_privileges():
            os.execl(sys.executable, *([sys.executable] + new_argv))
        sys.exit(0)
Esempio n. 2
0
 def quit_cnchi(self):
     misc.remove_temp_files()
     for proc in self.process_list:
         # Wait 'timeout' seconds at most for all processes to end
         proc.join(timeout=5)
         if proc.is_alive():
             proc.terminate()
             proc.join()
     logging.shutdown()
     sys.exit(0)
Esempio n. 3
0
 def quit_cnchi(self):
     misc.remove_temp_files()
     for proc in self.process_list:
         # Wait 'timeout' seconds at most for all processes to end
         proc.join(timeout=5)
         if proc.is_alive():
             proc.terminate()
             proc.join()
     logging.shutdown()
     sys.exit(0)
Esempio n. 4
0
 def on_exit_button_clicked(self, widget, data=None):
     """ Quit Cnchi """
     try:
         misc.remove_temp_files()
         logging.info("Quiting installer...")
         for proc in self.process_list:
             if proc.is_alive():
                 proc.terminate()
                 proc.join()
         logging.shutdown()
     except KeyboardInterrupt:
         pass
Esempio n. 5
0
def init_cnchi():
    """ This function initialises Cnchi """

    # Sets SIGTERM handler, so Cnchi can clean up before exiting
    # signal.signal(signal.SIGTERM, sigterm_handler)

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

    # Command line options
    global cmd_line
    cmd_line = parse_options()

    if cmd_line.version:
        print(
            _("Cnchi (Reborn OS Installer) version {0}").format(
                info.CNCHI_VERSION))
        sys.exit(0)

    if cmd_line.force:
        misc.remove_temp_files()

    # Drop root privileges
    misc.drop_privileges()

    # Setup our logging framework
    setup_logging()

    # Check Cnchi is correctly installed
    if not check_for_files():
        sys.exit(1)

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

    # Check installed pyalpm and libalpm versions
    if not check_pyalpm_version():
        sys.exit(1)

    # Check ISO version where Cnchi is running from
    if not check_iso_version():
        sys.exit(1)

    # if not cmd_line.disable_update:
    # update_cnchi()

    # Init PyObject Threads
    threads_init()
Esempio n. 6
0
def init_cnchi():
    """ This function initialises Cnchi """

    # Sets SIGTERM handler, so Cnchi can clean up before exiting
    # signal.signal(signal.SIGTERM, sigterm_handler)

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

    # Command line options
    global cmd_line
    cmd_line = parse_options()


    if cmd_line.version:
        print(_("Cnchi (Antergos Installer) version {0}").format(info.CNCHI_VERSION))
        sys.exit(0)

    if cmd_line.force:
        misc.remove_temp_files()

    # Drop root privileges
    misc.drop_privileges()

    # Setup our logging framework
    setup_logging()

    # Check Cnchi is correctly installed
    if not check_for_files():
        sys.exit(1)

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

    # Check installed pyalpm and libalpm versions
    if not check_pyalpm_version():
        sys.exit(1)

    # Check ISO version where Cnchi is running from
    if not check_iso_version():
        sys.exit(1)

    # if not cmd_line.disable_update:
        # update_cnchi()

    # Init PyObject Threads
    threads_init()
Esempio n. 7
0
def update_cnchi():
    """ Runs updater function to update cnchi to the latest version if necessary """
    upd = updater.Updater(force_update=cmd_line.update,
                          local_cnchi_version=info.CNCHI_VERSION)

    if upd.update():
        logging.info("Program updated! Restarting...")
        misc.remove_temp_files()
        if cmd_line.update:
            # Remove -u and --update options from new call
            new_argv = []
            for argv in sys.argv:
                if argv != "-u" and argv != "--update":
                    new_argv.append(argv)
        else:
            new_argv = sys.argv

        # Do not try to update again now
        new_argv.append("--disable-update")

        # Run another instance of Cnchi (which will be the new version)
        with misc.raised_privileges() as __:
            os.execl(sys.executable, *([sys.executable] + new_argv))
        sys.exit(0)
Esempio n. 8
0
    def manage_events_from_cb_queue(self):
        """ We should be quick here and do as less as possible """

        if self.fatal_error:
            return False

        if self.callback_queue is None:
            return True

        while not self.callback_queue.empty():
            try:
                event = self.callback_queue.get_nowait()
            except ValueError as queue_error:
                # Calling get_nowait so many times can issue a ValueError
                # exception with this error: semaphore or lock released too
                # many times. Log it anyways to keep an eye on this error
                logging.error(queue_error)
                return True
            except queue.Empty:
                # Queue is empty, just quit.
                return True

            if event[0] == 'percent':
                self.progress_bar.set_fraction(float(event[1]))
            elif event[0] == 'downloads_percent':
                self.downloads_progress_bar.set_fraction(float(event[1]))
            elif event[0] == 'progress_bar_show_text':
                if len(event[1]) > 0:
                    # self.progress_bar.set_show_text(True)
                    self.progress_bar.set_text(event[1])
                else:
                    # self.progress_bar.set_show_text(False)
                    self.progress_bar.set_text("")
            elif event[0] == 'progress_bar':
                if event[1] == 'hide':
                    self.progress_bar.hide()
                elif event[1] == 'show':
                    self.progress_bar.show()
            elif event[0] == 'downloads_progress_bar':
                if event[1] == 'hide':
                    self.downloads_progress_bar.hide()
                elif event[1] == 'show':
                    self.downloads_progress_bar.show()
            elif event[0] == 'pulse':
                if event[1] == 'stop':
                    self.stop_pulse()
                elif event[1] == 'start':
                    self.start_pulse()
            elif event[0] == 'finished':
                logging.info(event[1])
                log_util = ContextFilter()
                log_util.send_install_result("True")
                if (self.settings.get('bootloader_install')):
                    install_ok = _("Installation Complete!\n"
                                   "Do you want to restart your system now?")
                response = show.question(self.get_main_window(), install_ok)
                misc.remove_temp_files()
                logging.shutdown()
                if response == Gtk.ResponseType.YES:
                    self.reboot()
                else:
                    sys.exit(0)
                return False
            elif event[0] == 'error':
                log_util = ContextFilter()
                log_util.send_install_result("False")
                self.callback_queue.task_done()
                # A fatal error has been issued. We empty the queue
                self.empty_queue()

                # Add install id to error message (we can lookup logs on bugsnag by the install id)
                tpl = _(
                    'Please reference the following number when reporting this error: '
                )
                error_message = '{0}\n{1}{2}'.format(event[1], tpl,
                                                     log_util.install_id)

                # Show the error
                show.fatal_error(self.get_main_window(), error_message)
            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])

            elif event[0] == 'cache_pkgs_md5_check_failed':
                logging.debug('Adding %s to cache_pkgs_md5_check_failed list',
                              event[1])
                self.settings.set('cache_pkgs_md5_check_failed', event[1])

            self.callback_queue.task_done()

        return True
Esempio n. 9
0
    def manage_events_from_cb_queue(self):
        """ We should be quick here and do as less as possible """

        if self.fatal_error:
            return False

        if self.callback_queue is None:
            return True

        while not self.callback_queue.empty():
            try:
                event = self.callback_queue.get_nowait()
            except ValueError as queue_error:
                # Calling get_nowait so many times can issue a ValueError
                # exception with this error: semaphore or lock released too
                # many times. Log it anyways to keep an eye on this error
                logging.error(queue_error)
                return True
            except queue.Empty:
                # Queue is empty, just quit.
                return True

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

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

                # Add install id to error message (we can lookup logs on bugsnag by the install id)
                tpl = _(
                    'Please reference the following number when reporting this error: '
                )
                error_message = '{0}\n{1}{2}'.format(event[1], tpl,
                                                     log_util.install_id)

                # Show the error
                show.fatal_error(self.get_main_window(), error_message)
            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])

            elif event[0] == 'cache_pkgs_md5_check_failed':
                logging.debug('Adding %s to cache_pkgs_md5_check_failed list',
                              event[1])
                self.settings.set('cache_pkgs_md5_check_failed', event[1])

            self.callback_queue.task_done()

        return True
Esempio n. 10
0
    def manage_events_from_cb_queue(self):
        """ We should be quick here and do as less as possible """

        if self.fatal_error:
            return False

        if self.callback_queue is None:
            return True

        while not self.callback_queue.empty():
            try:
                event = self.callback_queue.get_nowait()
            except ValueError as queue_error:
                # Calling get_nowait so many times can issue a ValueError
                # exception with this error: semaphore or lock released too
                # many times. Log it anyways to keep an eye on this error
                logging.error(queue_error)
                return True
            except queue.Empty:
                # Queue is empty, just quit.
                return True

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

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

                # Show the error
                show.fatal_error(self.get_main_window(), event[1])
            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])

            elif event[0] == 'cache_pkgs_md5_check_failed':
                logging.debug(
                    'Adding %s to cache_pkgs_md5_check_failed list',
                    event[1])
                self.settings.set('cache_pkgs_md5_check_failed', event[1])

            self.callback_queue.task_done()

        return True