Openembedded Bitbake Development
 help / color / mirror / Atom feed
From: "Aníbal Limón" <anibal.limon@linux.intel.com>
To: bitbake-devel@lists.openembedded.org
Cc: "Aníbal Limón" <limon.anibal@gmail.com>
Subject: [PATCHv3 5/6] fetch2/wget.py: checkstatus fix using proxy handler
Date: Tue, 30 Jun 2015 09:39:14 -0500	[thread overview]
Message-ID: <1435675155-3431-6-git-send-email-anibal.limon@linux.intel.com> (raw)
In-Reply-To: <1435675155-3431-1-git-send-email-anibal.limon@linux.intel.com>

From: Aníbal Limón <limon.anibal@gmail.com>

Only use ProxyHandler opener when exists proxies in env.

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
 lib/bb/fetch2/wget.py | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py
index 8cb5f2b..7e90efb 100644
--- a/lib/bb/fetch2/wget.py
+++ b/lib/bb/fetch2/wget.py
@@ -221,17 +221,29 @@ class Wget(FetchMethod):
         def export_proxies(d):
             variables = ['http_proxy', 'HTTP_PROXY', 'https_proxy', 'HTTPS_PROXY',
                             'ftp_proxy', 'FTP_PROXY', 'no_proxy', 'NO_PROXY']
+            exported = False
 
             for v in variables:
-                if not v in os.environ.keys():
-                    os.environ[v] = d.getVar(v, True) or ''
+                if v in os.environ.keys():
+                    exported = True
+                else:
+                    v_proxy = d.getVar(v, True)
+                    if v_proxy is not None:
+                        os.environ[v] = v_proxy
+                        exported = True
+
+            return exported
 
         def head_method(self):
             return "HEAD"
 
-        export_proxies(d)
+        exported_proxies = export_proxies(d)
+        if exported_proxies == True:
+            opener = urllib2.build_opener(urllib2.ProxyHandler, CacheHTTPHandler)
+        else:
+            opener = urllib2.build_opener(CacheHTTPHandler)
+
         urllib2.Request.get_method = head_method
-        opener = urllib2.build_opener(urllib2.ProxyHandler, CacheHTTPHandler)
         urllib2.install_opener(opener)
 
         uri = ud.url.split(";")[0]
-- 
1.9.1



  parent reply	other threads:[~2015-06-30 14:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-30 14:39 [PATCHv3 0/6] Add connection cache support in wget checkstatus Aníbal Limón
2015-06-30 14:39 ` [PATCHv3 1/6] fetch2/__init__.py: Add FetchConnectionCache class Aníbal Limón
2015-06-30 14:39 ` [PATCHv3 2/6] fetch2: Add fetch parameter to checkstatus Aníbal Limón
2015-06-30 14:39 ` [PATCHv3 3/6] fetch2/wget.py: Add support of connection cache in checkstatus Aníbal Limón
2015-06-30 14:39 ` [PATCHv3 4/6] tests/fetch.py: Add FetchCheckStatusTest tests Aníbal Limón
2015-06-30 14:39 ` Aníbal Limón [this message]
2015-06-30 14:39 ` [PATCHv3 6/6] tests/fetch.py: FetchCheckStatusTest add cases for ftp and https Aníbal Limón

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1435675155-3431-6-git-send-email-anibal.limon@linux.intel.com \
    --to=anibal.limon@linux.intel.com \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=limon.anibal@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox