Skip to content

Commit 8c65315

Browse files
committed
Fix Python 3 Syntax Errors
1 parent 53d2294 commit 8c65315

File tree

14 files changed

+66
-65
lines changed

14 files changed

+66
-65
lines changed

llvm-lnt/fabfile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def new_log():
7878
get('/srv/lnt/install/lnt.log', 'lnt.log', )
7979
new_lines = {line for line in open("lnt.log", 'r').readlines()}
8080
for l in new_lines - lines:
81-
print ' '.join(l.split()[2:]),
81+
print(' '.join(l.split()[2:]), end=' ')
8282

8383

8484
@task
@@ -92,7 +92,7 @@ def rotate_log():
9292
sudo('rm -rf /srv/lnt/install/gunicorn.error.log')
9393
out = sudo('ps auxxxf | grep "gunicorn: master"')
9494
pid = re.search(r'lnt\s+(?P<pid>\d+)\s+', out).groupdict()['pid']
95-
print pid
95+
print(pid)
9696
sudo('kill -USR1 ' + pid)
9797

9898

@@ -113,7 +113,7 @@ def kill_zombies():
113113
pid = m.groupdict()['pid']
114114
pids.append(pid)
115115
else:
116-
print ">", line
116+
print(">", line)
117117
for pid in pids:
118118
sudo("kill -9 {}".format(pid))
119119

llvm-lnt/kill_zombies.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
pid = m.groupdict()['pid']
1717
pids.append(pid)
1818
else:
19-
print ">", line
19+
print(">", line)
2020

2121
if not pids:
22-
print "No PIDs to kill."
22+
print("No PIDs to kill.")
2323

2424
for pid in pids:
25-
print subprocess.check_output(["kill", "-9", "{}".format(pid)])
25+
print(subprocess.check_output(["kill", "-9", "{}".format(pid)]))

llvmbisect/llvmlab/ci.py

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ def find_binary(name):
247247
# Execute the command.
248248
try:
249249
cmd_object.execute(verbose=verbose)
250-
except OSError, e:
250+
except OSError as e:
251251
# Python's exceptions are horribly to read, and this one is
252252
# incredibly common when people don't use the right syntax (or
253253
# misspell something) when writing a predicate. Detect this and
@@ -277,9 +277,9 @@ def find_binary(name):
277277
data = f.read()
278278
f.close()
279279
if data:
280-
print ("-- command %s (note: suppressed by default, "
281-
"see sandbox dir for log files) --" % (type))
282-
print "--\n%s--\n" % data
280+
print("-- command %s (note: suppressed by default, "
281+
"see sandbox dir for log files) --" % (type))
282+
print("--\n%s--\n" % data)
283283

284284
test_result = cmd_object.result
285285
if not test_result:
@@ -393,8 +393,8 @@ def action_fetch(name, args):
393393
fatal('current directory is not clean, %r exists' % p)
394394
llvmlab.fetch_build_to_path(builder, build, root_path, builddir_path)
395395

396-
print 'downloaded root: %s' % root_path
397-
print 'extracted path : %s' % builddir_path
396+
print('downloaded root: %s' % root_path)
397+
print('extracted path : %s' % builddir_path)
398398

399399
# Update the symbolic link, if requested.
400400
if not opts.dry_run and opts.update_link:
@@ -408,7 +408,7 @@ def action_fetch(name, args):
408408

409409
# Create the symbolic link.
410410
os.symlink(os.path.abspath(builddir_path), opts.update_link)
411-
print 'updated link at: %s' % opts.update_link
411+
print('updated link at: %s' % opts.update_link)
412412
return os.path.abspath(builddir_path)
413413

414414

@@ -428,19 +428,19 @@ def action_ls(name, args):
428428
available_buildnames = llvmlab.fetch_builders()
429429
available_buildnames.sort()
430430
for item in available_buildnames:
431-
print item
431+
print(item)
432432
return available_buildnames
433433

434434
for name in args:
435435
if len(args) > 1:
436436
if name is not args[0]:
437-
print
438-
print '%s:' % name
437+
print()
438+
print('%s:' % name)
439439
available_builds = list(llvmlab.fetch_builds(name))
440440
available_builds.sort()
441441
available_builds.reverse()
442442
for build in available_builds:
443-
print build.tobasename(include_suffix=False)
443+
print(build.tobasename(include_suffix=False))
444444
min_rev = min([x.revision for x in available_builds])
445445
max_rev = max([x.revision for x in available_builds])
446446
note("Summary: found {} builds: r{}-r{}".format(len(available_builds),
@@ -546,8 +546,8 @@ def predicate(item):
546546
show_command_output=opts.show_command_output or opts.very_verbose)
547547

548548
# Print status.
549-
print '%s: %s' % (('FAIL', 'PASS')[test_result],
550-
item.tobasename(include_suffix=False))
549+
print('%s: %s' % (('FAIL', 'PASS')[test_result],
550+
item.tobasename(include_suffix=False)))
551551

552552
return test_result
553553

@@ -571,13 +571,13 @@ def predicate(item):
571571
if item is None:
572572
fatal('unable to find any passing build!')
573573

574-
print '%s: first working build' % item.tobasename(include_suffix=False)
574+
print('%s: first working build' % item.tobasename(include_suffix=False))
575575
index = available_builds.index(item)
576576
if index == 0:
577-
print 'no failing builds!?'
577+
print('no failing builds!?')
578578
else:
579-
print '%s: next failing build' % available_builds[index-1].tobasename(
580-
include_suffix=False)
579+
print('%s: next failing build' % available_builds[index-1].tobasename(
580+
include_suffix=False))
581581

582582

583583
def action_exec(name, args):
@@ -643,8 +643,8 @@ def action_exec(name, args):
643643
opts.sandbox, opts.build_name, build, args, verbose=True,
644644
show_command_output=True)
645645

646-
print '%s: %s' % (('FAIL', 'PASS')[test_result],
647-
build.tobasename(include_suffix=False))
646+
print('%s: %s' % (('FAIL', 'PASS')[test_result],
647+
build.tobasename(include_suffix=False)))
648648

649649
raise SystemExit(test_result != True)
650650

llvmbisect/llvmlab/test_llvmlab.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class TestLLVMLabCI(unittest.TestCase):
1010

1111
def setUp(self):
1212
self.workdir = tempfile.mkdtemp()
13-
print self.workdir
13+
print(self.workdir)
1414
os.chdir(self.workdir)
1515

1616
def tearDown(self):

llvmbisect/llvmlab/util.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def _write_message(kind, message):
1515
file,line,_,_,_ = inspect.getframeinfo(f)
1616
location = '%s:%d' % (os.path.basename(file), line)
1717

18-
print >>sys.stderr, '%s: %s: %s' % (location, kind, message)
18+
print('%s: %s: %s' % (location, kind, message), file=sys.stderr)
1919

2020
note = lambda message: _write_message('note', message)
2121
warning = lambda message: _write_message('warning', message)
@@ -205,7 +205,7 @@ def do_work():
205205
# Otherwise, execute the task and push to the output queue.
206206
try:
207207
output = (None, fn(item))
208-
except Exception, e:
208+
except Exception as e:
209209
output = ('error', sys.exc_info())
210210

211211
output_queue.put(output)

llvmlab/llvmlab/ci/buildbot/statusclient.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import sys
12
import time
23
import traceback
34
import urllib2
@@ -26,7 +27,7 @@ class BuilderInfo(object):
2627
def fromdata(data):
2728
version = data['version']
2829
if version != 0:
29-
raise ValueError, "Unknown version"
30+
raise ValueError("Unknown version")
3031

3132
return BuilderInfo(data['name'], data['last_build_number'],
3233
set(data['active_builds']), data['last_poll'])
@@ -57,7 +58,7 @@ class StatusClient(object):
5758
def fromdata(data):
5859
version = data['version']
5960
if version != 0:
60-
raise ValueError, "Unknown version"
61+
raise ValueError("Unknown version")
6162

6263
sc = StatusClient(data['master_url'], data['builders_poll_rate'],
6364
data['builder_poll_rate'])
@@ -107,22 +108,22 @@ def get_json_result(self, query_items, arguments=None):
107108
url = self.master_url + path
108109
try:
109110
request = urllib2.urlopen(url)
110-
except urllib2.HTTPError, err:
111+
except urllib2.HTTPError as err:
111112
# Turn 404 into a result missing error.
112113
if err.code == 404:
113114
raise ResultMissing
114115

115116
# Log this failure.
116117
os = StringIO.StringIO()
117-
print >>os, "*** ERROR: failure in 'get_json_result(%r, %r)' ***" %(
118-
query_items, arguments)
119-
print >>os, "URL: %r" % url
120-
print >>os, "\n-- Traceback --"
118+
print("*** ERROR: failure in 'get_json_result(%r, %r)' ***" %(
119+
query_items, arguments), file=os)
120+
print("URL: %r" % url, file=os)
121+
print("\n-- Traceback --", file=os)
121122
traceback.print_exc(file = os)
122123
if self.logger:
123124
self.logger.warning(os.getvalue())
124125
else:
125-
print >>sys.stderr, os.getvalue()
126+
print(os.getvalue(), file=sys.stderr)
126127
raise UnknownFailure
127128
data = request.read()
128129
request.close()
@@ -290,10 +291,10 @@ def main():
290291
try:
291292
while 1:
292293
for event in sc.pull_events():
293-
print time.time(), event
294+
print(time.time(), event)
294295
time.sleep(.1)
295296
except KeyboardInterrupt:
296-
print "(interrupted, stopping)"
297+
print("(interrupted, stopping)")
297298

298299
# Save the current instance.
299300
file = open(path, "w")

llvmlab/llvmlab/ci/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Phase(util.simple_repr_mixin):
1414
def fromdata(data):
1515
version = data['version']
1616
if version != 0:
17-
raise ValueError, "Unknown version"
17+
raise ValueError("Unknown version")
1818

1919
return Phase(data['name'], data['number'],
2020
data['phase_builder'], data['builder_names'],
@@ -45,7 +45,7 @@ class Builder(util.simple_repr_mixin):
4545
def fromdata(data):
4646
version = data['version']
4747
if version != 0:
48-
raise ValueError, "Unknown version"
48+
raise ValueError("Unknown version")
4949

5050
return Builder(data['name'])
5151

@@ -67,7 +67,7 @@ class PublishedBuild(util.simple_repr_mixin):
6767
def fromdata(data):
6868
version = data['version']
6969
if version != 0:
70-
raise ValueError, "Unknown version"
70+
raise ValueError("Unknown version")
7171

7272
return PublishedBuild(data['product'], data['os'],
7373
data['arch'], data['archive_name'])
@@ -99,7 +99,7 @@ class Config(util.simple_repr_mixin):
9999
def fromdata(data):
100100
version = data['version']
101101
if version != 0:
102-
raise ValueError, "Unknown version"
102+
raise ValueError("Unknown version")
103103

104104
return Config([Phases.fromdata(item)
105105
for item in data['phases']],

llvmlab/llvmlab/ci/status.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class BuildStatus(util.simple_repr_mixin):
1515
def fromdata(data):
1616
version = data['version']
1717
if version not in (0, 1):
18-
raise ValueError, "Unknown version"
18+
raise ValueError("Unknown version")
1919

2020
if version == 0:
2121
slave = None
@@ -144,7 +144,7 @@ class Status(util.simple_repr_mixin):
144144
def fromdata(data):
145145
version = data['version']
146146
if version != 0:
147-
raise ValueError, "Unknown version"
147+
raise ValueError("Unknown version")
148148

149149
sc = data.get('statusclient')
150150
if sc:

llvmlab/llvmlab/data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class Data(util.simple_repr_mixin):
1010
def fromdata(data):
1111
version = data['version']
1212
if version != 0:
13-
raise ValueError, "Unknown version"
13+
raise ValueError("Unknown version")
1414

1515
users = [user.User.fromdata(u)
1616
for u in data['users']]
@@ -33,7 +33,7 @@ def __init__(self, users, machines):
3333

3434
def set_admin_user(self, user):
3535
if user.id in self.users:
36-
raise ValueError, "database contains admin user %r" % user.id
36+
raise ValueError("database contains admin user %r" % user.id)
3737

3838
self.admin_user = user
3939
self.users[user.id] = user

llvmlab/llvmlab/llvmlabtool/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def split_name_and_email(str):
2525
if (str.count('<') != 1 or
2626
str.count('>') != 1 or
2727
not str.endswith('>')):
28-
raise ValueError,"Don't know how to parse: %r" % (str,)
28+
raise ValueError("Don't know how to parse: %r" % (str,))
2929

3030
lhs,rhs = str[:-1].split("<")
3131
return lhs.strip(), rhs.strip()

0 commit comments

Comments
 (0)