Commit c1e46869 authored by Alex Pearce's avatar Alex Pearce Committed by kreczko
Browse files

Use Python 3 compatible printing and importing.

parent 80a85700
#!/usr/bin/env python
from __future__ import print_function
import os
import sys
import re
......@@ -21,7 +21,7 @@ def main():
project, version, outputfile = args
if not opts.quiet:
print "Creating %s for %s %s" % (outputfile, project, version)
print("Creating %s for %s %s" % (outputfile, project, version))
for style in [lhcb_ver_style, atlas_ver_style, plain_ver_style]:
m = re.match(style, version)
......@@ -38,7 +38,7 @@ def main():
outdir = os.path.dirname(outputfile)
if not os.path.exists(outdir):
if not opts.quiet:
print "Creating directory", outdir
print("Creating directory", outdir)
os.makedirs(outdir)
# Prepare data to be written
......
......@@ -5,12 +5,12 @@ Gaudi cmake process (See Instrument.cmake) and create an other file
understandable by kcachegrind for easy visualization of where we spend time in
cmake.
'''
from __future__ import print_function
import sys
def usage():
print "Invalid arguments\nProper syntax is :\n %s <log file> <callgrind file>" % sys.argv[
0]
print("Invalid arguments\nProper syntax is :\n %s <log file> <callgrind file>" % sys.argv[0])
if len(sys.argv) != 3:
......@@ -45,7 +45,7 @@ for line in open(sys.argv[1]).readlines():
elif key == 'ENDTIME':
sfunc, stime = callStack.pop()
if sfunc != func:
print 'Mismatch START/END for %s/%s' % (sfunc, func)
print('Mismatch START/END for %s/%s' % (sfunc, func))
sys.exit()
deltatime = int(time) - stime
# add time spent to this function
......
......@@ -111,7 +111,7 @@ def analyze_suites(pkg, rootdir):
# transpose the dictionary of lists
test_labels = collections.defaultdict(set)
for label, tests in labels.iteritems():
for label, tests in labels.items():
for test in tests:
test_labels[test].add(label)
......
......@@ -90,7 +90,7 @@ def main():
if new_deps != old_deps: # write it only if it has changed
open(output, 'w').write(new_deps)
if old_deps and not opts.for_make:
print 'info: dependencies changed: next build will trigger a reconfigure'
print('info: dependencies changed: next build will trigger a reconfigure')
if __name__ == '__main__':
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
import os
import re
import atexit
......@@ -22,7 +23,7 @@ def update_coverage():
else:
data = {'lines': {}}
lines = data['lines']
for filename, linenumbers in coverage.iteritems():
for filename, linenumbers in coverage.items():
lines[filename] = sorted(linenumbers.union(lines.get(filename, [])))
with open(COVERAGE_FILE, 'w') as report:
cPickle.dump(data, report)
......@@ -84,9 +85,9 @@ if __name__ == '__main__':
lines = data['lines']
for filename in sorted(lines):
if not os.path.exists(filename):
print 'Unknown file', filename
print('Unknown file', filename)
continue
print filename
print(filename)
active_lines = set(get_active_lines(filename))
touched_lines = set(lines[filename])
missed_lines = active_lines.difference(touched_lines)
......@@ -97,7 +98,7 @@ if __name__ == '__main__':
touched_count = len(touched_lines)
active_count = len(active_lines)
if touched_count == active_count:
print ' coverage 100%'
print(' coverage 100%')
else:
print(' coverage %3d%%, missed: %s' % (
float(touched_count) / active_count * 100, ', '.join(ranges)))
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
from cmake_coverage import cmake_script
from os.path import join, curdir
......@@ -21,10 +21,10 @@ class CMakeTestScripts(object):
def run(self, name):
script_name = join(self.scripts_dir, 'test_%s.cmake' % name)
out, err, returncode = cmake_script(script_name, cwd=self.base_dir)
print "---------- stdout ----------"
print out
print "---------- stderr ----------"
print err
print("---------- stdout ----------")
print(out)
print("---------- stderr ----------")
print(err)
assert returncode == 0
def test_scripts(self):
......
# -*- coding: utf-8 -*-
from __future__ import print_function
from cmake_coverage import cmake_script
from os.path import join, dirname
......@@ -10,10 +10,10 @@ scripts_dir = join(base_dir, 'cmake_scripts')
def test_loops():
script_name = join(scripts_dir, 'test_loops.cmake')
out, err, returncode = cmake_script(script_name, cwd=base_dir)
print "---------- stdout ----------"
print out
print "---------- stderr ----------"
print err
print("---------- stdout ----------")
print(out)
print("---------- stderr ----------")
print(err)
assert returncode != 0
assert 'Infinite recursion detected at project Loop' in err
......@@ -21,9 +21,9 @@ def test_loops():
def test_missing_base():
script_name = join(scripts_dir, 'test_missing_base.cmake')
out, err, returncode = cmake_script(script_name, cwd=base_dir)
print "---------- stdout ----------"
print out
print "---------- stderr ----------"
print err
print("---------- stdout ----------")
print(out)
print("---------- stderr ----------")
print(err)
assert returncode != 0
assert 'Cannot find project IDoNotExist v0r0' in err
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment