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