Merge "python3: Basic python3 compatibility."
This commit is contained in:
commit
9ab7cdcef9
@ -19,6 +19,8 @@
|
||||
OpenStack Client interface. Handles the REST calls and responses.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
@ -234,13 +236,13 @@ class HTTPClient(object):
|
||||
self.management_url = management_url.rstrip('/')
|
||||
return None
|
||||
except exceptions.AmbiguousEndpoints:
|
||||
print "Found more than one valid endpoint. Use a more " \
|
||||
"restrictive filter"
|
||||
print("Found more than one valid endpoint. Use a more "
|
||||
"restrictive filter")
|
||||
raise
|
||||
except KeyError:
|
||||
raise exceptions.AuthorizationFailure()
|
||||
except exceptions.EndpointNotFound:
|
||||
print "Could not find any suitable endpoint. Correct region?"
|
||||
print("Could not find any suitable endpoint. Correct region?")
|
||||
raise
|
||||
|
||||
elif resp.status_code == 305:
|
||||
|
@ -18,6 +18,8 @@
|
||||
Command-line interface to the OpenStack Cinder API.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import glob
|
||||
import imp
|
||||
@ -470,7 +472,7 @@ class OpenStackCinderShell(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>')
|
||||
@ -500,14 +502,14 @@ def main():
|
||||
try:
|
||||
OpenStackCinderShell().main(map(strutils.safe_decode, sys.argv[1:]))
|
||||
except KeyboardInterrupt:
|
||||
print >> sys.stderr, "... terminating cinder client"
|
||||
print("... terminating cinder client", file=sys.stderr)
|
||||
sys.exit(130)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logger.debug(e, exc_info=1)
|
||||
message = e.message
|
||||
if not isinstance(message, basestring):
|
||||
message = str(message)
|
||||
print >> sys.stderr, "ERROR: %s" % strutils.safe_encode(message)
|
||||
print("ERROR: %s" % strutils.safe_encode(message), file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
|
@ -6,6 +6,8 @@ wrong the tests might raise AssertionError. I've indicated in comments the
|
||||
places where actual behavior differs from the spec.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
|
||||
def assert_has_keys(dict, required=[], optional=[]):
|
||||
keys = dict.keys()
|
||||
@ -58,9 +60,9 @@ class FakeClient(object):
|
||||
try:
|
||||
assert entry[2] == body
|
||||
except AssertionError:
|
||||
print entry[2]
|
||||
print "!="
|
||||
print body
|
||||
print(entry[2])
|
||||
print("!=")
|
||||
print(body)
|
||||
raise
|
||||
|
||||
self.client.callstack = []
|
||||
|
@ -13,6 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import os
|
||||
import re
|
||||
import sys
|
||||
@ -160,14 +162,14 @@ def print_list(objs, fields, formatters={}):
|
||||
pt.add_row(row)
|
||||
|
||||
if len(pt._rows) > 0:
|
||||
print strutils.safe_encode(pt.get_string(sortby=fields[0]))
|
||||
print(strutils.safe_encode(pt.get_string(sortby=fields[0])))
|
||||
|
||||
|
||||
def print_dict(d, property="Property"):
|
||||
pt = prettytable.PrettyTable([property, 'Value'], caching=False)
|
||||
pt.aligns = ['l', 'l']
|
||||
[pt.add_row(list(r)) for r in six.iteritems(d)]
|
||||
print strutils.safe_encode(pt.get_string(sortby=property))
|
||||
print(strutils.safe_encode(pt.get_string(sortby=property)))
|
||||
|
||||
|
||||
def find_resource(manager, name_or_id):
|
||||
|
@ -15,6 +15,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
@ -39,17 +41,17 @@ def _poll_for_status(poll_fn, obj_id, action, final_ok_states,
|
||||
sys.stdout.write(msg)
|
||||
sys.stdout.flush()
|
||||
|
||||
print
|
||||
print()
|
||||
while True:
|
||||
obj = poll_fn(obj_id)
|
||||
status = obj.status.lower()
|
||||
progress = getattr(obj, 'progress', None) or 0
|
||||
if status in final_ok_states:
|
||||
print_progress(100)
|
||||
print "\nFinished"
|
||||
print("\nFinished")
|
||||
break
|
||||
elif status == "error":
|
||||
print "\nError %(action)s instance" % locals()
|
||||
print("\nError %(action)s instance" % locals())
|
||||
break
|
||||
else:
|
||||
print_progress(progress)
|
||||
|
@ -13,6 +13,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import argparse
|
||||
import os
|
||||
import sys
|
||||
@ -35,17 +37,17 @@ def _poll_for_status(poll_fn, obj_id, action, final_ok_states,
|
||||
sys.stdout.write(msg)
|
||||
sys.stdout.flush()
|
||||
|
||||
print
|
||||
print()
|
||||
while True:
|
||||
obj = poll_fn(obj_id)
|
||||
status = obj.status.lower()
|
||||
progress = getattr(obj, 'progress', None) or 0
|
||||
if status in final_ok_states:
|
||||
print_progress(100)
|
||||
print "\nFinished"
|
||||
print("\nFinished")
|
||||
break
|
||||
elif status == "error":
|
||||
print "\nError %(action)s instance" % locals()
|
||||
print("\nError %(action)s instance" % locals())
|
||||
break
|
||||
else:
|
||||
print_progress(progress)
|
||||
|
@ -22,6 +22,8 @@
|
||||
Installation script for Nova's development virtualenv
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
import optparse
|
||||
import os
|
||||
import subprocess
|
||||
@ -37,7 +39,7 @@ PY_VERSION = "python%s.%s" % (sys.version_info[0], sys.version_info[1])
|
||||
|
||||
|
||||
def die(message, *args):
|
||||
print >> sys.stderr, message % args
|
||||
print(message % args, file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
@ -77,12 +79,12 @@ class Distro(object):
|
||||
return
|
||||
|
||||
if self.check_cmd('easy_install'):
|
||||
print 'Installing virtualenv via easy_install...',
|
||||
print('Installing virtualenv via easy_install...', end=' ')
|
||||
if run_command(['easy_install', 'virtualenv']):
|
||||
print 'Succeeded'
|
||||
print('Succeeded')
|
||||
return
|
||||
else:
|
||||
print 'Failed'
|
||||
print('Failed')
|
||||
|
||||
die('ERROR: virtualenv not found.\n\nDevelopment'
|
||||
' requires virtualenv, please install it using your'
|
||||
@ -162,17 +164,17 @@ def create_virtualenv(venv=VENV, no_site_packages=True):
|
||||
"""Creates the virtual environment and installs PIP only into the
|
||||
virtual environment
|
||||
"""
|
||||
print 'Creating venv...',
|
||||
print('Creating venv...', end=' ')
|
||||
if no_site_packages:
|
||||
run_command(['virtualenv', '-q', '--no-site-packages', VENV])
|
||||
else:
|
||||
run_command(['virtualenv', '-q', VENV])
|
||||
print 'done.'
|
||||
print 'Installing pip in virtualenv...',
|
||||
print('done.')
|
||||
print('Installing pip in virtualenv...', end=' ')
|
||||
if not run_command(['tools/with_venv.sh', 'easy_install',
|
||||
'pip>1.0']).strip():
|
||||
die("Failed to install pip.")
|
||||
print 'done.'
|
||||
print('done.')
|
||||
|
||||
|
||||
def pip_install(*args):
|
||||
@ -182,7 +184,7 @@ def pip_install(*args):
|
||||
|
||||
|
||||
def install_dependencies(venv=VENV):
|
||||
print 'Installing dependencies with pip (this can take a while)...'
|
||||
print('Installing dependencies with pip (this can take a while)...')
|
||||
|
||||
# First things first, make sure our venv has the latest pip and distribute.
|
||||
pip_install('pip')
|
||||
@ -220,7 +222,7 @@ def print_help():
|
||||
|
||||
Also, make test will automatically use the virtualenv.
|
||||
"""
|
||||
print help
|
||||
print(help)
|
||||
|
||||
|
||||
def parse_args():
|
||||
|
Loading…
x
Reference in New Issue
Block a user