def input(self, args, key): if key in self.key_list: # Get selected KVM from the KVM List selected_kvm_config = args[int(key) - 1] delete_config = YesNoDialog( "Do you want to delete the KVM Config?") ScreenHandler.push_screen_modal(delete_config) delete_reply = delete_config.answer skip_edit = False if delete_reply: KVMHolder.remove_kvm(selected_kvm_config) skip_edit = True if not skip_edit: customize_config = YesNoDialog( "Do you want to update the KVM Config?") ScreenHandler.push_screen_modal(customize_config) edit_reply = customize_config.answer if edit_reply: kvm_custom_config = KVMCustomConfiguration() ScreenHandler.push_screen_modal(kvm_custom_config, args=selected_kvm_config) return InputState.PROCESSED_AND_REDRAW return key
def _showYesNoQuestion(self, message): """Internal helper function that MUST BE CALLED FROM THE MAIN THREAD.""" if flags.automatedInstall and not flags.ksprompt: log.error(message) # If we're in cmdline mode, just say no. return False question_window = YesNoDialog(message) ScreenHandler.push_screen_modal(question_window) question_window.redraw() return question_window.answer
def input(self, args, key): """ Grab the choice and update things. """ if not self._container.process_user_input(key): # TRANSLATORS: 's' to rescan devices if key.lower() == C_('TUI|Spoke Navigation|Partitioning', 's'): text = _("Warning: This will revert all changes done so far.\n" "Do you want to proceed?\n") question_window = YesNoDialog(text) ScreenHandler.push_screen_modal(question_window) if question_window.answer: # unset selected disks temporarily so that # storage_initialize() processes all devices disk_select_proxy = STORAGE.get_proxy(DISK_SELECTION) selected_disks = disk_select_proxy.SelectedDisks disk_select_proxy.SetSelectedDisks([]) print(_("Scanning disks. This may take a moment...")) storage_initialize(self.storage, self.data, self.storage.protected_dev_names) disk_select_proxy.SetSelectedDisks(selected_disks) self.data.mount.clear_mount_data() self._gather_mount_data_info() return InputState.PROCESSED_AND_REDRAW # TRANSLATORS: 'c' to continue elif key.lower() == C_('TUI|Spoke Navigation', 'c'): self.apply() return super().input(args, key) return InputState.PROCESSED
def run_dasdfmt_dialog(self, dasd_formatting): """Do DASD formatting if user agrees.""" # Prepare text of the dialog. text = "" text += _("The following unformatted or LDL DASDs have been " "detected on your system. You can choose to format them " "now with dasdfmt or cancel to leave them unformatted. " "Unformatted DASDs cannot be used during installation.\n\n") text += dasd_formatting.dasds_summary + "\n\n" text += _( "Warning: All storage changes made using the installer will " "be lost when you choose to format.\n\nProceed to run dasdfmt?\n") # Run the dialog. question_window = YesNoDialog(text) ScreenHandler.push_screen_modal(question_window) if not question_window.answer: return None print(_("This may take a moment."), flush=True) # Do the DASD formatting. dasd_formatting.report.connect(self._show_dasdfmt_report) dasd_formatting.run(self.storage, self.data) dasd_formatting.report.disconnect(self._show_dasdfmt_report) self.update_disks()
def input(self, args, key): """ Grab the choice and update things. """ if not self._container.process_user_input(key): # TRANSLATORS: 's' to rescan devices if key.lower() == C_('TUI|Spoke Navigation|Partitioning', 's'): text = _( "Warning: This will revert all changes done so far.\nDo you want to proceed?\n" ) question_window = YesNoDialog(text) ScreenHandler.push_screen_modal(question_window) if question_window.answer: # unset self.data.ignoredisk.onlyuse temporarily so that # storage_initialize() processes all devices ignoredisk = self.data.ignoredisk.onlyuse self.data.ignoredisk.onlyuse = [] print(_("Scanning disks. This may take a moment...")) storage_initialize( self.storage, self.data, self.storage.devicetree.protected_dev_names) self.data.ignoredisk.onlyuse = ignoredisk self.data.mount.clear_mount_data() self._gather_mount_data_info() self.redraw() return InputState.PROCESSED # TRANSLATORS: 'c' to continue elif key.lower() == C_('TUI|Spoke Navigation', 'c'): self.apply() return super(MountPointAssignSpoke, self).input(args, key) return InputState.PROCESSED
def input(self, args, key): if key in self.key_list: # Get selected KVM from the KVM List selected_kvm_config = copy.deepcopy(args["kvms"][int(key) - 1]) kvm_os_conf_list = KVMOSConfigurationList() ScreenHandler.push_screen_modal(kvm_os_conf_list, args=args["os"]) vm_osinfo_id = KVMHolder.selected_os["vm_osinfo_id"] vm_cloud_image = KVMHolder.selected_os["vm_cloud_image"] selected_kvm_config.update({"vm_osinfo_id": vm_osinfo_id}) selected_kvm_config.update({"vm_cloud_image": vm_cloud_image}) customize_config = YesNoDialog( "Do you want to update the KVM Config?") ScreenHandler.push_screen_modal(customize_config) edit_reply = customize_config.answer if edit_reply: kvm_custom_config = KVMCustomConfiguration() ScreenHandler.push_screen_modal(kvm_custom_config, args=selected_kvm_config) KVMHolder.add_kvm(selected_kvm_config) print(selected_kvm_config) return InputState.PROCESSED_AND_REDRAW return key
def _quit_callback(self, data): d = YesNoDialog(_(QUIT_MESSAGE)) ScreenHandler.push_screen_modal(d) self.redraw() if d.answer: self._rescue.reboot = True self._rescue.finish()
def _quit_callback(self, data): d = YesNoDialog(_(u"Do you really want to quit?")) ScreenHandler.push_screen_modal(d) self.redraw() if d.answer: self._rescue.reboot = True self._rescue.finish()
def _validate_password(self, password, confirm): """Validate and process user password.""" if password != confirm: self._report( _(constants.SECRET_CONFIRM_ERROR_TUI[self._secret_type])) return None # If an empty password was provided, unset the value if not password: return "" # prepare a password validation request password_check_request = input_checking.PasswordCheckRequest() password_check_request.password = password password_check_request.password_confirmation = "" password_check_request.policy = self._policy # validate the password password_check = input_checking.PasswordValidityCheck() password_check.run(password_check_request) # if the score is equal to 0 and we have an error message set if not password_check.result.password_score and password_check.result.error_message: self._report(password_check.result.error_message) return None if password_check.result.password_quality < self._policy.min_quality: if self._policy.is_strict: done_msg = "" else: done_msg = _("\nWould you like to use it anyway?") if password_check.result.error_message: weak_prefix = _( constants.SECRET_WEAK_WITH_ERROR[self._secret_type]) error = "{} {} {}".format(weak_prefix, password_check.result.error_message, done_msg) else: weak_prefix = _(constants.SECRET_WEAK[self._secret_type]) error = "{} {}".format(weak_prefix, done_msg) if not self._policy.is_strict: question_window = YesNoDialog(error) ScreenHandler.push_screen_modal(question_window) if not question_window.answer: return None else: self._report(error) return None if any(char not in constants.PW_ASCII_CHARS for char in password): self._report(_(constants.SECRET_ASCII[self._secret_type])) return self._process_password(password)
def setup(self, data): """Construct all the objects required to implement this interface. This method must be provided by all subclasses. """ # Use GLib event loop for the Simpleline TUI loop = GLibEventLoop() App.initialize(event_loop=loop) loop.set_quit_callback(tui_quit_callback) scheduler = App.get_scheduler() scheduler.quit_screen = YesNoDialog(self.quitMessage) # tell python-meh it should use our raw_input meh_io_handler = meh.ui.text.IOHandler( in_func=self._get_meh_input_func) self._meh_interface.set_io_handler(meh_io_handler) # register handlers for various messages loop = App.get_event_loop() loop.register_signal_handler(ExceptionSignal, exception_msg_handler) loop.register_signal_handler(SendMessageSignal, self._handle_show_message) _hubs = self._list_hubs() # First, grab a list of all the standalone spokes. spokes = self._collectActionClasses(self.paths["spokes"], StandaloneSpoke) actionClasses = self._orderActionClasses(spokes, _hubs) for klass in actionClasses: obj = klass(data, self.storage, self.payload) # If we are doing a kickstart install, some standalone spokes # could already be filled out. In that case, we do not want # to display them. if self._is_standalone(obj) and obj.completed: del (obj) continue if hasattr(obj, "set_path"): obj.set_path("spokes", self.paths["spokes"]) obj.set_path("categories", self.paths["categories"]) should_schedule = obj.setup(self.ENVIRONMENT) if should_schedule: scheduler.schedule_screen(obj)
def _rescan_devices(self): """Rescan devices.""" text = _("Warning: This will revert all changes done so far.\n" "Do you want to proceed?\n") question_window = YesNoDialog(text) ScreenHandler.push_screen_modal(question_window) if not question_window.answer: return print(_("Scanning disks. This may take a moment...")) reset_storage(self.storage, scan_all=True) self._manual_part_proxy.SetMountPoints([]) self._mount_info = self._gather_mount_info()
def _validate_password(self, password, confirm): """Validate and process user password.""" if (password and not confirm) or (confirm and not password): self._report(_("You must enter your root password and confirm it by typing" " it a second time to continue.")) return None if password != confirm: self._report(_(PASSWORD_CONFIRM_ERROR_TUI)) return None # If an empty password was provided, unset the value if not password: return "" pw_score, _status_text, pw_quality, error_message = validatePassword(password, user=None, minlen=self._policy.minlen) # if the score is equal to 0 and we have an error message set if not pw_score and error_message: self._report(error_message) return None if pw_quality < self._policy.minquality: if self._policy.strict: done_msg = "" else: done_msg = _("\nWould you like to use it anyway?") if error_message: error = _(PASSWORD_WEAK_WITH_ERROR) % error_message + " " + done_msg else: error = _(PASSWORD_WEAK) % done_msg if not self._policy.strict: question_window = YesNoDialog(error) ScreenHandler.push_screen_modal(question_window) if not question_window.answer: return None else: self._report(error) return None if any(char not in PW_ASCII_CHARS for char in password): self._report(_("You have provided a password containing non-ASCII characters.\n" "You may not be able to switch between keyboard layouts to login.\n")) return cryptPassword(password)
def _rescan_devices(self): """Rescan devices.""" text = _("Warning: This will revert all changes done so far.\n" "Do you want to proceed?\n") question_window = YesNoDialog(text) ScreenHandler.push_screen_modal(question_window) if not question_window.answer: return print(_("Scanning disks. This may take a moment...")) reset_storage(scan_all=True) # Forget the mount point requests. self._partitioning.SetRequests([]) self._requests = self._gather_requests()
def input(self, args, key): """Override input so that we can launch the VNC password spoke""" if self._container.process_user_input(key): self.apply() return InputState.PROCESSED_AND_CLOSE else: if key.lower() == Prompt.QUIT: d = YesNoDialog(_(QUIT_MESSAGE)) ScreenHandler.push_screen_modal(d) if d.answer: ipmi_abort(scripts=self.data.scripts) if conf.system.can_reboot: execWithRedirect("systemctl", ["--no-wall", "reboot"]) else: sys.exit(1) else: return super().input(args, key)
def input(self, args, key): """Override input so that we can launch the VNC password spoke""" if self._container.process_user_input(key): self.apply() return InputState.PROCESSED_AND_CLOSE else: # TRANSLATORS: 'q' to quit if key.lower() == C_('TUI|Spoke Navigation', 'q'): d = YesNoDialog(_(u"Do you really want to quit?")) ScreenHandler.push_screen_modal(d) if d.answer: ipmi_abort(scripts=self.data.scripts) if conf.system.can_reboot: execWithRedirect("systemctl", ["--no-wall", "reboot"]) else: sys.exit(1) else: return super().input(args, key)
def run_dasdfmt(self, to_format): """ This generates the list of DASDs requiring dasdfmt and runs dasdfmt against them. """ # if the storage thread is running, wait on it to complete before taking # any further actions on devices; most likely to occur if user has # zerombr in their ks file threadMgr.wait(THREAD_STORAGE) # ask user to verify they want to format if zerombr not in ks file if not self.data.zerombr.zerombr: # prepare our msg strings; copied directly from dasdfmt.glade summary = _( "The following unformatted DASDs have been detected on your system. You can choose to format them now with dasdfmt or cancel to leave them unformatted. Unformatted DASDs cannot be used during installation.\n\n" ) warntext = _( "Warning: All storage changes made using the installer will be lost when you choose to format.\n\nProceed to run dasdfmt?\n" ) displaytext = summary + "\n".join( "/dev/" + d.name for d in to_format) + "\n" + warntext # now show actual prompt; note -- in cmdline mode, auto-answer for # this is 'no', so unformatted DASDs will remain so unless zerombr # is added to the ks file question_window = YesNoDialog(displaytext) ScreenHandler.push_screen_modal(question_window) if not question_window.answer: # no? well fine then, back to the storage spoke with you; return None for disk in to_format: try: print( _("Formatting /dev/%s. This may take a moment.") % disk.name) blockdev.s390.dasd_format(disk.name) except blockdev.S390Error as err: # Log errors if formatting fails, but don't halt the installer log.error(str(err)) continue
def _rescan_devices(self): """Rescan devices.""" text = _("Warning: This will revert all changes done so far.\n" "Do you want to proceed?\n") question_window = YesNoDialog(text) ScreenHandler.push_screen_modal(question_window) if not question_window.answer: return # unset selected disks temporarily so that # initialize_storage() processes all devices disk_select_proxy = STORAGE.get_proxy(DISK_SELECTION) selected_disks = disk_select_proxy.SelectedDisks disk_select_proxy.SetSelectedDisks([]) print(_("Scanning disks. This may take a moment...")) initialize_storage(self.storage) disk_select_proxy.SetSelectedDisks(selected_disks) self._manual_part_proxy.SetMountPoints([]) self._mount_info = self._gather_mount_info()
def _validate_password(self, password, confirm): """Validate and process user password.""" if (password and not confirm) or (confirm and not password): self._report( _("You must enter your root password and confirm it by typing" " it a second time to continue.")) return None if password != confirm: self._report( _(constants.PASSWORD_CONFIRM_ERROR_TUI) % {"password_name_plural": _(constants.NAME_OF_PASSWORD_PLURAL)}) return None # If an empty password was provided, unset the value if not password: return "" # prepare a password validation request password_check_request = input_checking.PasswordCheckRequest() password_check_request.password = password password_check_request.password_confirmation = "" password_check_request.policy = self._policy # validate the password password_check = input_checking.PasswordValidityCheck() password_check.run(password_check_request) # if the score is equal to 0 and we have an error message set if not password_check.result.password_score and password_check.result.error_message: self._report(password_check.result.error_message) return None if password_check.result.password_quality < self._policy.minquality: if self._policy.strict: done_msg = "" else: done_msg = _("\nWould you like to use it anyway?") if password_check.result.error_message: error_prefix = _(constants.PASSWORD_WEAK_WITH_ERROR) % { "password_name": _(constants.NAME_OF_PASSWORD), "error_message": password_check.result.error_message } error = "{} {}".format(error_prefix, done_msg) else: weak_prefix = _(constants.PASSWORD_WEAK) % { "password_name": _(constants.NAME_OF_PASSWORD) } error = "{} {}".format(weak_prefix, done_msg) if not self._policy.strict: question_window = YesNoDialog(error) ScreenHandler.push_screen_modal(question_window) if not question_window.answer: return None else: self._report(error) return None if any(char not in constants.PW_ASCII_CHARS for char in password): self._report( _("You have provided a password containing non-ASCII characters.\n" "You may not be able to switch between keyboard layouts to login.\n" )) return cryptPassword(password)
def prompt(self, args=None): entry = args if not entry: return None if entry.aux == self.PASSWORD: pw = self.get_user_input(_("%s: ") % entry.title, hidden=True) confirm = self.get_user_input(_("%s (confirm): ") % entry.title, hidden=True) if (pw and not confirm) or (confirm and not pw): print( _("You must enter your root password and confirm it by typing" " it a second time to continue.")) return None if pw != confirm: print(_(PASSWORD_CONFIRM_ERROR_TUI)) return None # If an empty password was provided, unset the value if not pw: self.value = "" return None pw_score, _status_text, pw_quality, error_message = validatePassword( pw, user=None, minlen=self.policy.minlen) # if the score is equal to 0 and we have an error message set if not pw_score and error_message: print(error_message) return None if pw_quality < self.policy.minquality: if self.policy.strict: done_msg = "" else: done_msg = _("\nWould you like to use it anyway?") if error_message: error = _(PASSWORD_WEAK_WITH_ERROR ) % error_message + " " + done_msg else: error = _(PASSWORD_WEAK) % done_msg if not self.policy.strict: question_window = YesNoDialog(error) ScreenHandler.push_screen_modal(question_window) if not question_window.answer: return None else: print(error) return None if any(char not in PW_ASCII_CHARS for char in pw): print( _("You have provided a password containing non-ASCII characters.\n" "You may not be able to switch between keyboard layouts to login.\n" )) self.value = cryptPassword(pw) return None else: return Prompt( _("Enter a new value for '%(title)s' and press %(enter)s") % { # TRANSLATORS: 'title' as a title of the entry "title": entry.title, # TRANSLATORS: 'enter' as the key ENTER "enter": Prompt.ENTER })