diff options
author | Rahul Chaudhry <rahulchaudhry@chromium.org> | 2015-12-30 17:05:14 -0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-01-04 20:39:25 +0000 |
commit | cbc5a2617f8d63e3319e159eab2c407952df1df9 (patch) | |
tree | 6cf71747d12dc0c4f5f9c1d14f82848ffd14a7c4 | |
parent | 278fc7437c8a31554903161eadfac2550507a47f (diff) | |
download | toolchain-utils-cbc5a2617f8d63e3319e159eab2c407952df1df9.tar.gz |
toolchain-utils: fix missing-print-function lint warnings.
BUG=chromium:570458
TEST='crosperf/run_tests.sh' passes.
Change-Id: I2e0cf0d903b0ca7662132528ee6860ea8eaee83b
Reviewed-on: https://chrome-internal-review.googlesource.com/243412
Commit-Ready: Rahul Chaudhry <rahulchaudhry@google.com>
Tested-by: Rahul Chaudhry <rahulchaudhry@google.com>
Reviewed-by: Caroline Tice <cmtice@google.com>
27 files changed, 111 insertions, 54 deletions
diff --git a/binary_search_tool/cros_pkg/cros_pkg_create_cleanup_script.py b/binary_search_tool/cros_pkg/cros_pkg_create_cleanup_script.py index 640ca658..3fc1bb61 100755 --- a/binary_search_tool/cros_pkg/cros_pkg_create_cleanup_script.py +++ b/binary_search_tool/cros_pkg/cros_pkg_create_cleanup_script.py @@ -9,12 +9,14 @@ # original state. # +from __future__ import print_function + import argparse import sys def Usage(parser, msg): - print 'ERROR: ' + msg + print('ERROR: ' + msg) parser.print_help() sys.exit(1) diff --git a/binary_search_tool/cros_pkg/cros_pkg_undo_eclean.py b/binary_search_tool/cros_pkg/cros_pkg_undo_eclean.py index cd7b2c89..ed934c47 100755 --- a/binary_search_tool/cros_pkg/cros_pkg_undo_eclean.py +++ b/binary_search_tool/cros_pkg/cros_pkg_undo_eclean.py @@ -10,6 +10,8 @@ # output file, in effect commenting out any lines that contain 'eclean'. # +from __future__ import print_function + import sys import os diff --git a/binary_search_tool/test/binary_search_tool_tester.py b/binary_search_tool/test/binary_search_tool_tester.py index 20defe2f..72816790 100755 --- a/binary_search_tool/test/binary_search_tool_tester.py +++ b/binary_search_tool/test/binary_search_tool_tester.py @@ -3,6 +3,8 @@ # Copyright 2012 Google Inc. All Rights Reserved. """Tests for bisecting tool.""" +from __future__ import print_function + __author__ = 'shenhan@google.com (Han Shen)' import os @@ -31,8 +33,8 @@ class BisectingUtilsTest(unittest.TestCase): """Cleanup temp files.""" os.remove(common.OBJECTS_FILE) os.remove(common.WORKING_SET_FILE) - print 'Deleted "{0}" and "{1}"'.format(common.OBJECTS_FILE, - common.WORKING_SET_FILE) + print('Deleted "{0}" and "{1}"'.format(common.OBJECTS_FILE, + common.WORKING_SET_FILE)) def runTest(self): args = ['--get_initial_items', './gen_init_list.py', '--switch_to_good', diff --git a/binary_search_tool/test/gen_init_list.py b/binary_search_tool/test/gen_init_list.py index c1348119..e840973c 100755 --- a/binary_search_tool/test/gen_init_list.py +++ b/binary_search_tool/test/gen_init_list.py @@ -1,6 +1,8 @@ #!/usr/bin/python2 """Prints out index for every object file, starting from 0.""" +from __future__ import print_function + import sys from utils import command_executer @@ -12,7 +14,7 @@ def Main(): _, l, _ = ce.RunCommandWOutput('cat {0} | wc -l'.format(common.OBJECTS_FILE), print_to_console=False) for i in range(0, int(l)): - print i + print(i) if __name__ == '__main__': diff --git a/binary_search_tool/test/switch_to_bad.py b/binary_search_tool/test/switch_to_bad.py index 25f76304..b8602421 100755 --- a/binary_search_tool/test/switch_to_bad.py +++ b/binary_search_tool/test/switch_to_bad.py @@ -1,6 +1,8 @@ #!/usr/bin/python2 """Switch part of the objects file in working set to (possible) bad ones.""" +from __future__ import print_function + import sys import common diff --git a/crosperf/crosperf.py b/crosperf/crosperf.py index 2466ac6c..cc2c9010 100755 --- a/crosperf/crosperf.py +++ b/crosperf/crosperf.py @@ -3,6 +3,8 @@ # Copyright 2011 Google Inc. All Rights Reserved. """The driver script for running performance benchmarks on ChromeOS.""" +from __future__ import print_function + import atexit import optparse import os diff --git a/crosperf/experiment_runner_unittest.py b/crosperf/experiment_runner_unittest.py index fe5733e4..320c5014 100755 --- a/crosperf/experiment_runner_unittest.py +++ b/crosperf/experiment_runner_unittest.py @@ -1,6 +1,9 @@ #!/usr/bin/python2 # # Copyright 2014 Google Inc. All Rights Reserved + +from __future__ import print_function + import StringIO import getpass import os diff --git a/crosperf/machine_manager_unittest.py b/crosperf/machine_manager_unittest.py index f0084a0d..440f9bba 100755 --- a/crosperf/machine_manager_unittest.py +++ b/crosperf/machine_manager_unittest.py @@ -2,6 +2,9 @@ # Copyright 2012 Google Inc. All Rights Reserved. """Unittest for machine_manager.""" + +from __future__ import print_function + import os.path import time import hashlib diff --git a/crosperf/suite_runner.py b/crosperf/suite_runner.py index 527aa984..b76f85e9 100644 --- a/crosperf/suite_runner.py +++ b/crosperf/suite_runner.py @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +from __future__ import print_function + import os import time import shlex diff --git a/utils/buildbot_json.py b/utils/buildbot_json.py index cf8fcb30..825ac8a5 100755 --- a/utils/buildbot_json.py +++ b/utils/buildbot_json.py @@ -31,6 +31,8 @@ """Queries buildbot through the json interface. """ +from __future__ import print_function + __author__ = 'maruel@chromium.org' __version__ = '1.2' @@ -1033,15 +1035,15 @@ def CMDpending(parser, args): pending_builds = builder.data.get('pendingBuilds', 0) if not pending_builds: continue - print 'Builder %s: %d' % (builder.name, pending_builds) + print('Builder %s: %d' % (builder.name, pending_builds)) if not options.quiet: for pending in builder.pending_builds.data: if 'revision' in pending['source']: - print ' revision: %s' % pending['source']['revision'] + print(' revision: %s' % pending['source']['revision']) for change in pending['source']['changes']: - print ' change:' - print ' comment: %r' % unicode(change['comments'][:50]) - print ' who: %s' % change['who'] + print(' change:') + print(' comment: %r' % unicode(change['comments'][:50])) + print(' who: %s' % change['who']) return 0 @@ -1108,7 +1110,7 @@ def CMDdisconnected(parser, args): parser.error('Unrecognized parameters: %s' % ' '.join(args)) for slave in buildbot.slaves: if not slave.connected: - print slave.name + print(slave.name) return 0 @@ -1146,10 +1148,10 @@ def find_idle_busy_slaves(parser, args, show_idle): slaves = natsorted(set(slaves) & set(busy_slaves)) if options.quiet: for slave in slaves: - print slave + print(slave) else: if slaves: - print 'Builder %s: %s' % (builder.name, ', '.join(slaves)) + print('Builder %s: %s' % (builder.name, ', '.join(slaves))) return 0 @@ -1241,20 +1243,20 @@ def CMDlast_failure(parser, args): no_cache=options.no_cache): if print_builders and last_builder != build.builder: - print build.builder.name + print(build.builder.name) last_builder = build.builder if options.quiet: if options.slaves: - print '%s: %s' % (build.builder.name, build.slave.name) + print('%s: %s' % (build.builder.name, build.slave.name)) else: - print build.slave.name + print(build.slave.name) else: out = '%d on %s: blame:%s' % (build.number, build.slave.name, ', '.join(build.blame)) if print_builders: out = ' ' + out - print out + print(out) if len(options.steps) != 1: for step in build.steps: @@ -1264,7 +1266,7 @@ def CMDlast_failure(parser, args): out = ' %s: "%s"' % (step.data['name'], summary) if print_builders: out = ' ' + out - print out + print(out) return 0 @@ -1293,16 +1295,16 @@ def CMDcurrent(parser, args): if build.blame: for blamed in build.blame: blame.add(blamed) - print '\n'.join(blame) + print('\n'.join(blame)) return 0 for builder in options.builders: builder = buildbot.builders[builder] if not options.quiet and builder.current_builds: - print builder.name + print(builder.name) for build in builder.current_builds: if options.quiet: - print build.slave.name + print(build.slave.name) else: out = '%4d: slave=%10s' % (build.number, build.slave.name) out += ' duration=%5d' % (build.duration or 0) @@ -1312,7 +1314,7 @@ def CMDcurrent(parser, args): out += ' ' if build.blame: out += ' blame=' + ', '.join(build.blame) - print out + print(out) return 0 @@ -1359,9 +1361,9 @@ def CMDbuilds(parser, args): out += '%s/' % build.slave.name out += '%d revision:%s result:%s blame:%s' % ( build.number, build.revision, build.result, ','.join(build.blame)) - print out + print(out) else: - print build + print(build) return 0 @@ -1393,27 +1395,27 @@ def CMDcount(parser, args): builder = buildbot.builders[builder] counts[builder.name] = 0 if not options.quiet: - print builder.name + print(builder.name) for build in builder.builds.iterall(): try: start_time = build.start_time except urllib2.HTTPError: # The build was probably trimmed. - print >> sys.stderr, ('Failed to fetch build %s/%d' % - (builder.name, build.number)) + print('Failed to fetch build %s/%d' % (builder.name, build.number), + file=sys.stderr) continue if start_time >= since: counts[builder.name] += 1 else: break if not options.quiet: - print '.. %d' % counts[builder.name] + print('.. %d' % counts[builder.name]) align_name = max(len(b) for b in counts) align_number = max(len(str(c)) for c in counts.itervalues()) for builder in sorted(counts): - print '%*s: %*d' % (align_name, builder, align_number, counts[builder]) - print 'Total: %d' % sum(counts.itervalues()) + print('%*s: %*d' % (align_name, builder, align_number, counts[builder])) + print('Total: %d' % sum(counts.itervalues())) return 0 diff --git a/utils/buildbot_utils.py b/utils/buildbot_utils.py index f95f2e8b..8f83c972 100644 --- a/utils/buildbot_utils.py +++ b/utils/buildbot_utils.py @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +from __future__ import print_function + import os import time import urllib2 @@ -96,7 +98,7 @@ def FindBuildRecordFromLog(description, log_info): # We found a match; we're done. return my_dict except: - print "reason is not in dictionary: '%s'" % repr(my_dict) + print("reason is not in dictionary: '%s'" % repr(my_dict)) else: # Keep going. continue diff --git a/utils/command_executer.py b/utils/command_executer.py index a7131ef2..423eded2 100644 --- a/utils/command_executer.py +++ b/utils/command_executer.py @@ -3,6 +3,8 @@ # found in the LICENSE file. """Utilities to run commands in outside/inside chroot and on the board.""" +from __future__ import print_function + import getpass import os import re diff --git a/utils/command_executer_unittest.py b/utils/command_executer_unittest.py index cf5bf683..6922febe 100755 --- a/utils/command_executer_unittest.py +++ b/utils/command_executer_unittest.py @@ -1,5 +1,8 @@ #!/usr/bin/python2 """Unittest for command_executer.py.""" + +from __future__ import print_function + import time import unittest diff --git a/utils/email_sender.py b/utils/email_sender.py index 3300867a..1ae701ef 100755 --- a/utils/email_sender.py +++ b/utils/email_sender.py @@ -3,6 +3,8 @@ # Copyright 2011 Google Inc. All Rights Reserved. """Utilities to send email either through SMTP or SendGMR.""" +from __future__ import print_function + from email import Encoders from email.MIMEBase import MIMEBase from email.MIMEMultipart import MIMEMultipart diff --git a/utils/file_utils.py b/utils/file_utils.py index cb2e417f..a9a84d5a 100644 --- a/utils/file_utils.py +++ b/utils/file_utils.py @@ -1,5 +1,7 @@ # Copyright 2011 Google Inc. All Rights Reserved. +from __future__ import print_function + import errno import os import shutil diff --git a/utils/locks.py b/utils/locks.py index 5d865710..ef224ee7 100644 --- a/utils/locks.py +++ b/utils/locks.py @@ -1,6 +1,8 @@ # Copyright 2015 The Chromium OS Authors. All rights reserved. """Utilities for locking machines.""" +from __future__ import print_function + import time import afe_lock_machine diff --git a/utils/logger.py b/utils/logger.py index 147f359d..8006d4b9 100644 --- a/utils/logger.py +++ b/utils/logger.py @@ -1,5 +1,7 @@ # Copyright 2010 Google Inc. All Rights Reserved. +from __future__ import print_function + # System modules import os.path import sys @@ -26,7 +28,7 @@ class Logger(object): os.makedirs(logdir) except OSError: pass - # print "Warning: Logs directory '%s' already exists." % logdir + # print("Warning: Logs directory '%s' already exists." % logdir) self.print_console = print_console @@ -63,7 +65,7 @@ class Logger(object): try: fd = open(name, 'w') except IOError: - print 'Warning: could not open %s for writing.' % name + print('Warning: could not open %s for writing.' % name) return fd def _CreateLogFileHandles(self, basename): @@ -86,7 +88,7 @@ class Logger(object): os.remove(dest_file) os.symlink(src_file, dest_file) except Exception as ex: - print 'Exception while creating symlinks: %s' % str(ex) + print('Exception while creating symlinks: %s' % str(ex)) def _WriteTo(self, fd, msg, flush): if fd: @@ -231,15 +233,15 @@ class MockLogger(object): return suffix def _CreateLogFileHandle(self, name): - print 'MockLogger: creating open file handle for %s (writing)' % name + print('MockLogger: creating open file handle for %s (writing)' % name) def _CreateLogFileHandles(self, basename): suffix = self._FindSuffix(basename) suffixed_basename = self._AddSuffix(basename, suffix) - print 'MockLogger: opening file %s.cmd' % suffixed_basename - print 'MockLogger: opening file %s.out' % suffixed_basename - print 'MockLogger: opening file %s.err' % suffixed_basename + print('MockLogger: opening file %s.cmd' % suffixed_basename) + print('MockLogger: opening file %s.out' % suffixed_basename) + print('MockLogger: opening file %s.err' % suffixed_basename) self._CreateLogFileSymlinks(basename, suffixed_basename) @@ -248,22 +250,22 @@ class MockLogger(object): for extension in ['cmd', 'out', 'err']: src_file = '%s.%s' % (os.path.basename(suffixed_basename), extension) dest_file = '%s.%s' % (basename, extension) - print 'MockLogger: Calling os.symlink(%s, %s)' % (src_file, dest_file) + print('MockLogger: Calling os.symlink(%s, %s)' % (src_file, dest_file)) def _WriteTo(self, fd, msg, flush): - print 'MockLogger: %s' % msg + print('MockLogger: %s' % msg) def LogStartDots(self, print_to_console=True): - print '. ' + print('. ') def LogAppendDot(self, print_to_console=True): - print '. ' + print('. ') def LogEndDots(self, print_to_console=True): - print '\n' + print('\n') def LogMsg(self, file_fd, term_fd, msg, flush=True): - print 'MockLogger: %s' % msg + print('MockLogger: %s' % msg) def _GetStdout(self, print_to_console): # if print_to_console: @@ -280,7 +282,7 @@ class MockLogger(object): host = ('%s@%s' % (user, machine)) if user else machine cmd_string = 'CMD (%s): %s\n' % (host, cmd) - print 'MockLogger: Writing to file ONLY: %s' % cmd_string + print('MockLogger: Writing to file ONLY: %s' % cmd_string) def LogCmd(self, cmd, machine='', user=None, print_to_console=True): if user: @@ -295,7 +297,7 @@ class MockLogger(object): self.LogMsg(0, self._GetStderr(print_to_console), 'FATAL: %s\n' % msg) self.LogMsg(0, self._GetStderr(print_to_console), '\n'.join(traceback.format_stack())) - print 'MockLogger: Calling sysexit(1)' + print('MockLogger: Calling sysexit(1)') def LogError(self, msg, print_to_console=True): self.LogMsg(0, self._GetStderr(print_to_console), 'ERROR: %s\n' % msg) @@ -331,7 +333,7 @@ class MockLogger(object): flush=False) def Flush(self): - print 'MockLogger: Flushing cmdfd, stdout, stderr' + print('MockLogger: Flushing cmdfd, stdout, stderr') main_logger = None diff --git a/utils/machines.py b/utils/machines.py index 1973e656..73aa96ad 100644 --- a/utils/machines.py +++ b/utils/machines.py @@ -3,6 +3,8 @@ # found in the LICENSE file. """Utilities relating to machine-specific functions.""" +from __future__ import print_function + from utils import command_executer diff --git a/utils/manifest_versions.py b/utils/manifest_versions.py index c09ac00c..f011282b 100644 --- a/utils/manifest_versions.py +++ b/utils/manifest_versions.py @@ -3,6 +3,8 @@ # found in the LICENSE file. """Tools for searching/manipulating the manifests repository.""" +from __future__ import print_function + __author__ = 'llozano@google.com (Luis Lozano)' import os diff --git a/utils/misc.py b/utils/misc.py index ecc0b1a5..90d41b2e 100644 --- a/utils/misc.py +++ b/utils/misc.py @@ -3,6 +3,8 @@ # found in the LICENSE file. """Utilities for toolchain build.""" +from __future__ import print_function + __author__ = 'asharif@google.com (Ahmad Sharif)' from contextlib import contextmanager @@ -428,7 +430,7 @@ def DeleteChromeOsTree(chromeos_root, dry_run=False): return False cmd0 = 'cd {0} && cros_sdk --delete'.format(chromeos_root) if dry_run: - print cmd0 + print(cmd0) else: if command_executer.GetCommandExecuter().RunCommand( cmd0, @@ -440,7 +442,7 @@ def DeleteChromeOsTree(chromeos_root, dry_run=False): 'cd $CHROMEOSDIRNAME && sudo rm -fr $CHROMEOSBASENAME').format( chromeos_root) if dry_run: - print cmd1 + print(cmd1) return True return command_executer.GetCommandExecuter().RunCommand( diff --git a/utils/misc_test.py b/utils/misc_test.py index 06cf2f92..418068bf 100644 --- a/utils/misc_test.py +++ b/utils/misc_test.py @@ -1,6 +1,8 @@ # Copyright 2012 Google Inc. All Rights Reserved. """Tests for misc.""" +from __future__ import print_function + __author__ = 'asharif@google.com (Ahmad Sharif)' # System modules diff --git a/utils/no_pseudo_terminal_test.py b/utils/no_pseudo_terminal_test.py index 209840f1..fd349e87 100644 --- a/utils/no_pseudo_terminal_test.py +++ b/utils/no_pseudo_terminal_test.py @@ -1,5 +1,7 @@ """Test to ensure we're not touching /dev/ptmx when running commands.""" +from __future__ import print_function + import os import subprocess import tempfile @@ -15,7 +17,7 @@ class NoPsuedoTerminalTest(unittest.TestCase): def _AttachStraceToSelf(self, output_file): """Attaches strace to the current process.""" args = ['strace', '-o', output_file, '-p', str(os.getpid())] - print args + print(args) self._strace_process = subprocess.Popen(args) # Wait until we see some activity. start_time = time.time() diff --git a/utils/perf_diff.py b/utils/perf_diff.py index 46d46a3a..3e390b2c 100755 --- a/utils/perf_diff.py +++ b/utils/perf_diff.py @@ -5,6 +5,8 @@ A detailed description of perf_diff. """ +from __future__ import print_function + __author__ = 'asharif@google.com (Ahmad Sharif)' import optparse @@ -85,7 +87,7 @@ class Tabulator(object): row.append('0') table.append(row) - print tabulator.GetSimpleTable(table) + print(tabulator.GetSimpleTable(table)) class Function(object): diff --git a/utils/tabulator.py b/utils/tabulator.py index 23bbca22..78c84f5d 100644 --- a/utils/tabulator.py +++ b/utils/tabulator.py @@ -60,6 +60,8 @@ table: """ +from __future__ import print_function + import getpass import math import sys @@ -915,7 +917,7 @@ class TableFormatter(object): for cell in row: o += str(cell) + ' ' o += '\n' - print o + print(o) def GetCellTable(self, table_type, headers=True): """Function to return a table of cells. @@ -1203,13 +1205,13 @@ if __name__ == '__main__': 'k9': 'PASS'}]] labels = ['vanilla', 'modified'] t = GetComplexTable(runs, labels, TablePrinter.CONSOLE) - print t + print(t) email = GetComplexTable(runs, labels, TablePrinter.EMAIL) runs = [[{'k1': '1'}, {'k1': '1.1'}, {'k1': '1.2'}], [{'k1': '5'}, {'k1': '5.1'}, {'k1': '5.2'}]] t = GetComplexTable(runs, labels, TablePrinter.CONSOLE) - print t + print(t) simple_table = [ ['binary', 'b1', 'b2', 'b3'], @@ -1219,7 +1221,7 @@ if __name__ == '__main__': ['debug', 100, 140, 60], ] t = GetSimpleTable(simple_table) - print t + print(t) email += GetSimpleTable(simple_table, TablePrinter.HTML) email_to = [getpass.getuser()] email = "<pre style='font-size: 13px'>%s</pre>" % email diff --git a/utils/tabulator_test.py b/utils/tabulator_test.py index b46fcc1f..461c2877 100644 --- a/utils/tabulator_test.py +++ b/utils/tabulator_test.py @@ -1,6 +1,8 @@ # Copyright 2012 Google Inc. All Rights Reserved. """Tests for the tabulator module.""" +from __future__ import print_function + __author__ = 'asharif@google.com (Ahmad Sharif)' # System modules diff --git a/utils/timeline.py b/utils/timeline.py index 8fa73a2d..84c8be85 100644 --- a/utils/timeline.py +++ b/utils/timeline.py @@ -2,6 +2,8 @@ # """Tools for recording and reporting timeline of benchmark_run.""" +from __future__ import print_function + __author__ = 'yunlian@google.com (Yunlian Jiang)' import time diff --git a/utils/timeline_test.py b/utils/timeline_test.py index 17482c2b..866d119c 100644 --- a/utils/timeline_test.py +++ b/utils/timeline_test.py @@ -1,6 +1,8 @@ # Copyright 2012 Google Inc. All Rights Reserved. """Tests for time_line.py.""" +from __future__ import print_function + __author__ = 'yunlian@google.com (Yunlian Jiang)' import time |