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>
changes/16/4824616/2
Gavin Mak 2 years ago committed by LUCI CQ
parent b9d7c85582
commit 1c1cc06a0d

@ -9,11 +9,7 @@ from __future__ import print_function
import hashlib
import optparse
import os
try:
import Queue as queue
except ImportError: # For Py3 compatibility
import queue
import queue
import re
import shutil
@ -44,11 +40,6 @@ PLATFORM_MAPPING = {
'aix7': 'aix',
}
if sys.version_info.major == 2:
# pylint: disable=redefined-builtin
class FileNotFoundError(IOError):
pass
class InvalidFileError(IOError):
pass

@ -18,11 +18,7 @@ import subprocess
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 @@ def download_gsutil(version, target_dir):
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 @@ def download_gsutil(version, target_dir):
# 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)

@ -10,11 +10,7 @@ from __future__ import print_function
import optparse
import os
try:
import Queue as queue
except ImportError: # For Py3 compatibility
import queue
import queue
import shutil
import sys

@ -19,11 +19,7 @@ import sys
import tempfile
import unittest
import zipfile
try:
import urllib2 as urllib
except ImportError: # For Py3 compatibility
import urllib.request as urllib
import urllib.request
# Add depot_tools to path
THIS_DIR = os.path.dirname(os.path.abspath(__file__))
@ -60,15 +56,15 @@ class GsutilUnitTests(unittest.TestCase):
def setUp(self):
self.fake = FakeCall()
self.tempdir = tempfile.mkdtemp()
self.old_urlopen = getattr(urllib, 'urlopen')
self.old_urlopen = getattr(urllib.request, 'urlopen')
self.old_call = getattr(subprocess, 'call')
setattr(urllib, 'urlopen', self.fake)
setattr(urllib.request, 'urlopen', self.fake)
setattr(subprocess, 'call', self.fake)
def tearDown(self):
self.assertEqual(self.fake.expectations, [])
shutil.rmtree(self.tempdir)
setattr(urllib, 'urlopen', self.old_urlopen)
setattr(urllib.request, 'urlopen', self.old_urlopen)
setattr(subprocess, 'call', self.old_call)
def test_download_gsutil(self):

@ -8,11 +8,7 @@
import optparse
import os
import posixpath
try:
import Queue as queue
except ImportError: # For Py3 compatibility
import queue
import queue
import shutil
import sys

@ -10,11 +10,7 @@ from __future__ import print_function
import hashlib
import optparse
import os
try:
import Queue as queue
except ImportError: # For Py3 compatibility
import queue
import queue
import re
import stat

Loading…
Cancel
Save