From a4d4e81c88da400d4ec62fb9fdc00eeeafafc0e5 Mon Sep 17 00:00:00 2001 From: Madhu Mohan Nelemane Date: Wed, 27 Apr 2016 18:43:57 +0200 Subject: [PATCH] Avoid TypeError on message object additions Change-Id: I634c1e158e93eeb55ab17fef8a0715b6678dffec Closes-Bug: #1575787 --- openstackclient/api/auth.py | 36 ++++++++++++++++++++---------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/openstackclient/api/auth.py b/openstackclient/api/auth.py index 3d6f7bcf19..c74e8005de 100644 --- a/openstackclient/api/auth.py +++ b/openstackclient/api/auth.py @@ -142,14 +142,14 @@ def check_valid_auth_options(options, auth_plugin_name, required_scope=True): """ - msg = '' + msgs = [] if auth_plugin_name.endswith('password'): if not options.auth.get('username'): - msg += _('Set a username with --os-username, OS_USERNAME,' - ' or auth.username\n') + msgs.append(_('Set a username with --os-username, OS_USERNAME,' + ' or auth.username')) if not options.auth.get('auth_url'): - msg += _('Set an authentication URL, with --os-auth-url,' - ' OS_AUTH_URL or auth.auth_url\n') + msgs.append(_('Set an authentication URL, with --os-auth-url,' + ' OS_AUTH_URL or auth.auth_url')) if (required_scope and not options.auth.get('project_id') and not options.auth.get('domain_id') and not @@ -157,24 +157,28 @@ def check_valid_auth_options(options, auth_plugin_name, required_scope=True): options.auth.get('project_name') and not options.auth.get('tenant_id') and not options.auth.get('tenant_name')): - msg += _('Set a scope, such as a project or domain, set a ' - 'project scope with --os-project-name, OS_PROJECT_NAME ' - 'or auth.project_name, set a domain scope with ' - '--os-domain-name, OS_DOMAIN_NAME or auth.domain_name') + msgs.append(_('Set a scope, such as a project or domain, set a ' + 'project scope with --os-project-name, ' + 'OS_PROJECT_NAME or auth.project_name, set a domain ' + 'scope with --os-domain-name, OS_DOMAIN_NAME or ' + 'auth.domain_name')) elif auth_plugin_name.endswith('token'): if not options.auth.get('token'): - msg += _('Set a token with --os-token, OS_TOKEN or auth.token\n') + msgs.append(_('Set a token with --os-token, OS_TOKEN or ' + 'auth.token')) if not options.auth.get('auth_url'): - msg += _('Set a service AUTH_URL, with --os-auth-url, ' - 'OS_AUTH_URL or auth.auth_url\n') + msgs.append(_('Set a service AUTH_URL, with --os-auth-url, ' + 'OS_AUTH_URL or auth.auth_url')) elif auth_plugin_name == 'token_endpoint': if not options.auth.get('token'): - msg += _('Set a token with --os-token, OS_TOKEN or auth.token\n') + msgs.append(_('Set a token with --os-token, OS_TOKEN or ' + 'auth.token')) if not options.auth.get('url'): - msg += _('Set a service URL, with --os-url, OS_URL or auth.url\n') + msgs.append(_('Set a service URL, with --os-url, OS_URL or ' + 'auth.url')) - if msg: - raise exc.CommandError('Missing parameter(s): \n%s' % msg) + if msgs: + raise exc.CommandError('Missing parameter(s): \n%s' % '\n'.join(msgs)) def build_auth_plugins_option_parser(parser):