Merge "Use Python 3.x compatible print syntax"
This commit is contained in:
@@ -44,7 +44,7 @@ def do_discover(cs, args):
|
||||
versions = cs.discover()
|
||||
if versions:
|
||||
if 'message' in versions:
|
||||
print versions['message']
|
||||
print(versions['message'])
|
||||
for key, version in versions.iteritems():
|
||||
if key != 'message':
|
||||
print (" - supports version %s (%s) here %s" %
|
||||
@@ -56,4 +56,4 @@ def do_discover(cs, args):
|
||||
print (" - and %s: %s" %
|
||||
(key, extension))
|
||||
else:
|
||||
print "No Keystone-compatible endpoint found"
|
||||
print("No Keystone-compatible endpoint found")
|
||||
|
@@ -18,6 +18,8 @@
|
||||
Command-line interface to the OpenStack Identity API.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import getpass
|
||||
import os
|
||||
@@ -321,7 +323,7 @@ class OpenStackIdentityShell(object):
|
||||
msg = ('WARNING: Bypassing authentication using a token & '
|
||||
'endpoint (authentication credentials are being '
|
||||
'ignored).')
|
||||
print msg
|
||||
print(msg)
|
||||
|
||||
else:
|
||||
if not args.os_auth_url:
|
||||
@@ -453,7 +455,7 @@ class OpenStackIdentityShell(object):
|
||||
|
||||
commands.remove('bash-completion')
|
||||
commands.remove('bash_completion')
|
||||
print ' '.join(commands | options)
|
||||
print(' '.join(commands | options))
|
||||
|
||||
@utils.arg('command', metavar='<subcommand>', nargs='?',
|
||||
help='Display help for <subcommand>')
|
||||
@@ -484,7 +486,7 @@ def main():
|
||||
OpenStackIdentityShell().main(sys.argv[1:])
|
||||
|
||||
except Exception as e:
|
||||
print >> sys.stderr, e
|
||||
print(e, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
@@ -42,7 +42,7 @@ def print_list(objs, fields, formatters={}, order_by=None):
|
||||
|
||||
if order_by is None:
|
||||
order_by = fields[0]
|
||||
print pt.get_string(sortby=order_by)
|
||||
print(pt.get_string(sortby=order_by))
|
||||
|
||||
|
||||
def _word_wrap(string, max_length=0):
|
||||
@@ -66,7 +66,7 @@ def print_dict(d, wrap=0):
|
||||
value = ''
|
||||
value = _word_wrap(value, max_length=wrap)
|
||||
pt.add_row([prop, value])
|
||||
print pt.get_string(sortby='Property')
|
||||
print(pt.get_string(sortby='Property'))
|
||||
|
||||
|
||||
def find_resource(manager, name_or_id):
|
||||
|
@@ -96,15 +96,15 @@ def do_user_update(kc, args):
|
||||
kwargs['enabled'] = utils.string_to_bool(args.enabled)
|
||||
|
||||
if not len(kwargs):
|
||||
print "User not updated, no arguments present."
|
||||
print("User not updated, no arguments present.")
|
||||
return
|
||||
|
||||
user = utils.find_resource(kc.users, args.user)
|
||||
try:
|
||||
kc.users.update(user, **kwargs)
|
||||
print 'User has been updated.'
|
||||
print('User has been updated.')
|
||||
except Exception as e:
|
||||
print 'Unable to update user: %s' % e
|
||||
print('Unable to update user: %s' % e)
|
||||
|
||||
|
||||
@utils.arg('--pass', metavar='<password>', dest='passwd', required=False,
|
||||
@@ -150,8 +150,8 @@ def do_password_update(kc, args):
|
||||
kc.users.update_own_password(currentpasswd, newpasswd)
|
||||
|
||||
if args.os_password != newpasswd:
|
||||
print "You should update the password you are using to authenticate "\
|
||||
"to match your new password"
|
||||
print("You should update the password you are using to authenticate "
|
||||
"to match your new password")
|
||||
|
||||
|
||||
@utils.arg('user', metavar='<user>', help='Name or ID of user to delete')
|
||||
@@ -208,7 +208,7 @@ def do_tenant_update(kc, args):
|
||||
kwargs.update({'enabled': utils.string_to_bool(args.enabled)})
|
||||
|
||||
if kwargs == {}:
|
||||
print "Tenant not updated, no arguments present."
|
||||
print("Tenant not updated, no arguments present.")
|
||||
return
|
||||
tenant.update(**kwargs)
|
||||
|
||||
@@ -419,9 +419,9 @@ def do_ec2_credentials_delete(kc, args):
|
||||
args.user_id = kc.auth_user_id
|
||||
try:
|
||||
kc.ec2.delete(args.user_id, args.access)
|
||||
print 'Credential has been deleted.'
|
||||
print('Credential has been deleted.')
|
||||
except Exception as e:
|
||||
print 'Unable to delete credential: %s' % e
|
||||
print('Unable to delete credential: %s' % e)
|
||||
|
||||
|
||||
@utils.arg('--service', metavar='<service-type>', default=None,
|
||||
@@ -432,7 +432,7 @@ def do_catalog(kc, args):
|
||||
endpoints = kc.service_catalog.get_endpoints(service_type=args.service)
|
||||
for (service, service_endpoints) in endpoints.iteritems():
|
||||
if len(service_endpoints) > 0:
|
||||
print "Service: %s" % service
|
||||
print("Service: %s" % service)
|
||||
for ep in service_endpoints:
|
||||
utils.print_dict(ep)
|
||||
|
||||
@@ -458,7 +458,7 @@ def do_endpoint_get(kc, args):
|
||||
if args.attr and args.value:
|
||||
kwargs.update({'attr': args.attr, 'filter_value': args.value})
|
||||
elif args.attr or args.value:
|
||||
print 'Both --attr and --value required.'
|
||||
print('Both --attr and --value required.')
|
||||
return
|
||||
|
||||
url = kc.service_catalog.url_for(**kwargs)
|
||||
@@ -498,9 +498,9 @@ def do_endpoint_delete(kc, args):
|
||||
"""Delete a service endpoint"""
|
||||
try:
|
||||
kc.endpoints.delete(args.id)
|
||||
print 'Endpoint has been deleted.'
|
||||
print('Endpoint has been deleted.')
|
||||
except Exception:
|
||||
print 'Unable to delete endpoint.'
|
||||
print('Unable to delete endpoint.')
|
||||
|
||||
|
||||
@utils.arg('--wrap', metavar='<integer>', default=0,
|
||||
|
@@ -94,7 +94,7 @@ def print_help():
|
||||
|
||||
Also, make test will automatically use the virtualenv.
|
||||
"""
|
||||
print help
|
||||
print(help)
|
||||
|
||||
|
||||
def main(argv):
|
||||
|
Reference in New Issue
Block a user