From: Zhang Qiang Date: Tue, 25 Feb 2014 06:02:37 +0000 (+0800) Subject: Enhance exception caused by proxy X-Git-Tag: 0.21~19 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8b8f9b226158022a9ab9f87d7ba8e48b26f8326e;p=tools%2Fgbs.git Enhance exception caused by proxy Add http_code 503 as proxy issue, and print system proxy environment if encounter error. Fixes: #1383 Change-Id: Ide3daefa57dc16241891fd4cd205e5444ff9a30b --- diff --git a/gitbuildsys/utils.py b/gitbuildsys/utils.py index c80a209..c3deb8c 100644 --- a/gitbuildsys/utils.py +++ b/gitbuildsys/utils.py @@ -222,7 +222,6 @@ class URLGrabber(object): curl.setopt(pycurl.PROGRESSFUNCTION, progressing) curl.setopt(pycurl.NOPROGRESS, False) original_handler = signal.signal(signal.SIGINT, handler) - try: curl.perform() except pycurl.error, err: @@ -231,9 +230,16 @@ class URLGrabber(object): errcode, errmsg = err.args http_code = curl.getinfo(pycurl.HTTP_CODE) - if errcode == pycurl.E_OPERATION_TIMEOUTED: + if errcode == pycurl.E_OPERATION_TIMEOUTED or http_code == 503: + proxies = ['Detected proxies set in system environment:'] + ENV = os.environ + for key in ['HTTPS_PROXY', 'HTTP_PROXY', 'FTP_PROXY', + 'https_proxy', 'http_proxy', 'ftp_proxy', + 'NO_PROXY', 'no_proxy']: + proxies.append('%s=%s' % (key, ENV.get(key, ''))) raise UrlError("connect timeout to %s, maybe it's caused by " - "proxy settings, please check." % curl.url) + "proxy settings, please check. %s" % (curl.url, + '\n '.join(proxies))) elif errcode == pycurl.E_ABORTED_BY_CALLBACK: raise KeyboardInterrupt(err) elif http_code in (401, 403):