Python 3 Fixes: Use print() not print

For Python 3 fixes, use print() instead of the python 2 "print"
bareword syntax.

Change-Id: Ib77544d111aab6a1bd52555bcbd1dad9955d0074
This commit is contained in:
Morgan Fainberg 2016-05-27 08:42:17 -07:00 committed by Monty Taylor
parent 8fc762bc5e
commit 4c6a774419
No known key found for this signature in database
GPG Key ID: 3390DB68041A12F0
8 changed files with 18 additions and 21 deletions

View File

@ -1296,9 +1296,8 @@ class ZuulTestCase(BaseTestCase):
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 @@ class ZuulTestCase(BaseTestCase):
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")

View File

@ -33,13 +33,13 @@ LAYOUT_RE = re.compile(r'^(good|bad)_.*\.yaml$')
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 @@ class TestLayoutValidator(testtools.TestCase):
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)

View File

@ -1484,7 +1484,7 @@ jobs:
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 @@ jobs:
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))

View File

@ -35,7 +35,7 @@ for pipeline in data['pipelines']:
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,

View File

@ -154,7 +154,7 @@ class Client(zuul.cmd.ZuulApp):
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 @@ class Client(zuul.cmd.ZuulApp):
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):

View File

@ -99,7 +99,7 @@ class Launcher(zuul.cmd.ZuulApp):
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)

View File

@ -68,7 +68,7 @@ class Merger(zuul.cmd.ZuulApp):
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 @@ def main():
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'):

View File

@ -107,7 +107,7 @@ class Server(zuul.cmd.ZuulApp):
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 @@ class Server(zuul.cmd.ZuulApp):
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)