Commit 426f69b4 authored by joshua.lock@intel.com's avatar joshua.lock@intel.com

Remove the use of urllib for SSL connections

Using urllib for SSL connections when behind a proxy is known to be
broken.

Upstream has fixed this in urllib2 in Python 2.6.3 and newer so
replace uses of urllib for SSL connections with urllib2 methods.

R=maruel@chromium.org
BUG=134165
TEST=gclient sync behind corporate proxy. Submitting this CL with git_cl.


Review URL: https://chromiumcodereview.appspot.com/10825107

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@149742 0039d316-1c4b-4281-b951-d872f2087c98
parent 8cfdb58a
...@@ -16,7 +16,6 @@ import stat ...@@ -16,7 +16,6 @@ import stat
import sys import sys
import textwrap import textwrap
import urlparse import urlparse
import urllib
import urllib2 import urllib2
try: try:
...@@ -756,6 +755,13 @@ def LoadCodereviewSettingsFromFile(fileobj): ...@@ -756,6 +755,13 @@ def LoadCodereviewSettingsFromFile(fileobj):
keyvals['ORIGIN_URL_CONFIG']]) keyvals['ORIGIN_URL_CONFIG']])
def urlretrieve(source, destination):
"""urllib is broken for SSL connections via a proxy therefore we
can't use urllib.urlretrieve()."""
with open(destination, 'w') as f:
f.write(urllib2.urlopen(source).read())
def DownloadHooks(force): def DownloadHooks(force):
"""downloads hooks """downloads hooks
...@@ -773,7 +779,7 @@ def DownloadHooks(force): ...@@ -773,7 +779,7 @@ def DownloadHooks(force):
return return
os.remove(dst) os.remove(dst)
try: try:
urllib.urlretrieve(src, dst) urlretrieve(src, dst)
os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR) os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
except Exception: except Exception:
if os.path.exists(dst): if os.path.exists(dst):
......
...@@ -431,7 +431,7 @@ class TestGitCl(TestCase): ...@@ -431,7 +431,7 @@ class TestGitCl(TestCase):
# others paths, such as /usr/share/locale/.... # others paths, such as /usr/share/locale/....
return True return True
self.mock(git_cl.os.path, 'exists', Exists) self.mock(git_cl.os.path, 'exists', Exists)
self.mock(git_cl.urllib, 'urlretrieve', self._mocked_call) self.mock(git_cl, 'urlretrieve', self._mocked_call)
self.calls = [ self.calls = [
((['git', 'config', 'rietveld.server', 'gerrit.chromium.org'],), ''), ((['git', 'config', 'rietveld.server', 'gerrit.chromium.org'],), ''),
((['git', 'config', '--unset-all', 'rietveld.cc'],), ''), ((['git', 'config', '--unset-all', 'rietveld.cc'],), ''),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment