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()
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
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