From e6f6890ac087d7218040e5b77a5a803c427cd395 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Mon, 24 Jun 2013 15:41:51 +0200 Subject: [PATCH] Use print_function compatible syntax This changes the code to use a python 3.x compatible print function syntax (or import from __future__ where necessary) Change-Id: Ia1f19d0ac082853d25c7c9b754b440469c0526eb --- heat/cmd/manage.py | 2 +- heat/common/wsgi.py | 4 ++-- heat/db/sqlalchemy/manage.py | 2 +- heat/db/sync.py | 10 ++++++---- heat/tests/fakes.py | 6 +++--- heat/tests/test_cli.py | 2 +- heat/tests/test_scheduler.py | 2 +- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/heat/cmd/manage.py b/heat/cmd/manage.py index 97262d81e2..1f19185f33 100644 --- a/heat/cmd/manage.py +++ b/heat/cmd/manage.py @@ -33,7 +33,7 @@ CONF = cfg.CONF def do_db_version(): """Print database's current migration level.""" - print migration.db_version() + print(migration.db_version()) def do_db_sync(): diff --git a/heat/common/wsgi.py b/heat/common/wsgi.py index 4b31d30f61..e628994644 100644 --- a/heat/common/wsgi.py +++ b/heat/common/wsgi.py @@ -318,13 +318,13 @@ class Debug(Middleware): def __call__(self, req): print ("*" * 40) + " REQUEST ENVIRON" for key, value in req.environ.items(): - print key, "=", value + print(key, "=", value) print resp = req.get_response(self.application) print ("*" * 40) + " RESPONSE HEADERS" for (key, value) in resp.headers.iteritems(): - print key, "=", value + print(key, "=", value) print resp.app_iter = self.print_generator(resp.app_iter) diff --git a/heat/db/sqlalchemy/manage.py b/heat/db/sqlalchemy/manage.py index dabb204cbd..4d57542e5e 100755 --- a/heat/db/sqlalchemy/manage.py +++ b/heat/db/sqlalchemy/manage.py @@ -22,4 +22,4 @@ if __name__ == '__main__': try: main(url=sql_connection, debug='False', repository=migrate_repo_path) except migrate.exceptions.DatabaseAlreadyControlledError: - print 'Database already version controlled.' + print('Database already version controlled.') diff --git a/heat/db/sync.py b/heat/db/sync.py index 9855fb3fdd..d95d6c556b 100755 --- a/heat/db/sync.py +++ b/heat/db/sync.py @@ -14,6 +14,8 @@ # License for the specific language governing permissions and limitations # under the License. +from __future__ import print_function + import gettext import sys @@ -29,9 +31,9 @@ LOG = logging.getLogger(__name__) if __name__ == '__main__': - print >>sys.stderr, '*******************************************' - print >>sys.stderr, 'Deprecated: use heat-manage db_sync instead' - print >>sys.stderr, '*******************************************' + print('*******************************************', file=sys.stderr) + print('Deprecated: use heat-manage db_sync instead', file=sys.stderr) + print('*******************************************', file=sys.stderr) cfg.CONF(project='heat', prog='heat-engine') api.configure() @@ -39,5 +41,5 @@ if __name__ == '__main__': try: migration.db_sync() except Exception as exc: - print >>sys.stderr, str(exc) + print(str(exc), file=sys.stderr) sys.exit(1) diff --git a/heat/tests/fakes.py b/heat/tests/fakes.py index f4e2fa82d3..7e8d3154e1 100644 --- a/heat/tests/fakes.py +++ b/heat/tests/fakes.py @@ -72,9 +72,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 = [] diff --git a/heat/tests/test_cli.py b/heat/tests/test_cli.py index bafb4d4549..464ce6b6eb 100644 --- a/heat/tests/test_cli.py +++ b/heat/tests/test_cli.py @@ -41,5 +41,5 @@ class CliTest(testtools.TestCase): stdout, stderr = proc.communicate() if proc.returncode: - print 'Error executing %s:\n %s %s ' % (bin, stdout, stderr) + print('Error executing %s:\n %s %s ' % (bin, stdout, stderr)) raise subprocess.CalledProcessError(proc.returncode, bin) diff --git a/heat/tests/test_scheduler.py b/heat/tests/test_scheduler.py index 7d12c912f2..ac20a88eda 100644 --- a/heat/tests/test_scheduler.py +++ b/heat/tests/test_scheduler.py @@ -31,7 +31,7 @@ class DummyTask(object): yield def do_step(self, step_num, *args, **kwargs): - print self, step_num + print(self, step_num) class PollingTaskGroupTest(mox.MoxTestBase):