Prompt correctly for required Password params.

Ticket #361
This commit is contained in:
Pavel Zuna 2010-11-24 08:01:31 -05:00 committed by Rob Crittenden
parent c90bff232d
commit 94957c8ddc

View File

@ -515,7 +515,7 @@ class textui(backend.Backend):
try: try:
if sys.stdin.isatty(): if sys.stdin.isatty():
while True: while True:
pw1 = getpass.getpass('%s: ' % label) pw1 = getpass.getpass(u'%s: ' % unicode(label))
pw2 = getpass.getpass( pw2 = getpass.getpass(
unicode(_('Enter %(label)s again to verify: ') % dict(label=label)) unicode(_('Enter %(label)s again to verify: ') % dict(label=label))
) )
@ -887,16 +887,15 @@ class cli(backend.Executioner):
``self.env.prompt_all`` is ``True``, this method will prompt for any ``self.env.prompt_all`` is ``True``, this method will prompt for any
params that have a missing values, even if the param is optional. params that have a missing values, even if the param is optional.
""" """
for param in cmd.params(): for param in cmd.params():
if param.password and ( if (param.required and param.name not in kw) or self.env.prompt_all:
kw.get(param.name, False) is True or param.name in cmd.args if param.password:
): kw[param.name] = self.Backend.textui.prompt_password(
kw[param.name] = \ param.label
self.Backend.textui.prompt_password(param.cli_name) )
elif param.name not in kw: elif param.autofill:
if param.autofill:
kw[param.name] = param.get_default(**kw) kw[param.name] = param.get_default(**kw)
elif param.required or self.env.prompt_all: else:
default = param.get_default(**kw) default = param.get_default(**kw)
error = None error = None
while True: while True:
@ -910,6 +909,10 @@ class cli(backend.Executioner):
break break
except ValidationError, e: except ValidationError, e:
error = e.error error = e.error
elif param.password and kw.get(param.name, False) is True:
kw[param.name] = self.Backend.textui.prompt_password(
param.label
)
def load_files(self, cmd, kw): def load_files(self, cmd, kw):
""" """