Drop py2 support in gs-related files
python3 is the only supported version of python in depot_tools.
Bug: 1475402
Change-Id: I71db631b5556525dd4932134679c70cacd205a90
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4824616
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
Commit-Queue: Gavin Mak <gavinmak@google.com>
diff --git a/gsutil.py b/gsutil.py
index 85b72bf..c8eb0ff 100755
--- a/gsutil.py
+++ b/gsutil.py
@@ -18,11 +18,7 @@
import sys
import tempfile
import time
-
-try:
- import urllib2 as urllib
-except ImportError: # For Py3 compatibility
- import urllib.request as urllib
+import urllib.request
import zipfile
@@ -65,7 +61,7 @@
local_md5 = md5_calc.hexdigest()
metadata_url = '%s%s' % (API_URL, filename)
- metadata = json.load(urllib.urlopen(metadata_url))
+ metadata = json.load(urllib.request.urlopen(metadata_url))
remote_md5 = base64.b64decode(metadata['md5Hash']).decode('utf-8')
if local_md5 == remote_md5:
@@ -74,7 +70,7 @@
# Do the download.
url = '%s%s' % (GSUTIL_URL, filename)
- u = urllib.urlopen(url)
+ u = urllib.request.urlopen(url)
with open(target_filename, 'wb') as f:
while True:
buf = u.read(4096)