~ubuntu-branches/ubuntu/trusty/freeipa/trusty

« back to all changes in this revision

Viewing changes to ipalib/cli.py

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2013-06-17 22:15:21 UTC
  • mfrom: (1.1.3)
  • Revision ID: package-import@ubuntu.com-20130617221521-z8zya289o8xgrv3u
Tags: 3.2.1-0ubuntu1
* Merge from unreleased debian git
  - rebase to 3.2.1
  - add ipa-client-automount to freeipa-client, and patch it so it
    works on Debian/Ubuntu

Show diffs side-by-side

added added

removed removed

Lines of Context:
1043
1043
        """Get the keyword arguments for a Command"""
1044
1044
        if self.env.interactive:
1045
1045
            self.prompt_interactively(cmd, kw)
1046
 
        if self.env.interactive:
1047
1046
            try:
1048
1047
                callbacks = cmd.get_callbacks('interactive_prompt')
1049
1048
            except AttributeError:
1179
1178
        ``self.env.prompt_all`` is ``True``, this method will prompt for any
1180
1179
        params that have a missing values, even if the param is optional.
1181
1180
        """
 
1181
 
1182
1182
        honor_alwaysask = True
1183
1183
        for param in cmd.params():
1184
1184
            if param.alwaysask and param.name in kw:
1185
1185
                honor_alwaysask = False
1186
1186
                break
 
1187
 
1187
1188
        for param in cmd.params():
1188
1189
            if (param.required and param.name not in kw) or \
1189
1190
                (param.alwaysask and honor_alwaysask) or self.env.prompt_all:
1197
1198
                    )
1198
1199
                else:
1199
1200
                    default = cmd.get_default_of(param.name, **kw)
1200
 
                    error = None
1201
 
                    while True:
1202
 
                        if error is not None:
1203
 
                            self.Backend.textui.print_prompt_attribute_error(unicode(param.label),
1204
 
                                                                             unicode(error))
1205
 
                        raw = self.Backend.textui.prompt(param.label, default, optional=param.alwaysask or not param.required)
1206
 
                        try:
1207
 
                            value = param(raw, **kw)
1208
 
                            if value is not None:
1209
 
                                kw[param.name] = value
1210
 
                            break
1211
 
                        except (ValidationError, ConversionError), e:
1212
 
                            error = e.error
 
1201
                    optional = param.alwaysask or not param.required
 
1202
 
 
1203
                    value = cmd.prompt_param(param,
 
1204
                                             default=default,
 
1205
                                             optional=optional,
 
1206
                                             kw=kw)
 
1207
 
 
1208
                    if value is not None:
 
1209
                        kw[param.name] = value
 
1210
 
1213
1211
            elif param.password and kw.get(param.name, False) is True:
1214
1212
                kw[param.name] = self.Backend.textui.prompt_password(
1215
1213
                    param.label, param.confirm