summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Zuna <pzuna@redhat.com>2010-11-24 08:01:31 -0500
committerRob Crittenden <rcritten@redhat.com>2010-11-30 15:14:28 -0500
commit94957c8ddcb8c11cea394b92ce67944adb991b23 (patch)
tree7780c729f3ab50005ad3fff8bf893df5c0bf9189
parentc90bff232dcc9dbab2cd6d5a1bb482cb1c5f16f9 (diff)
downloadfreeipa-94957c8ddcb8c11cea394b92ce67944adb991b23.tar.gz
freeipa-94957c8ddcb8c11cea394b92ce67944adb991b23.tar.xz
freeipa-94957c8ddcb8c11cea394b92ce67944adb991b23.zip
Prompt correctly for required Password params.
Ticket #361
-rw-r--r--ipalib/cli.py23
1 files changed, 13 insertions, 10 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index 41bee7a8c..3120e0117 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -515,7 +515,7 @@ class textui(backend.Backend):
try:
if sys.stdin.isatty():
while True:
- pw1 = getpass.getpass('%s: ' % label)
+ pw1 = getpass.getpass(u'%s: ' % unicode(label))
pw2 = getpass.getpass(
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
params that have a missing values, even if the param is optional.
"""
- for param in cmd.params():
- if param.password and (
- kw.get(param.name, False) is True or param.name in cmd.args
- ):
- kw[param.name] = \
- self.Backend.textui.prompt_password(param.cli_name)
- elif param.name not in kw:
- if param.autofill:
+ for param in cmd.params():
+ if (param.required and param.name not in kw) or self.env.prompt_all:
+ if param.password:
+ kw[param.name] = self.Backend.textui.prompt_password(
+ param.label
+ )
+ elif param.autofill:
kw[param.name] = param.get_default(**kw)
- elif param.required or self.env.prompt_all:
+ else:
default = param.get_default(**kw)
error = None
while True:
@@ -910,6 +909,10 @@ class cli(backend.Executioner):
break
except ValidationError, e:
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):
"""