summaryrefslogtreecommitdiffstats
path: root/openstack
diff options
context:
space:
mode:
authorChuck Short <chuck.short@canonical.com>2013-05-01 09:40:43 -0500
committerChuck Short <chuck.short@canonical.com>2013-05-02 08:06:01 -0500
commit2f771aca390639cc49f71c451bd55c1d10db6f58 (patch)
tree5873dda954d351f5522a7451acb1215b7c85ab7c /openstack
parent90e83530d4dc49d570fa05ea63a93805717dcfa0 (diff)
downloadoslo-2f771aca390639cc49f71c451bd55c1d10db6f58.tar.gz
oslo-2f771aca390639cc49f71c451bd55c1d10db6f58.tar.xz
oslo-2f771aca390639cc49f71c451bd55c1d10db6f58.zip
Improve python3 compatibility
Change print statements so that it works with python3 as well. Change-Id: Iff16b62e4b875c79862c9af7726ea77627aa7b4f Signed-off-by: Chuck Short <chuck.short@canonical.com>
Diffstat (limited to 'openstack')
-rw-r--r--openstack/common/eventlet_backdoor.py12
-rw-r--r--openstack/common/setup.py6
-rw-r--r--openstack/common/wsgi.py18
3 files changed, 21 insertions, 15 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):