diff --git a/ceilometerclient/common/utils.py b/ceilometerclient/common/utils.py index f28a3ea..67e7a2e 100644 --- a/ceilometerclient/common/utils.py +++ b/ceilometerclient/common/utils.py @@ -13,6 +13,7 @@ # License for the specific language governing permissions and limitations # under the License. +from __future__ import print_function import os import sys import textwrap @@ -59,7 +60,7 @@ def print_list(objs, fields, field_labels, formatters={}, sortby=0): data = getattr(o, field, '') row.append(data) pt.add_row(row) - print pt.get_string(sortby=field_labels[sortby]) + print(pt.get_string(sortby=field_labels[sortby])) def print_dict(d, dict_property="Property", wrap=0): @@ -84,7 +85,7 @@ def print_dict(d, dict_property="Property", wrap=0): if wrap > 0: v = textwrap.fill(str(v), wrap) pt.add_row([k, v]) - print pt.get_string() + print(pt.get_string()) def find_resource(manager, name_or_id): @@ -171,5 +172,5 @@ def merge_nested_dict(dest, source, depth=0): def exit(msg=''): if msg: - print >> sys.stderr, msg + print(msg, file=sys.stderr) sys.exit(1) diff --git a/ceilometerclient/tests/test_http.py b/ceilometerclient/tests/test_http.py index 308028a..602db54 100644 --- a/ceilometerclient/tests/test_http.py +++ b/ceilometerclient/tests/test_http.py @@ -13,11 +13,11 @@ # License for the specific language governing permissions and limitations # under the License. +from __future__ import print_function from ceilometerclient.tests import utils from ceilometerclient.common import http - fixtures = {} @@ -26,23 +26,23 @@ class HttpClientTest(utils.BaseTestCase): def test_url_generation_trailing_slash_in_base(self): client = http.HTTPClient('http://localhost/') url = client._make_connection_url('/v1/resources') - print client.connection_params + print(client.connection_params) self.assertEqual(url, '/v1/resources') def test_url_generation_without_trailing_slash_in_base(self): client = http.HTTPClient('http://localhost') url = client._make_connection_url('/v1/resources') - print client.connection_params + print(client.connection_params) self.assertEqual(url, '/v1/resources') def test_url_generation_prefix_slash_in_path(self): client = http.HTTPClient('http://localhost/') url = client._make_connection_url('/v1/resources') - print client.connection_params + print(client.connection_params) self.assertEqual(url, '/v1/resources') def test_url_generation_without_prefix_slash_in_path(self): client = http.HTTPClient('http://localhost') url = client._make_connection_url('v1/resources') - print client.connection_params + print(client.connection_params) self.assertEqual(url, '/v1/resources')