Add labels for passwords, fix output of exceptions, fix passwd output.

Passwords didn't have internationalizable labels.

Exceptions that occured during required input weren't printed as unicode
so weren't being translated properly.

Don't use output_for_cli() directly in the passwd plugin, use output.Output.

ticket 352
This commit is contained in:
Rob Crittenden 2010-12-02 16:31:42 -05:00
parent 6c393e53b0
commit a41e69fba3
3 changed files with 14 additions and 9 deletions

View File

@ -903,7 +903,7 @@ class cli(backend.Executioner):
error = None
while True:
if error is not None:
print '>>> %s: %s' % (param.label, error)
print '>>> %s: %s' % (unicode(param.label), unicode(error))
raw = self.Backend.textui.prompt(param.label, default)
try:
value = param(raw, **kw)

View File

@ -124,7 +124,7 @@ def _pre_migrate_group(ldap, pkey, dn, entry_attrs, failed, config, ctx):
def validate_ldapuri(ugettext, ldapuri):
m = re.match('^ldaps?://[-\w\.]+(:\d+)?$', ldapuri)
if not m:
err_msg = 'Invalid LDAP URI.'
err_msg = _('Invalid LDAP URI.')
raise errors.ValidationError(name='ldap_uri', error=err_msg)
@ -171,6 +171,7 @@ class migrate_ds(Command):
),
Password('bindpw',
cli_name='password',
label=_('Password'),
doc=_('bind password'),
),
)

View File

@ -39,6 +39,7 @@ from ipalib import api, errors, util
from ipalib import Command
from ipalib import Str, Password
from ipalib import _
from ipalib import output
class passwd(Command):
@ -54,9 +55,14 @@ class passwd(Command):
autofill=True,
create_default=lambda **kw: util.get_current_principal(),
),
Password('password'),
Password('password',
label=_('Password'),
),
)
has_output = output.standard_value
msg_summary = _('Changed password for "%(value)s"')
def execute(self, principal, password):
"""
Execute the passwd operation.
@ -84,11 +90,9 @@ class passwd(Command):
ldap.modify_password(dn, password)
return dict(result=True)
def output_for_cli(self, textui, result, principal, password):
assert password is None
textui.print_name(self.name)
textui.print_dashed('Changed password for "%s."' % principal)
return dict(
result=True,
value=principal,
)
api.register(passwd)