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
diff --git a/git_cl.py b/git_cl.py
index 143ad28..9716ef1 100755
--- a/git_cl.py
+++ b/git_cl.py
@@ -16,7 +16,6 @@
 import sys
 import textwrap
 import urlparse
-import urllib
 import urllib2
 
 try:
@@ -756,6 +755,13 @@
             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):
   """downloads hooks
 
@@ -773,7 +779,7 @@
         return
       os.remove(dst)
     try:
-      urllib.urlretrieve(src, dst)
+      urlretrieve(src, dst)
       os.chmod(dst, stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR)
     except Exception:
       if os.path.exists(dst):