Make run_on_app_dump.py run with python3

Change-Id: I054acf4f25658c66ad4156217009fc48c678374e
diff --git a/tools/archive.py b/tools/archive.py
index 3bf5514..b7ca7c0 100755
--- a/tools/archive.py
+++ b/tools/archive.py
@@ -158,7 +158,7 @@
   is_master = IsMaster(version)
   if is_master:
     # On master we use the git hash to archive with
-    print 'On master, using git hash for archiving'
+    print('On master, using git hash for archiving')
     version = GetGitHash()
 
   destination = GetVersionDestination('gs://', version, is_master)
diff --git a/tools/compiledump.py b/tools/compiledump.py
index 29fed2c..b5f49d1 100755
--- a/tools/compiledump.py
+++ b/tools/compiledump.py
@@ -106,7 +106,7 @@
   return parser
 
 def error(msg):
-  print msg
+  print(msg)
   sys.exit(1)
 
 class Dump(object):
@@ -145,11 +145,11 @@
 
   def proguard_input_map(self):
     if self.if_exists('proguard_input.config'):
-      print "Unimplemented: proguard_input configuration."
+      print("Unimplemented: proguard_input configuration.")
 
   def main_dex_resource(self):
     if self.if_exists('main-dex-list.txt'):
-      print "Unimplemented: main-dex-list."
+      print("Unimplemented: main-dex-list.")
 
   def build_properties_file(self):
     return self.if_exists('build.properties')
@@ -270,7 +270,7 @@
     if not dump.program_jar():
       error("Cannot compile dump with no program classes")
     if not dump.library_jar():
-      print "WARNING: Unexpected lack of library classes in dump"
+      print("WARNING: Unexpected lack of library classes in dump")
     build_properties = determine_build_properties(args, dump)
     version = determine_version(args, dump)
     compiler = determine_compiler(args, dump)
@@ -284,7 +284,7 @@
     cmd = [jdk.GetJavaExecutable()]
     if args.debug_agent:
       if not args.nolib:
-        print "WARNING: Running debugging agent on r8lib is questionable..."
+        print("WARNING: Running debugging agent on r8lib is questionable...")
       cmd.append(
           '-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=*:5005')
     if args.xmx:
@@ -329,18 +329,18 @@
     cmd.extend(otherargs)
     utils.PrintCmd(cmd)
     try:
-      print subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+      print(subprocess.check_output(cmd, stderr=subprocess.STDOUT))
       return 0
-    except subprocess.CalledProcessError, e:
-      print e.output
+    except subprocess.CalledProcessError as e:
+      print(e.output)
       if not args.nolib and version != 'source':
         stacktrace = os.path.join(temp, 'stacktrace')
         open(stacktrace, 'w+').write(e.output)
         local_map = utils.R8LIB_MAP if version == 'master' else None
         hash_or_version = None if version == 'master' else version
-        print "=" * 80
-        print " RETRACED OUTPUT"
-        print "=" * 80
+        print("=" * 80)
+        print(" RETRACED OUTPUT")
+        print("=" * 80)
         retrace.run(
           local_map, hash_or_version, stacktrace, is_hash(version), no_r8lib=False)
       return 1
diff --git a/tools/gradle.py b/tools/gradle.py
index a52e3f3..b6f5187 100755
--- a/tools/gradle.py
+++ b/tools/gradle.py
@@ -47,7 +47,7 @@
 def PrintCmd(s):
   if type(s) is list:
     s = ' '.join(s)
-  print 'Running: %s' % s
+  print('Running: %s' % s)
   # I know this will hit os on windows eventually if we don't do this.
   sys.stdout.flush()
 
diff --git a/tools/jdk.py b/tools/jdk.py
index bc40873..7138fda 100755
--- a/tools/jdk.py
+++ b/tools/jdk.py
@@ -40,7 +40,7 @@
   return os.path.join(jdkHome, 'bin', executable) if jdkHome else executable
 
 def Main():
-  print GetJdkHome()
+  print(GetJdkHome())
 
 if __name__ == '__main__':
   sys.exit(Main())
diff --git a/tools/bisect.py b/tools/r8bisect.py
similarity index 100%
rename from tools/bisect.py
rename to tools/r8bisect.py
diff --git a/tools/run_on_app_dump.py b/tools/run_on_app_dump.py
index 45c1c78..4509656 100755
--- a/tools/run_on_app_dump.py
+++ b/tools/run_on_app_dump.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # Copyright (c) 2020, the R8 project authors. Please see the AUTHORS file
 # for details. All rights reserved. Use of this source code is governed by a
 # BSD-style license that can be found in the LICENSE file.
diff --git a/tools/update_prebuilds_in_android.py b/tools/update_prebuilds_in_android.py
index 22c8863..fe8a3c0 100755
--- a/tools/update_prebuilds_in_android.py
+++ b/tools/update_prebuilds_in_android.py
@@ -53,14 +53,14 @@
     src = os.path.join(root, srcs[i])
     dest = os.path.join(target_root, 'prebuilts', 'r8', dests[i])
     if os.path.exists(dest):
-      print 'Copying: ' + src + ' -> ' + dest
+      print('Copying: ' + src + ' -> ' + dest)
       copyfile(src, dest)
       if maps:
-        print 'Copying: ' + src + '.map -> ' + dest + '.map'
+        print('Copying: ' + src + '.map -> ' + dest + '.map')
         copyfile(src + '.map', dest + '.map')
     else:
-      print ('WARNING: Not copying ' + src + ' -> ' + dest +
-             ', as' + dest + ' does not exist already')
+      print('WARNING: Not copying ' + src + ' -> ' + dest +
+            ', as' + dest + ' does not exist already')
 
 def copy_jar_targets(root, target_root, jar_targets, maps):
   srcs = map((lambda t: t[0] + '.jar'), jar_targets)
@@ -83,7 +83,7 @@
     target,
     is_hash)
   if not quiet:
-    print 'Downloading: ' + url + ' -> ' + download_path
+    print('Downloading: ' + url + ' -> ' + download_path)
   utils.download_file_from_cloud_storage(url, download_path, quiet=quiet)
 
 def main_download(hash, maps, targets, target_root, version):
diff --git a/tools/utils.py b/tools/utils.py
index bed28d8..351a038 100644
--- a/tools/utils.py
+++ b/tools/utils.py
@@ -222,7 +222,7 @@
     # there is an update.
     os.utime(tgz, None)
   else:
-    print 'Ensure cloud dependency:', msg, 'present'
+    print('Ensure cloud dependency:', msg, 'present')
 
 def DownloadFromX20(sha1_file):
   download_script = os.path.join(REPO_ROOT, 'tools', 'download_from_x20.py')
@@ -336,7 +336,7 @@
 def unpack_archive(filename):
   dest_dir = extract_dir(filename)
   if os.path.exists(dest_dir):
-    print 'Deleting existing dir %s' % dest_dir
+    print('Deleting existing dir %s' % dest_dir)
     shutil.rmtree(dest_dir)
   dirname = os.path.dirname(os.path.abspath(filename))
   with tarfile.open(filename, 'r:gz') as tar:
@@ -376,12 +376,12 @@
  def __enter__(self):
    self._old_cwd = os.getcwd()
    if not self._quiet:
-     print 'Enter directory:', self._working_directory
+     print('Enter directory:', self._working_directory)
    os.chdir(self._working_directory)
 
  def __exit__(self, *_):
    if not self._quiet:
-     print 'Enter directory:', self._old_cwd
+     print('Enter directory:', self._old_cwd)
    os.chdir(self._old_cwd)
 
 # Reading Android CTS test_result.xml