Switch DEPS actions on bots to Python 3.

In doing so, I think this fixes a bug on Windows where extract.py was
digesting the archive in text mode. (Doesn't particularly matter, though
by using the correct digest, we will end up re-extracting the files
once.)

Change-Id: Ia7effe5f9c228c1a702cba8e6380975b59261808
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/50166
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/util/bot/DEPS b/util/bot/DEPS
index bad720f..46f484f 100644
--- a/util/bot/DEPS
+++ b/util/bot/DEPS
@@ -127,7 +127,7 @@
     'name': 'cmake_win32_extract',
     'pattern': '.',
     'condition': 'host_os == "win"',
-    'action': [ 'python',
+    'action': [ 'python3',
                 'boringssl/util/bot/extract.py',
                 'boringssl/util/bot/cmake-win32.zip',
                 'boringssl/util/bot/cmake-win32/',
@@ -149,7 +149,7 @@
     'name': 'perl_win32_extract',
     'pattern': '.',
     'condition': 'host_os == "win"',
-    'action': [ 'python',
+    'action': [ 'python3',
                 'boringssl/util/bot/extract.py',
                 '--no-prefix',
                 'boringssl/util/bot/perl-win32.zip',
@@ -172,7 +172,7 @@
     'name': 'win_toolchain',
     'pattern': '.',
     'condition': 'host_os == "win"',
-    'action': [ 'python',
+    'action': [ 'python3',
                 'boringssl/util/bot/vs_toolchain.py',
                 'update',
                 Var('vs_version'),
@@ -182,7 +182,7 @@
     'name': 'clang',
     'pattern': '.',
     'condition': 'checkout_clang',
-    'action': [ 'python',
+    'action': [ 'python3',
                 'boringssl/util/bot/update_clang.py',
     ],
   },
@@ -200,7 +200,7 @@
     'name': 'sde_linux64_extract',
     'pattern': '.',
     'condition': 'checkout_sde and host_os == "linux"',
-    'action': [ 'python',
+    'action': [ 'python3',
                 'boringssl/util/bot/extract.py',
                 'boringssl/util/bot/sde-linux64.tar.bz2',
                 'boringssl/util/bot/sde-linux64/',
@@ -220,7 +220,7 @@
     'name': 'sde_win32_extract',
     'pattern': '.',
     'condition': 'checkout_sde and host_os == "win"',
-    'action': [ 'python',
+    'action': [ 'python3',
                 'boringssl/util/bot/extract.py',
                 'boringssl/util/bot/sde-win32.tar.bz2',
                 'boringssl/util/bot/sde-win32/',
diff --git a/util/bot/extract.py b/util/bot/extract.py
index 4680cfe..9b1b88a 100644
--- a/util/bot/extract.py
+++ b/util/bot/extract.py
@@ -96,7 +96,7 @@
     # Skip archives that weren't downloaded.
     return 0
 
-  with open(archive) as f:
+  with open(archive, 'rb') as f:
     sha256 = hashlib.sha256()
     while True:
       chunk = f.read(1024 * 1024)
@@ -109,7 +109,7 @@
   if os.path.exists(stamp_path):
     with open(stamp_path) as f:
       if f.read().strip() == digest:
-        print "Already up-to-date."
+        print("Already up-to-date.")
         return 0
 
   if archive.endswith('.zip'):
@@ -123,10 +123,10 @@
 
   try:
     if os.path.exists(output):
-      print "Removing %s" % (output, )
+      print("Removing %s" % (output, ))
       shutil.rmtree(output)
 
-    print "Extracting %s to %s" % (archive, output)
+    print("Extracting %s to %s" % (archive, output))
     prefix = None
     num_extracted = 0
     for entry in entries:
@@ -166,14 +166,14 @@
       # Print every 100 files, so bots do not time out on large archives.
       num_extracted += 1
       if num_extracted % 100 == 0:
-        print "Extracted %d files..." % (num_extracted,)
+        print("Extracted %d files..." % (num_extracted,))
   finally:
     entries.close()
 
   with open(stamp_path, 'w') as f:
     f.write(digest)
 
-  print "Done. Extracted %d files." % (num_extracted,)
+  print("Done. Extracted %d files." % (num_extracted,))
   return 0