diff options
| -rw-r--r-- | openstack/common/eventlet_backdoor.py | 12 | ||||
| -rw-r--r-- | openstack/common/setup.py | 6 | ||||
| -rw-r--r-- | openstack/common/wsgi.py | 18 | ||||
| -rw-r--r-- | tools/install_venv_common.py | 22 | ||||
| -rw-r--r-- | update.py | 14 |
5 files changed, 41 insertions, 31 deletions
diff --git a/openstack/common/eventlet_backdoor.py b/openstack/common/eventlet_backdoor.py index c0ad460..57b89ae 100644 --- a/openstack/common/eventlet_backdoor.py +++ b/openstack/common/eventlet_backdoor.py @@ -16,6 +16,8 @@ # License for the specific language governing permissions and limitations # under the License. +from __future__ import print_function + import gc import pprint import sys @@ -37,7 +39,7 @@ CONF.register_opts(eventlet_backdoor_opts) def _dont_use_this(): - print "Don't use this, just disconnect instead" + print("Don't use this, just disconnect instead") def _find_objects(t): @@ -46,16 +48,16 @@ def _find_objects(t): def _print_greenthreads(): for i, gt in enumerate(_find_objects(greenlet.greenlet)): - print i, gt + print(i, gt) traceback.print_stack(gt.gr_frame) - print + print() def _print_nativethreads(): for threadId, stack in sys._current_frames().items(): - print threadId + print(threadId) traceback.print_stack(stack) - print + print() def initialize_if_enabled(): diff --git a/openstack/common/setup.py b/openstack/common/setup.py index ba6b54a..03b0675 100644 --- a/openstack/common/setup.py +++ b/openstack/common/setup.py @@ -20,6 +20,8 @@ Utilities with minimum-depends for use in setup.py """ +from __future__ import print_function + import email import os import re @@ -232,7 +234,7 @@ def get_cmdclass(): builders = ['html', 'man'] def generate_autoindex(self): - print "**Autodocumenting from %s" % os.path.abspath(os.curdir) + print("**Autodocumenting from %s" % os.path.abspath(os.curdir)) modules = {} option_dict = self.distribution.get_option_dict('build_sphinx') source_dir = os.path.join(option_dict['source_dir'][1], 'api') @@ -257,7 +259,7 @@ def get_cmdclass(): values = dict(module=module, heading=heading, underline=underline) - print "Generating %s" % output_filename + print("Generating %s" % output_filename) with open(output_filename, 'w') as output_file: output_file.write(_rst_template % values) autoindex.write(" %s.rst\n" % module) diff --git a/openstack/common/wsgi.py b/openstack/common/wsgi.py index 98a0874..064c09c 100644 --- a/openstack/common/wsgi.py +++ b/openstack/common/wsgi.py @@ -17,6 +17,8 @@ """Utility methods for working with WSGI servers.""" +from __future__ import print_function + import eventlet eventlet.patcher.monkey_patch(all=False, socket=True) @@ -203,16 +205,16 @@ class Debug(Middleware): @webob.dec.wsgify def __call__(self, req): - print ("*" * 40) + " REQUEST ENVIRON" + print(("*" * 40) + " REQUEST ENVIRON") for key, value in req.environ.items(): - print key, "=", value - print + print(key, "=", value) + print() resp = req.get_response(self.application) - print ("*" * 40) + " RESPONSE HEADERS" + print(("*" * 40) + " RESPONSE HEADERS") for (key, value) in resp.headers.iteritems(): - print key, "=", value - print + print(key, "=", value) + print() resp.app_iter = self.print_generator(resp.app_iter) @@ -224,12 +226,12 @@ class Debug(Middleware): Iterator that prints the contents of a wrapper string iterator when iterated. """ - print ("*" * 40) + " BODY" + print(("*" * 40) + " BODY") for part in app_iter: sys.stdout.write(part) sys.stdout.flush() yield part - print + print() class Router(object): diff --git a/tools/install_venv_common.py b/tools/install_venv_common.py index 0401a95..914fcf1 100644 --- a/tools/install_venv_common.py +++ b/tools/install_venv_common.py @@ -24,6 +24,8 @@ environment, it should be kept strictly compatible with Python 2.6. Synced in from openstack-common """ +from __future__ import print_function + import optparse import os import subprocess @@ -42,7 +44,7 @@ class InstallVenv(object): self.project = project def die(self, message, *args): - print >> sys.stderr, message % args + print(message % args, file=sys.stderr) sys.exit(1) def check_python_version(self): @@ -89,20 +91,20 @@ class InstallVenv(object): virtual environment. """ if not os.path.isdir(self.venv): - print 'Creating venv...', + print('Creating venv...', end=' ') if no_site_packages: self.run_command(['virtualenv', '-q', '--no-site-packages', self.venv]) else: self.run_command(['virtualenv', '-q', self.venv]) - print 'done.' - print 'Installing pip in venv...', + print('done.') + print('Installing pip in venv...', end=' ') if not self.run_command(['tools/with_venv.sh', 'easy_install', 'pip>1.0']).strip(): self.die("Failed to install pip.") - print 'done.' + print('done.') else: - print "venv already exists..." + print("venv already exists...") pass def pip_install(self, *args): @@ -111,7 +113,7 @@ class InstallVenv(object): redirect_output=False) def install_dependencies(self): - 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. @@ -153,12 +155,12 @@ class Distro(InstallVenv): return if self.check_cmd('easy_install'): - print 'Installing virtualenv via easy_install...', + print('Installing virtualenv via easy_install...', end=' ') if self.run_command(['easy_install', 'virtualenv']): - print 'Succeeded' + print('Succeeded') return else: - print 'Failed' + print('Failed') self.die('ERROR: virtualenv not found.\n\n%s development' ' requires virtualenv, please install it using your' @@ -55,6 +55,8 @@ the modules to copy and the base destination module Obviously, the first way is the easiest! """ +from __future__ import print_function + import functools import glob import os @@ -171,8 +173,8 @@ def _copy_pyfile(path, base, dest_dir): def _copy_module(mod, base, dest_dir): - print ("Copying openstack.common.%s under the %s module in %s" % - (mod, base, dest_dir)) + print(("Copying openstack.common.%s under the %s module in %s" % + (mod, base, dest_dir))) copy_pyfile = functools.partial(_copy_pyfile, base=base, dest_dir=dest_dir) @@ -203,7 +205,7 @@ def _copy_module(mod, base, dest_dir): for matches in [glob.glob(g) for g in globs_to_copy]: for match in matches: dest = os.path.join(dest_dir, match.replace('oslo', base)) - print "Copying %s to %s" % (match, dest) + print("Copying %s to %s" % (match, dest)) _copy_file(match, dest, base) @@ -275,15 +277,15 @@ def main(argv): dest_dir = os.path.dirname(conf.config_file[-1]) if not dest_dir or not os.path.isdir(dest_dir): - print >> sys.stderr, "A valid destination dir is required" + print("A valid destination dir is required", file=sys.stderr) sys.exit(1) if not conf.module and not conf.modules: - print >> sys.stderr, "A list of modules to copy is required" + print("A list of modules to copy is required", file=sys.stderr) sys.exit(1) if not conf.base: - print >> sys.stderr, "A destination base module is required" + print("A destination base module is required", file=sys.stderr) sys.exit(1) _create_module_init(conf.base, dest_dir) |
