Exemplo n.º 1
0
 def prompt(self, args=None):
     return tui.Prompt(_("Please respond '%(yes)s' or '%(no)s'") % {
         # TRANSLATORS: 'yes' as positive reply
         "yes": C_('TUI|Spoke Navigation', 'yes'),
         # TRANSLATORS: 'no' as negative reply
         "no": C_('TUI|Spoke Navigation', 'no')
     })
Exemplo n.º 2
0
    def prompt(self, entry=None):
        if not entry:
            return None

        if entry.aux == self.PASSWORD:
            pw = self._app.raw_input(_("%s: ") % entry.title, hidden=True)
            confirm = self._app.raw_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

            valid, strength, message = validatePassword(pw, user=None, minlen=self.policy.minlen)

            if not valid:
                print(message)
                return None

            if strength < self.policy.minquality:
                if self.policy.strict:
                    done_msg = ""
                else:
                    done_msg = _("\nWould you like to use it anyway?")

                if message:
                    error = _(PASSWORD_WEAK_WITH_ERROR) % message + " " + done_msg
                else:
                    error = _(PASSWORD_WEAK) % done_msg

                if not self.policy.strict:
                    question_window = YesNoDialog(self._app, error)
                    self._app.switch_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 tui.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": tui.Prompt.ENTER
            })
Exemplo n.º 3
0
 def prompt(self, args=None):
     return tui.Prompt(_("Press %s to exit") % tui.Prompt.ENTER)