Example #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)
Example #2
0
 def on_exit_button_clicked(self, widget, data=None):
     """ Quit Cnchi """
     try:
         misc.remove_temp_files()
         logging.info(_("Quiting installer..."))
         self.settings.set('stop_all_threads', True)
         logging.shutdown()
     except KeyboardInterrupt:
         pass
Example #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)
Example #4
0
 def on_exit_button_clicked(self, widget, data=None):
     """ Quit Thus """
     try:
         misc.remove_temp_files()
         logging.info(_("Quiting installer..."))
         self.settings.set('stop_all_threads', True)
         logging.shutdown()
         os._exit(0)
     except KeyboardInterrupt:
         pass
Example #5
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)
 def on_exit_button_clicked(self, widget, data=None):
     """ Quit DSGos_Installer """
     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
Example #7
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
Example #8
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.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)

    # if not cmd_line.disable_update:
    # update_cnchi()

    # Init PyObject Threads
    threads_init()
def init_DSGos_Installer():
    """ This function initialises DSGos_Installer """

    # Sets SIGTERM handler, so DSGos_Installer 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.force:
        misc.remove_temp_files()

    # Drop root privileges
    misc.drop_privileges()

    # Setup our logging framework
    setup_logging()

    # Check DSGos_Installer 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)

    # if not cmd_line.disable_update:
    # update_DSGos_Installer()

    # Init PyObject Threads
    threads_init()
Example #10
0
def update_thus():
    """ Runs updater function to update thus to the latest version if necessary """
    upd = updater.Updater(force_update=cmd_line.update)

    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 Thus (which will be the new version)
        with misc.raised_privileges():
            os.execl(sys.executable, *([sys.executable] + new_argv))
        sys.exit(0)
Example #11
0
 def quit_cnchi(self):
     misc.remove_temp_files()
     self.settings.set('stop_all_threads', True)
     logging.shutdown()
     sys.exit(0)
Example #12
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

        if self.callback_queue is None:
            return True

        while not self.callback_queue.empty():
            try:
                event = self.callback_queue.get_nowait()
            except queue.Empty:
                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] == '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] == 'downloads_progress_bar':
                if event[1] == 'hide':
                    self.downloads_progress_bar.hide()
                if event[1] == 'show':
                    self.downloads_progress_bar.show()
            elif event[0] == 'finished':
                logging.info(event[1])
                if 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\n"
                                  "installation which could prevent your system from booting properly. Before\n"
                                  "rebooting, you may want to verify whether or not the bootloader 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(self.get_toplevel(), 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(self.get_toplevel(), install_ok)
                misc.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(self.get_toplevel(), 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])

            self.callback_queue.task_done()

        return True
Example #13
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

        if self.callback_queue is None:
            return True

        while not self.callback_queue.empty():
            try:
                event = self.callback_queue.get_nowait()
            except queue.Empty:
                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] == '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] == 'downloads_progress_bar':
                if event[1] == 'hide':
                    self.downloads_progress_bar.hide()
                if event[1] == 'show':
                    self.downloads_progress_bar.show()
            elif event[0] == 'finished':
                logging.info(event[1])
                if 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\n"
                        "installation which could prevent your system from booting properly. Before\n"
                        "rebooting, you may want to verify whether or not the bootloader 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(self.get_toplevel(), 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(self.get_toplevel(), install_ok)
                misc.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(self.get_toplevel(), 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])

            self.callback_queue.task_done()

        return True