Python 3 Fixes: Use print() not print
For Python 3 fixes, use print() instead of the python 2 "print"
bareword syntax.
Change-Id: Ib77544d111aab6a1bd52555bcbd1dad9955d0074
diff --git a/tests/base.py b/tests/base.py
index 585f2d2..de5601b 100755
--- a/tests/base.py
+++ b/tests/base.py
@@ -1296,9 +1296,8 @@
start = time.time()
while True:
if time.time() - start > 10:
- print 'queue status:',
- print ' '.join(self.eventQueuesEmpty())
- print self.areAllBuildsWaiting()
+ print('queue status:', ''.join(self.eventQueuesEmpty()))
+ print(self.areAllBuildsWaiting())
raise Exception("Timeout waiting for Zuul to settle")
# Make sure no new events show up while we're checking
self.worker.lock.acquire()
@@ -1336,8 +1335,8 @@
for pipeline in self.sched.layout.pipelines.values():
for queue in pipeline.queues:
if len(queue.queue) != 0:
- print 'pipeline %s queue %s contents %s' % (
- pipeline.name, queue.name, queue.queue)
+ print('pipeline %s queue %s contents %s' % (
+ pipeline.name, queue.name, queue.queue))
self.assertEqual(len(queue.queue), 0,
"Pipelines queues should be empty")
diff --git a/tests/test_layoutvalidator.py b/tests/test_layoutvalidator.py
index 3dc3234..3de4a94 100644
--- a/tests/test_layoutvalidator.py
+++ b/tests/test_layoutvalidator.py
@@ -33,13 +33,13 @@
class TestLayoutValidator(testtools.TestCase):
def test_layouts(self):
"""Test layout file validation"""
- print
+ print()
errors = []
for fn in os.listdir(os.path.join(FIXTURE_DIR, 'layouts')):
m = LAYOUT_RE.match(fn)
if not m:
continue
- print fn
+ print(fn)
# Load any .conf file by the same name but .conf extension.
config_file = ("%s.conf" %
@@ -69,7 +69,7 @@
fn)
except voluptuous.Invalid as e:
error = str(e)
- print ' ', error
+ print(' ', error)
if error in errors:
raise Exception("Error has already been tested: %s" %
error)
diff --git a/tests/test_scheduler.py b/tests/test_scheduler.py
index 15d33c8..053b1cc 100755
--- a/tests/test_scheduler.py
+++ b/tests/test_scheduler.py
@@ -1484,7 +1484,7 @@
self.worker.build_history = []
path = os.path.join(self.git_root, "org/project")
- print repack_repo(path)
+ print(repack_repo(path))
A = self.fake_gerrit.addFakeChange('org/project', 'master', 'A')
A.addApproval('CRVW', 2)
@@ -1509,9 +1509,9 @@
A = self.fake_gerrit.addFakeChange('org/project1', 'master', 'A')
A.addPatchset(large=True)
path = os.path.join(self.upstream_root, "org/project1")
- print repack_repo(path)
+ print(repack_repo(path))
path = os.path.join(self.git_root, "org/project1")
- print repack_repo(path)
+ print(repack_repo(path))
A.addApproval('CRVW', 2)
self.fake_gerrit.addEvent(A.addApproval('APRV', 1))
diff --git a/tools/zuul-changes.py b/tools/zuul-changes.py
index 9dbf504..8b854c7 100755
--- a/tools/zuul-changes.py
+++ b/tools/zuul-changes.py
@@ -35,7 +35,7 @@
if not change['live']:
continue
cid, cps = change['id'].split(',')
- print (
+ print(
"zuul enqueue --trigger gerrit --pipeline %s "
"--project %s --change %s,%s" % (
options.pipeline_name,
diff --git a/zuul/cmd/client.py b/zuul/cmd/client.py
index 59ac419..1ce2828 100644
--- a/zuul/cmd/client.py
+++ b/zuul/cmd/client.py
@@ -154,7 +154,7 @@
running_items = client.get_running_jobs()
if len(running_items) == 0:
- print "No jobs currently running"
+ print("No jobs currently running")
return True
all_fields = self._show_running_jobs_columns()
@@ -181,7 +181,7 @@
v += all_fields[f]['append']
values.append(v)
table.add_row(values)
- print table
+ print(table)
return True
def _epoch_to_relative_time(self, epoch):
diff --git a/zuul/cmd/launcher.py b/zuul/cmd/launcher.py
index 2ba4b85..bbda87d 100644
--- a/zuul/cmd/launcher.py
+++ b/zuul/cmd/launcher.py
@@ -99,7 +99,7 @@
try:
signal.pause()
except KeyboardInterrupt:
- print "Ctrl + C: asking launcher to exit nicely...\n"
+ print("Ctrl + C: asking launcher to exit nicely...\n")
self.exit_handler()
sys.exit(0)
diff --git a/zuul/cmd/merger.py b/zuul/cmd/merger.py
index df215fd..797a990 100644
--- a/zuul/cmd/merger.py
+++ b/zuul/cmd/merger.py
@@ -68,7 +68,7 @@
try:
signal.pause()
except KeyboardInterrupt:
- print "Ctrl + C: asking merger to exit nicely...\n"
+ print("Ctrl + C: asking merger to exit nicely...\n")
self.exit_handler(signal.SIGINT, None)
@@ -89,9 +89,7 @@
f.close()
os.unlink(test_fn)
except Exception:
- print
- print "Unable to write to state directory: %s" % state_dir
- print
+ print("\nUnable to write to state directory: %s\n" % state_dir)
raise
if server.config.has_option('merger', 'pidfile'):
diff --git a/zuul/cmd/server.py b/zuul/cmd/server.py
index 6db15a2..f400436 100755
--- a/zuul/cmd/server.py
+++ b/zuul/cmd/server.py
@@ -107,7 +107,7 @@
jobs.add(v)
for job in sorted(layout.jobs):
if job not in jobs:
- print "Job %s not defined" % job
+ print("Job %s not defined" % job)
failure = True
return failure
@@ -196,7 +196,7 @@
try:
signal.pause()
except KeyboardInterrupt:
- print "Ctrl + C: asking scheduler to exit nicely...\n"
+ print("Ctrl + C: asking scheduler to exit nicely...\n")
self.exit_handler(signal.SIGINT, None)