def store_values(self): """ Store all user values in self.settings """ self.settings.set('fullname', self.entry['fullname'].get_text()) self.settings.set('hostname', self.entry['hostname'].get_text()) self.settings.set('username', self.entry['username'].get_text()) self.settings.set('password', self.entry['password'].get_text()) self.settings.set('root_password', self.entry['root_password'].get_text()) self.settings.set('require_password', self.require_password) self.settings.set('encrypt_home', False) if self.encrypt_home: m = _("Manjaro will use eCryptfs to encrypt your home directory. Unfortunately, eCryptfs does not handle sparse files well.\n\n") m += _("Don't worry, for most intents and purposes this deficiency does not pose a problem.\n\n") m += _("Anyway, one popular and inadvisable application of eCryptfs is to encrypt a BitTorrent download location as this often requires eCryptfs to handle sparse files of 10 GB or more and may lead to intense disk starvation.\n\n") m += _("A simple workaround is to place sparse files in an unencrypted .Public directory\n\n") m += _("Look at https://wiki.archlinux.org/index.php/ECryptfs for detailed information\n\n") m += _("Are you sure you want to encrypt your home directory?\n") res = show.question(m) if res == Gtk.ResponseType.YES: self.settings.set('encrypt_home', True) # this way installer_process will know all info has been entered self.settings.set('user_info_done', True) return True
def store_values(self): """ Store all user values in self.settings """ # For developer testing if self.settings.get('z_hidden'): self.settings.set('fullname', 'Antergos Testing') self.settings.set('hostname', 'Testing Machine') self.settings.set('username', 'antergos') self.settings.set('password', 'testing') self.settings.set('require_password', True) else: self.settings.set('fullname', self.entry['fullname'].get_text()) self.settings.set('hostname', self.entry['hostname'].get_text()) self.settings.set('username', self.entry['username'].get_text()) self.settings.set('password', self.entry['password'].get_text()) self.settings.set('require_password', self.require_password) self.settings.set('encrypt_home', False) if self.encrypt_home: message = _("Are you sure you want to encrypt your home directory?") res = show.question(message) if res == Gtk.ResponseType.YES: self.settings.set('encrypt_home', True) # Let installer_process know that all info has been entered self.settings.set('user_info_done', True)
def store_values(self): """ Store all user values in self.settings """ # For developer testing if self.settings.get("z_hidden"): self.settings.set("fullname", "Antergos Testing") self.settings.set("hostname", "Testing Machine") self.settings.set("username", "antergos") self.settings.set("password", "testing") self.settings.set("require_password", True) else: self.settings.set("fullname", self.entry["fullname"].get_text()) self.settings.set("hostname", self.entry["hostname"].get_text()) self.settings.set("username", self.entry["username"].get_text()) self.settings.set("password", self.entry["password"].get_text()) self.settings.set("require_password", self.require_password) self.settings.set("encrypt_home", False) if self.encrypt_home: message = _("Are you sure you want to encrypt your home directory?") res = show.question(message) if res == Gtk.ResponseType.YES: self.settings.set("encrypt_home", True) # Let installer_process know that all info has been entered self.settings.set("user_info_done", True)
def store_values(self): """ Store all user values in self.settings """ # For developer testing # Do not use this, is confusing for others when testing dev version ''' if self.settings.get('z_hidden'): self.settings.set('fullname', 'DSGos Testing') self.settings.set('hostname', 'Testing Machine') self.settings.set('username', 'DSGos') self.settings.set('password', 'testing') self.settings.set('require_password', True) else: ''' self.settings.set('fullname', self.entry['fullname'].get_text()) self.settings.set('hostname', self.entry['hostname'].get_text()) self.settings.set('username', self.entry['username'].get_text()) self.settings.set('password', self.entry['password'].get_text()) self.settings.set('require_password', self.require_password) self.settings.set('encrypt_home', False) if self.encrypt_home: message = _("Are you sure you want to encrypt your home directory?") res = show.question(self.get_toplevel(), message) if res == Gtk.ResponseType.YES: self.settings.set('encrypt_home', True) # Let installer_process know that all info has been entered self.settings.set('user_info_done', True) return True
def store_values(self): """ User wants to continue """ parent = self.get_toplevel() msg = _("Are you REALLY sure you want to continue?") try: response = show.question(parent, msg) except TypeError as ex: response = show.question(None, msg) if response != Gtk.ResponseType.YES: return False install_screen = self.get_install_screen() self.process = Process(install_screen, self.settings, self.callback_queue) self.process.start() return True
def manage_events_from_cb_queue(self): 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] == 'global_percent': self.show_global_progress_bar_if_hidden() self.global_progress_bar.set_fraction(event[1]) elif event[0] == 'finished': logging.info(event[1]) self.set_message(self.install_ok) response = show.question(self.install_ok) if response == Gtk.ResponseType.YES: self.reboot() else: tmp_files = [".setup-running", ".km-running", "setup-pacman-running", "setup-mkinitcpio-running", ".tz-running", ".setup", "Cnchi.log"] for t in tmp_files: p = os.path.join("/tmp", t) if os.path.exists(p): # TODO: some of these tmp files are created with sudo privileges # (this should be fixed) meanwhile, we need sudo privileges to remove them with misc.raised_privileges(): os.remove(p) while Gtk.events_pending(): Gtk.main_iteration() Gtk.main_quit() self.exit_button.show() return False elif event[0] == 'error': self.callback_queue.task_done() # a fatal error has been issued. We empty the queue self.empty_queue() self.fatal_error = True show.fatal_error(event[1]) return False elif event[0] == 'debug': logging.debug(event[1]) elif event[0] == 'warning': logging.warning(event[1]) else: # TODO: Check if logging slows down showing messages # remove logging.info in that case (and at least # use the one at pac.py:queue_event) logging.info(event[1]) self.set_message(event[1]) self.callback_queue.task_done() return True
def store_values(self): response = show.question( self.get_toplevel(), _("Are you REALLY sure you want to continue?")) if response != Gtk.ResponseType.YES: return False install_screen = self.get_install_screen() self.process = Process(install_screen, self.settings, self.callback_queue) self.process.start() return True
def manage_events_from_cb_queue(self): ''' try: event = self.callback_queue.get_nowait() except queue.Empty: event = () ''' event = self.get_newest_event() if len(event) > 0: if event[0] == "percent": self.progress_bar.set_fraction(event[1]) elif event[0] == "finished": log.debug(event[1]) self.set_message(self.install_ok) response = show.question(self.install_ok) if response == Gtk.ResponseType.YES: self.reboot() else: tmp_files = [ ".setup-running", ".km-running", "setup-pacman-running", "setup-mkinitcpio-running", ".tz-running", ".setup", "Cnchi.log" ] for t in tmp_files: p = os.path.join("/tmp", t) if os.path.exists(p): # TODO: some of these tmp files are created with sudo privileges # (this should be fixed) meanwhile, we need sudo privileges to remove them with misc.raised_privileges(): os.remove(p) Gtk.main_quit() self.exit_button.show() return False elif event[0] == "error": show.fatal_error(event[1]) else: #with self.lock: log.debug(event[1]) self.set_message(event[1]) # remove old messages from the event queue #self.callback_queue.clear() return True
def manage_events_from_cb_queue(self): ''' try: event = self.callback_queue.get_nowait() except queue.Empty: event = () ''' event = self.get_newest_event() if len(event) > 0: if event[0] == "percent": self.progress_bar.set_fraction(event[1]) elif event[0] == "finished": log.debug(event[1]) self.set_message(self.install_ok) response = show.question(self.install_ok) if response == Gtk.ResponseType.YES: self.reboot() else: tmp_files = [".setup-running", ".km-running", "setup-pacman-running", "setup-mkinitcpio-running", ".tz-running", ".setup", "Cnchi.log"] for t in tmp_files: p = os.path.join("/tmp", t) if os.path.exists(p): # TODO: some of these tmp files are created with sudo privileges # (this should be fixed) meanwhile, we need sudo privileges to remove them with misc.raised_privileges(): os.remove(p) Gtk.main_quit() self.exit_button.show() return False elif event[0] == "error": show.fatal_error(event[1]) else: #with self.lock: log.debug(event[1]) self.set_message(event[1]) # remove old messages from the event queue #self.callback_queue.clear() return True
def store_values(self): """ Store all user values in self.settings """ # For developer testing if self.settings.get('z_hidden'): self.settings.set('fullname', 'Antergos Testing') self.settings.set('hostname', 'Testing Machine') self.settings.set('username', 'antergos') self.settings.set('password', 'testing') self.settings.set('require_password', True) else: self.settings.set('fullname', self.entry['fullname'].get_text()) self.settings.set('hostname', self.entry['hostname'].get_text()) self.settings.set('username', self.entry['username'].get_text()) self.settings.set('password', self.entry['password'].get_text()) self.settings.set('require_password', self.require_password) self.settings.set('encrypt_home', False) if self.encrypt_home: ''' # This is not true anymore, we use encFS now. message = _("Antergos will use eCryptfs to encrypt your home directory.\n" "Unfortunately, eCryptfs does not handle sparse files very well.\n\n" "Don't worry though, for most intents and purposes this deficiency does not pose a problem.\n\n" "One popular but inadvisable application of eCryptfs is to encrypt a BitTorrent download " "locationw as this often requires eCryptfs to handle sparse files of 10 GB or more and can " "lead to intense disk starvation.\n\n" "A simple workaround is to place sparse files in an unencrypted Public directory.\n\n" "Review https://wiki.archlinux.org/index.php/ECryptfs for more detailed information.\n\n" "Are you sure you want to encrypt your home directory?") ''' message = _("Are you sure you want to encrypt your home directory?") res = show.question(message) if res == Gtk.ResponseType.YES: self.settings.set('encrypt_home', True) # this way installer_process will know all info has been entered self.settings.set('user_info_done', True)
def store_values(self): """ Store all user values in self.settings """ # For developer testing # Do not use this, is confusing for others when testing dev version self.settings.set('fullname', self.entry['fullname'].get_text()) self.settings.set('hostname', self.entry['hostname'].get_text()) self.settings.set('username', self.entry['username'].get_text()) self.settings.set('password', self.entry['password'].get_text()) self.settings.set('require_password', self.require_password) self.settings.set('encrypt_home', False) if self.encrypt_home: message = _( "Are you sure you want to encrypt your home directory?") res = show.question(self.get_main_window(), message) if res == Gtk.ResponseType.YES: self.settings.set('encrypt_home', True) # Let installer_process know that all info has been entered self.settings.set('user_info_done', True) return True
def store_values(self): """ Store all user values in self.settings """ self.settings.set('fullname', self.entry['fullname'].get_text()) self.settings.set('hostname', self.entry['hostname'].get_text()) self.settings.set('username', self.entry['username'].get_text()) self.settings.set('password', self.entry['password'].get_text()) self.settings.set('root_password', self.entry['root_password'].get_text()) self.settings.set('require_password', self.require_password) self.settings.set('encrypt_home', False) if self.encrypt_home: m = _("Manjaro will use eCryptfs to encrypt your home directory. Unfortunately, eCryptfs does not handle sparse files well.\n\n") m += _("Don't worry, for most intents and purposes this deficiency does not pose a problem.\n\n") m += _("Anyway, one popular and inadvisable application of eCryptfs is to encrypt a BitTorrent download location as this often requires eCryptfs to handle sparse files of 10 GB or more and may lead to intense disk starvation.\n\n") m += _("A simple workaround is to place sparse files in an unencrypted .Public directory\n\n") m += _("Look at https://wiki.archlinux.org/index.php/ECryptfs for detailed information\n\n") m += _("Are you sure you want to encrypt your home directory?\n") res = show.question(m) if res == Gtk.ResponseType.YES: self.settings.set('encrypt_home', True) # this way installer_process will know all info has been entered self.settings.set('user_info_done', 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() # 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
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
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
def manage_events_from_cb_queue(self): """ This function is called from cnchi.py with a timeout function 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() is 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] == "global_percent": self.show_global_progress_bar_if_hidden() self.global_progress_bar.set_fraction(event[1]) elif event[0] == "pulse": self.do_progress_pulse() elif event[0] == "stop_pulse": self.stop_pulse() elif event[0] == "finished": logging.info(event[1]) self.should_pulse = False self.set_message(self.install_ok) response = show.question(self.install_ok) if response == Gtk.ResponseType.YES: self.reboot() else: tmp_files = [ ".setup-running", ".km-running", "setup-pacman-running", "setup-mkinitcpio-running", ".tz-running", ".setup", "thus.log", ] for t in tmp_files: p = os.path.join("/tmp", t) if os.path.exists(p): # TODO: some of these tmp files are created with sudo privileges # (this should be fixed) meanwhile, we need sudo privileges to remove them with misc.raised_privileges(): os.remove(p) self.callback_queue.task_done() os._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() self.fatal_error = True show.fatal_error(event[1]) # Ask if user wants to retry res = show.question(_("Do you want to retry?")) 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] == "debug": logging.debug(event[1]) elif event[0] == "warning": logging.warning(event[1]) else: logging.info(event[1]) self.set_message(event[1]) self.callback_queue.task_done() return True
def manage_events_from_cb_queue(self): """ This function is called from cnchi.py with a timeout function 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() is 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] == 'global_percent': self.show_global_progress_bar_if_hidden() self.global_progress_bar.set_fraction(event[1]) elif event[0] == 'pulse': self.do_progress_pulse() elif event[0] == 'stop_pulse': self.stop_pulse() elif event[0] == 'finished': logging.info(event[1]) self.should_pulse = False # Warn user about GRUB and ask if we should open wiki page. if not self.settings.get('bootloader_ok'): import webbrowser self.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(self.boot_warn) if response == Gtk.ResponseType.YES: webbrowser.open('https://wiki.archlinux.org/index.php/GRUB') self.set_message(self.install_ok) response = show.question(self.install_ok) if response == Gtk.ResponseType.YES: logging.shutdown() self.reboot() else: tmp_files = [".setup-running", ".km-running", "setup-pacman-running", "setup-mkinitcpio-running", ".tz-running", ".setup", "thus.log"] for t in tmp_files: p = os.path.join("/tmp", t) if os.path.exists(p): # TODO: some of these tmp files are created with sudo privileges # (this should be fixed) meanwhile, we need sudo privileges to remove them with misc.raised_privileges(): os.remove(p) self.callback_queue.task_done() logging.shutdown() os._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() self.fatal_error = True show.fatal_error(event[1]) # Ask if user wants to retry res = show.question(_("Do you want to retry?")) 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] == 'debug': logging.debug(event[1]) elif event[0] == 'warning': logging.warning(event[1]) else: logging.info(event[1]) self.set_message(event[1]) self.callback_queue.task_done() return True
def manage_events_from_cb_queue(self): """ This function is called from cnchi.py with a timeout function 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() is 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] == 'global_percent': self.show_global_progress_bar_if_hidden() self.global_progress_bar.set_fraction(event[1]) elif event[0] == 'pulse': self.do_progress_pulse() elif event[0] == 'stop_pulse': self.stop_pulse() elif event[0] == 'finished': logging.info(event[1]) self.should_pulse = False # Warn user about GRUB and ask if we should open wiki page. if not self.settings.get('bootloader_ok'): import webbrowser self.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(self.boot_warn) if response == Gtk.ResponseType.YES: webbrowser.open( 'https://wiki.archlinux.org/index.php/GRUB') self.set_message(self.install_ok) response = show.question(self.install_ok) if response == Gtk.ResponseType.YES: logging.shutdown() self.reboot() else: tmp_files = [ ".setup-running", ".km-running", "setup-pacman-running", "setup-mkinitcpio-running", ".tz-running", ".setup", "thus.log" ] for t in tmp_files: p = os.path.join("/tmp", t) if os.path.exists(p): # TODO: some of these tmp files are created with sudo privileges # (this should be fixed) meanwhile, we need sudo privileges to remove them with misc.raised_privileges(): os.remove(p) self.callback_queue.task_done() logging.shutdown() os._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() self.fatal_error = True show.fatal_error(event[1]) # Ask if user wants to retry res = show.question(_("Do you want to retry?")) 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] == 'debug': logging.debug(event[1]) elif event[0] == 'warning': logging.warning(event[1]) else: logging.info(event[1]) 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
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
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