urllib doesn't work with https under proxy
When access CSAR file which is URL and the protocol is https by proxy, it will be error and the information is below: toscaparser.common.exception.URLException: Failed to reach server "https://raw.githubusercontent.com/openstack/tosca- parser/master/ toscaparser/tests/data/custom_types/wordpress.yaml". Reason is: Tunnel connection failed: 503 Service Unavailable. The reason of the error is urllib doesn't support https proxy and the solution is using urllib2 instead of urllib. closes-Bug: #1606015 Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn> Change-Id: I06cb2a33bfd02da7a5372c8162fdccad171e0edd
This commit is contained in:
parent
ca9f8a0ee6
commit
84bef41070
|
@ -18,10 +18,10 @@ from toscaparser.utils.gettextutils import _
|
|||
|
||||
try:
|
||||
# Python 3.x
|
||||
import urllib.request as urllib
|
||||
import urllib.request as urllib2
|
||||
except ImportError:
|
||||
# Python 2.x
|
||||
import urllib
|
||||
import urllib2
|
||||
|
||||
|
||||
class UrlUtils(object):
|
||||
|
@ -62,4 +62,4 @@ class UrlUtils(object):
|
|||
Returns true if the get call returns a 200 response code.
|
||||
Otherwise, returns false.
|
||||
"""
|
||||
return urllib.urlopen(url).getcode() == 200
|
||||
return urllib2.urlopen(url).getcode() == 200
|
||||
|
|
Loading…
Reference in New Issue