Openembedded Bitbake Development
 help / color / mirror / Atom feed
* [PATCHv4 0/7] Add connection cache support in wget checkstatus
@ 2015-07-08 23:34 Aníbal Limón
  2015-07-08 23:34 ` [PATCHv4 1/7] fetch2/__init__.py: Add FetchConnectionCache class Aníbal Limón
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Aníbal Limón @ 2015-07-08 23:34 UTC (permalink / raw)
  To: bitbake-devel

This v4 fixes issues related to SSL cert validation in Python>=2.7.9, see
last commit.

You can also review the changes at,

http://git.yoctoproject.org/cgit/cgit.cgi/poky-contrib/log/?h=alimon/fetch2-wget-checkstatus

Aníbal Limón (7):
  fetch2/__init__.py: Add FetchConnectionCache class
  fetch2: Add fetch parameter to checkstatus
  fetch2/wget.py: Add support of connection cache in checkstatus.
  tests/fetch.py: Add FetchCheckStatusTest tests.
  fetch2/wget.py: checkstatus fix using proxy handler
  tests/fetch.py: FetchCheckStatusTest add cases for ftp and https.
  fetch2/wget.py: checkstatus disable SSL cert validation.

 lib/bb/fetch2/__init__.py |  59 +++++++++++++---
 lib/bb/fetch2/git.py      |   2 +-
 lib/bb/fetch2/local.py    |   2 +-
 lib/bb/fetch2/wget.py     | 168 ++++++++++++++++++++++++++++++++++++++++++++--
 lib/bb/tests/fetch.py     |  45 +++++++++++++
 5 files changed, 259 insertions(+), 17 deletions(-)

-- 
1.9.1



^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCHv4 1/7] fetch2/__init__.py: Add FetchConnectionCache class
  2015-07-08 23:34 [PATCHv4 0/7] Add connection cache support in wget checkstatus Aníbal Limón
@ 2015-07-08 23:34 ` Aníbal Limón
  2015-07-08 23:34 ` [PATCHv4 2/7] fetch2: Add fetch parameter to checkstatus Aníbal Limón
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Aníbal Limón @ 2015-07-08 23:34 UTC (permalink / raw)
  To: bitbake-devel

FetchConnectionCache class acts as a container for socket connections
useful when implement connection cache into fetcher modules.

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

diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index cc772df..7fd9ec7 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -1711,6 +1711,42 @@ class Fetch(object):
             if ud.lockfile:
                 bb.utils.unlockfile(lf)
 
+class FetchConnectionCache(object):
+    """
+        A class which represents an container for socket connections.
+    """
+    def __init__(self):
+        self.cache = {}
+
+    def get_connection_name(self, host, port):
+        return host + ':' + str(port)
+
+    def add_connection(self, host, port, connection):
+        cn = self.get_connection_name(host, port)
+
+        if cn not in self.cache:
+            self.cache[cn] = connection
+
+    def get_connection(self, host, port):
+        connection = None
+
+        cn = self.get_connection_name(host, port)
+        if cn in self.cache:
+            connection = self.cache[cn]
+
+        return connection
+
+    def remove_connection(self, host, port):
+        cn = self.get_connection_name(host, port)
+        if cn in self.cache:
+            self.cache[cn].close()
+            del self.cache[cn]
+
+    def close_connections(self):
+        for cn in self.cache.keys():
+            self.cache[cn].close()
+            del self.cache[cn]
+
 from . import cvs
 from . import git
 from . import gitsm
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCHv4 2/7] fetch2: Add fetch parameter to checkstatus
  2015-07-08 23:34 [PATCHv4 0/7] Add connection cache support in wget checkstatus Aníbal Limón
  2015-07-08 23:34 ` [PATCHv4 1/7] fetch2/__init__.py: Add FetchConnectionCache class Aníbal Limón
@ 2015-07-08 23:34 ` Aníbal Limón
  2015-07-08 23:34 ` [PATCHv4 3/7] fetch2/wget.py: Add support of connection cache in checkstatus Aníbal Limón
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Aníbal Limón @ 2015-07-08 23:34 UTC (permalink / raw)
  To: bitbake-devel

In order to pass connection cache object to checkstatus function
add fetch parameter.

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

diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index 7fd9ec7..8d0221d 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -907,12 +907,12 @@ def rename_bad_checksum(ud, suffix):
     bb.utils.movefile(ud.localpath, new_localpath)
 
 
-def try_mirror_url(origud, ud, ld, check = False):
+def try_mirror_url(fetch, origud, ud, ld, check = False):
     # Return of None or a value means we're finished
     # False means try another url
     try:
         if check:
-            found = ud.method.checkstatus(ud, ld)
+            found = ud.method.checkstatus(fetch, ud, ld)
             if found:
                 return found
             return False
@@ -975,7 +975,7 @@ def try_mirror_url(origud, ud, ld, check = False):
             pass
         return False
 
-def try_mirrors(d, origud, mirrors, check = False):
+def try_mirrors(fetch, d, origud, mirrors, check = False):
     """
     Try to use a mirrored version of the sources.
     This method will be automatically called before the fetchers go.
@@ -989,7 +989,7 @@ def try_mirrors(d, origud, mirrors, check = False):
     uris, uds = build_mirroruris(origud, mirrors, ld)
 
     for index, uri in enumerate(uris):
-        ret = try_mirror_url(origud, uds[index], ld, check)
+        ret = try_mirror_url(fetch, origud, uds[index], ld, check)
         if ret != False:
             return ret
     return None
@@ -1473,7 +1473,7 @@ class FetchMethod(object):
         """
         return True
 
-    def checkstatus(self, urldata, d):
+    def checkstatus(self, fetch, urldata, d):
         """
         Check the status of a URL
         Assumes localpath was called first
@@ -1577,7 +1577,7 @@ class Fetch(object):
                 elif m.try_premirror(ud, self.d):
                     logger.debug(1, "Trying PREMIRRORS")
                     mirrors = mirror_from_string(self.d.getVar('PREMIRRORS', True))
-                    localpath = try_mirrors(self.d, ud, mirrors, False)
+                    localpath = try_mirrors(self, self.d, ud, mirrors, False)
 
                 if premirroronly:
                     self.d.setVar("BB_NO_NETWORK", "1")
@@ -1616,7 +1616,7 @@ class Fetch(object):
                         m.clean(ud, self.d)
                         logger.debug(1, "Trying MIRRORS")
                         mirrors = mirror_from_string(self.d.getVar('MIRRORS', True))
-                        localpath = try_mirrors (self.d, ud, mirrors)
+                        localpath = try_mirrors(self, self.d, ud, mirrors)
 
                 if not localpath or ((not os.path.exists(localpath)) and localpath.find("*") == -1):
                     if firsterr:
@@ -1648,15 +1648,15 @@ class Fetch(object):
             logger.debug(1, "Testing URL %s", u)
             # First try checking uri, u, from PREMIRRORS
             mirrors = mirror_from_string(self.d.getVar('PREMIRRORS', True))
-            ret = try_mirrors(self.d, ud, mirrors, True)
+            ret = try_mirrors(self, self.d, ud, mirrors, True)
             if not ret:
                 # Next try checking from the original uri, u
                 try:
-                    ret = m.checkstatus(ud, self.d)
+                    ret = m.checkstatus(self, ud, self.d)
                 except:
                     # Finally, try checking uri, u, from MIRRORS
                     mirrors = mirror_from_string(self.d.getVar('MIRRORS', True))
-                    ret = try_mirrors(self.d, ud, mirrors, True)
+                    ret = try_mirrors(self, self.d, ud, mirrors, True)
 
             if not ret:
                 raise FetchError("URL %s doesn't work" % u, u)
diff --git a/lib/bb/fetch2/git.py b/lib/bb/fetch2/git.py
index 2e53882..0abd679 100644
--- a/lib/bb/fetch2/git.py
+++ b/lib/bb/fetch2/git.py
@@ -423,7 +423,7 @@ class Git(FetchMethod):
         else:
             return True, str(rev)
 
-    def checkstatus(self, ud, d):
+    def checkstatus(self, fetch, ud, d):
         try:
             self._lsremote(ud, d, "")
             return True
diff --git a/lib/bb/fetch2/local.py b/lib/bb/fetch2/local.py
index 0785236..2d921f7 100644
--- a/lib/bb/fetch2/local.py
+++ b/lib/bb/fetch2/local.py
@@ -112,7 +112,7 @@ class Local(FetchMethod):
 
         return True
 
-    def checkstatus(self, urldata, d):
+    def checkstatus(self, fetch, urldata, d):
         """
         Check the status of the url
         """
diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py
index 162a6bd..abacbcf 100644
--- a/lib/bb/fetch2/wget.py
+++ b/lib/bb/fetch2/wget.py
@@ -100,7 +100,7 @@ class Wget(FetchMethod):
 
         return True
 
-    def checkstatus(self, ud, d):
+    def checkstatus(self, fetch, ud, d):
 
         uri = ud.url.split(";")[0]
         fetchcmd = self.basecmd + " --spider '%s'" % uri
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCHv4 3/7] fetch2/wget.py: Add support of connection cache in checkstatus.
  2015-07-08 23:34 [PATCHv4 0/7] Add connection cache support in wget checkstatus Aníbal Limón
  2015-07-08 23:34 ` [PATCHv4 1/7] fetch2/__init__.py: Add FetchConnectionCache class Aníbal Limón
  2015-07-08 23:34 ` [PATCHv4 2/7] fetch2: Add fetch parameter to checkstatus Aníbal Limón
@ 2015-07-08 23:34 ` Aníbal Limón
  2015-07-08 23:34 ` [PATCHv4 4/7] tests/fetch.py: Add FetchCheckStatusTest tests Aníbal Limón
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Aníbal Limón @ 2015-07-08 23:34 UTC (permalink / raw)
  To: bitbake-devel

fetch2/__init__.py: Add connection_cache param in Fetch __init__.

In order to pass connection cache object to checkstatus method.

[YOCTO #7796]

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
 lib/bb/fetch2/__init__.py |   3 +-
 lib/bb/fetch2/wget.py     | 140 ++++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 138 insertions(+), 5 deletions(-)

diff --git a/lib/bb/fetch2/__init__.py b/lib/bb/fetch2/__init__.py
index 8d0221d..7b4d130 100644
--- a/lib/bb/fetch2/__init__.py
+++ b/lib/bb/fetch2/__init__.py
@@ -1505,7 +1505,7 @@ class FetchMethod(object):
         return "%s-%s" % (key, d.getVar("PN", True) or "")
 
 class Fetch(object):
-    def __init__(self, urls, d, cache = True, localonly = False):
+    def __init__(self, urls, d, cache = True, localonly = False, connection_cache = None):
         if localonly and cache:
             raise Exception("bb.fetch2.Fetch.__init__: cannot set cache and localonly at same time")
 
@@ -1514,6 +1514,7 @@ class Fetch(object):
         self.urls = urls
         self.d = d
         self.ud = {}
+        self.connection_cache = connection_cache
 
         fn = d.getVar('FILE', True)
         if cache and fn and fn in urldata_cache:
diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py
index abacbcf..8cb5f2b 100644
--- a/lib/bb/fetch2/wget.py
+++ b/lib/bb/fetch2/wget.py
@@ -101,12 +101,144 @@ class Wget(FetchMethod):
         return True
 
     def checkstatus(self, fetch, ud, d):
+        import urllib2, socket, httplib
+        from urllib import addinfourl
+        from bb.fetch2 import FetchConnectionCache
+
+        class HTTPConnectionCache(httplib.HTTPConnection):
+            if fetch.connection_cache:
+                def connect(self):
+                    """Connect to the host and port specified in __init__."""
+
+                    sock = fetch.connection_cache.get_connection(self.host, self.port)
+                    if sock:
+                        self.sock = sock
+                    else:
+                        self.sock = socket.create_connection((self.host, self.port),
+                                    self.timeout, self.source_address)
+                        fetch.connection_cache.add_connection(self.host, self.port, self.sock)
+
+                    if self._tunnel_host:
+                        self._tunnel()
+
+        class CacheHTTPHandler(urllib2.HTTPHandler):
+            def http_open(self, req):
+                return self.do_open(HTTPConnectionCache, req)
+
+            def do_open(self, http_class, req):
+                """Return an addinfourl object for the request, using http_class.
+
+                http_class must implement the HTTPConnection API from httplib.
+                The addinfourl return value is a file-like object.  It also
+                has methods and attributes including:
+                    - info(): return a mimetools.Message object for the headers
+                    - geturl(): return the original request URL
+                    - code: HTTP status code
+                """
+                host = req.get_host()
+                if not host:
+                    raise urlllib2.URLError('no host given')
+
+                h = http_class(host, timeout=req.timeout) # will parse host:port
+                h.set_debuglevel(self._debuglevel)
+
+                headers = dict(req.unredirected_hdrs)
+                headers.update(dict((k, v) for k, v in req.headers.items()
+                            if k not in headers))
+
+                # We want to make an HTTP/1.1 request, but the addinfourl
+                # class isn't prepared to deal with a persistent connection.
+                # It will try to read all remaining data from the socket,
+                # which will block while the server waits for the next request.
+                # So make sure the connection gets closed after the (only)
+                # request.
+
+                # Don't close connection when connection_cache is enabled,
+                if fetch.connection_cache is None: 
+                    headers["Connection"] = "close"
+                else:
+                    headers["Connection"] = "Keep-Alive" # Works for HTTP/1.0
+
+                headers = dict(
+                    (name.title(), val) for name, val in headers.items())
+
+                if req._tunnel_host:
+                    tunnel_headers = {}
+                    proxy_auth_hdr = "Proxy-Authorization"
+                    if proxy_auth_hdr in headers:
+                        tunnel_headers[proxy_auth_hdr] = headers[proxy_auth_hdr]
+                        # Proxy-Authorization should not be sent to origin
+                        # server.
+                        del headers[proxy_auth_hdr]
+                    h.set_tunnel(req._tunnel_host, headers=tunnel_headers)
+
+                try:
+                    h.request(req.get_method(), req.get_selector(), req.data, headers)
+                except socket.error, err: # XXX what error?
+                    # Don't close connection when cache is enabled.
+                    if fetch.connection_cache is None:
+                        h.close()
+                    raise urllib2.URLError(err)
+                else:
+                    try:
+                        r = h.getresponse(buffering=True)
+                    except TypeError: # buffering kw not supported
+                        r = h.getresponse()
+
+                # Pick apart the HTTPResponse object to get the addinfourl
+                # object initialized properly.
+
+                # Wrap the HTTPResponse object in socket's file object adapter
+                # for Windows.  That adapter calls recv(), so delegate recv()
+                # to read().  This weird wrapping allows the returned object to
+                # have readline() and readlines() methods.
+
+                # XXX It might be better to extract the read buffering code
+                # out of socket._fileobject() and into a base class.
+                r.recv = r.read
+
+                # no data, just have to read
+                r.read()
+                class fp_dummy(object):
+                    def read(self):
+                        return ""
+                    def readline(self):
+                        return ""
+                    def close(self):
+                        pass
+
+                resp = addinfourl(fp_dummy(), r.msg, req.get_full_url())
+                resp.code = r.status
+                resp.msg = r.reason
+
+                # Close connection when server request it.
+                if fetch.connection_cache is not None:
+                    if 'Connection' in r.msg and r.msg['Connection'] == 'close':
+                        fetch.connection_cache.remove_connection(h.host, h.port)
+
+                return resp
+
+        def export_proxies(d):
+            variables = ['http_proxy', 'HTTP_PROXY', 'https_proxy', 'HTTPS_PROXY',
+                            'ftp_proxy', 'FTP_PROXY', 'no_proxy', 'NO_PROXY']
+
+            for v in variables:
+                if not v in os.environ.keys():
+                    os.environ[v] = d.getVar(v, True) or ''
+
+        def head_method(self):
+            return "HEAD"
+
+        export_proxies(d)
+        urllib2.Request.get_method = head_method
+        opener = urllib2.build_opener(urllib2.ProxyHandler, CacheHTTPHandler)
+        urllib2.install_opener(opener)
 
         uri = ud.url.split(";")[0]
-        fetchcmd = self.basecmd + " --spider '%s'" % uri
-
-        self._runwget(ud, d, fetchcmd, True)
-
+        try:
+            f = urllib2.urlopen(uri)
+        except:
+            return False
         return True
 
     def _parse_path(self, regex, s):
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCHv4 4/7] tests/fetch.py: Add FetchCheckStatusTest tests.
  2015-07-08 23:34 [PATCHv4 0/7] Add connection cache support in wget checkstatus Aníbal Limón
                   ` (2 preceding siblings ...)
  2015-07-08 23:34 ` [PATCHv4 3/7] fetch2/wget.py: Add support of connection cache in checkstatus Aníbal Limón
@ 2015-07-08 23:34 ` Aníbal Limón
  2015-07-08 23:34 ` [PATCHv4 5/7] fetch2/wget.py: checkstatus fix using proxy handler Aníbal Limón
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Aníbal Limón @ 2015-07-08 23:34 UTC (permalink / raw)
  To: bitbake-devel

Add tests for checkstatus method using http with/without
connection cache.

[YOCTO #7796]

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
 lib/bb/tests/fetch.py | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 561650e..1132af5 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -710,3 +710,42 @@ class FetchMethodTest(FetcherTest):
                 verstring = ud.method.latest_versionstring(ud, self.d)
                 r = bb.utils.vercmp_string(v, verstring)
                 self.assertTrue(r == -1 or r == 0, msg="Package %s, version: %s <= %s" % (k[0], v, verstring))
+
+
+class FetchCheckStatusTest(FetcherTest):
+    test_wget_uris = ["http://www.cups.org/software/1.7.2/cups-1.7.2-source.tar.bz2",
+                      "http://www.cups.org/software/ipptool/ipptool-20130731-linux-ubuntu-i686.tar.gz",
+                      "http://www.cups.org/",
+                      "http://downloads.yoctoproject.org/releases/sato/sato-engine-0.1.tar.gz",
+                      "http://downloads.yoctoproject.org/releases/sato/sato-engine-0.2.tar.gz",
+                      "http://downloads.yoctoproject.org/releases/sato/sato-engine-0.3.tar.gz",
+                      "http://downloads.yoctoproject.org/releases/opkg/opkg-0.1.7.tar.gz",
+                      "http://downloads.yoctoproject.org/releases/opkg/opkg-0.3.0.tar.gz"]
+
+    if os.environ.get("BB_SKIP_NETTESTS") == "yes":
+        print("Unset BB_SKIP_NETTESTS to run network tests")
+    else:
+
+        def test_wget_checkstatus(self):
+            fetch = bb.fetch2.Fetch(self.test_wget_uris, self.d)
+            for u in self.test_wget_uris:
+                ud = fetch.ud[u]
+                m = ud.method
+                ret = m.checkstatus(fetch, ud, self.d)
+                self.assertTrue(ret, msg="URI %s, can't check status" % (u))
+
+
+        def test_wget_checkstatus_connection_cache(self):
+            from bb.fetch2 import FetchConnectionCache
+
+            connection_cache = FetchConnectionCache()
+            fetch = bb.fetch2.Fetch(self.test_wget_uris, self.d,
+                        connection_cache = connection_cache)
+
+            for u in self.test_wget_uris:
+                ud = fetch.ud[u]
+                m = ud.method
+                ret = m.checkstatus(fetch, ud, self.d)
+                self.assertTrue(ret, msg="URI %s, can't check status" % (u))
+
+            connection_cache.close_connections()
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCHv4 5/7] fetch2/wget.py: checkstatus fix using proxy handler
  2015-07-08 23:34 [PATCHv4 0/7] Add connection cache support in wget checkstatus Aníbal Limón
                   ` (3 preceding siblings ...)
  2015-07-08 23:34 ` [PATCHv4 4/7] tests/fetch.py: Add FetchCheckStatusTest tests Aníbal Limón
@ 2015-07-08 23:34 ` Aníbal Limón
  2015-07-08 23:34 ` [PATCHv4 6/7] tests/fetch.py: FetchCheckStatusTest add cases for ftp and https Aníbal Limón
  2015-07-08 23:34 ` [PATCHv4 7/7] fetch2/wget.py: checkstatus disable SSL cert validation Aníbal Limón
  6 siblings, 0 replies; 8+ messages in thread
From: Aníbal Limón @ 2015-07-08 23:34 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Aníbal Limón

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



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCHv4 6/7] tests/fetch.py: FetchCheckStatusTest add cases for ftp and https.
  2015-07-08 23:34 [PATCHv4 0/7] Add connection cache support in wget checkstatus Aníbal Limón
                   ` (4 preceding siblings ...)
  2015-07-08 23:34 ` [PATCHv4 5/7] fetch2/wget.py: checkstatus fix using proxy handler Aníbal Limón
@ 2015-07-08 23:34 ` Aníbal Limón
  2015-07-08 23:34 ` [PATCHv4 7/7] fetch2/wget.py: checkstatus disable SSL cert validation Aníbal Limón
  6 siblings, 0 replies; 8+ messages in thread
From: Aníbal Limón @ 2015-07-08 23:34 UTC (permalink / raw)
  To: bitbake-devel; +Cc: Aníbal Limón

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

Signed-off-by: Aníbal Limón <anibal.limon@linux.intel.com>
---
 lib/bb/tests/fetch.py | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/bb/tests/fetch.py b/lib/bb/tests/fetch.py
index 1132af5..13555bd 100644
--- a/lib/bb/tests/fetch.py
+++ b/lib/bb/tests/fetch.py
@@ -719,8 +719,14 @@ class FetchCheckStatusTest(FetcherTest):
                       "http://downloads.yoctoproject.org/releases/sato/sato-engine-0.1.tar.gz",
                       "http://downloads.yoctoproject.org/releases/sato/sato-engine-0.2.tar.gz",
                       "http://downloads.yoctoproject.org/releases/sato/sato-engine-0.3.tar.gz",
+                      "https://yoctoproject.org/",
+                      "https://yoctoproject.org/documentation",
                       "http://downloads.yoctoproject.org/releases/opkg/opkg-0.1.7.tar.gz",
-                      "http://downloads.yoctoproject.org/releases/opkg/opkg-0.3.0.tar.gz"]
+                      "http://downloads.yoctoproject.org/releases/opkg/opkg-0.3.0.tar.gz",
+                      "ftp://ftp.gnu.org/gnu/autoconf/autoconf-2.60.tar.gz",
+                      "ftp://ftp.gnu.org/gnu/chess/gnuchess-5.08.tar.gz",
+                      "ftp://ftp.gnu.org/gnu/gmp/gmp-4.0.tar.gz",
+                      ]
 
     if os.environ.get("BB_SKIP_NETTESTS") == "yes":
         print("Unset BB_SKIP_NETTESTS to run network tests")
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCHv4 7/7] fetch2/wget.py: checkstatus disable SSL cert validation.
  2015-07-08 23:34 [PATCHv4 0/7] Add connection cache support in wget checkstatus Aníbal Limón
                   ` (5 preceding siblings ...)
  2015-07-08 23:34 ` [PATCHv4 6/7] tests/fetch.py: FetchCheckStatusTest add cases for ftp and https Aníbal Limón
@ 2015-07-08 23:34 ` Aníbal Limón
  6 siblings, 0 replies; 8+ messages in thread
From: Aníbal Limón @ 2015-07-08 23:34 UTC (permalink / raw)
  To: bitbake-devel

Since Python 2.7.9 ssl cert validation is enabled by default
see PEP-0476, this causes verification errors on some https
servers so disable by default.

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

diff --git a/lib/bb/fetch2/wget.py b/lib/bb/fetch2/wget.py
index 7e90efb..545f02d 100644
--- a/lib/bb/fetch2/wget.py
+++ b/lib/bb/fetch2/wget.py
@@ -238,7 +238,22 @@ class Wget(FetchMethod):
             return "HEAD"
 
         exported_proxies = export_proxies(d)
-        if exported_proxies == True:
+
+        # XXX: Since Python 2.7.9 ssl cert validation is enabled by default
+        # see PEP-0476, this causes verification errors on some https servers
+        # so disable by default.
+        import ssl
+        ssl_context = None
+        if hasattr(ssl, '_create_unverified_context'):
+            ssl_context = ssl._create_unverified_context()
+
+        if exported_proxies == True and ssl_context is not None:
+            opener = urllib2.build_opener(urllib2.ProxyHandler, CacheHTTPHandler,
+                    urllib2.HTTPSHandler(context=ssl_context))
+        elif exported_proxies == False and ssl_context is not None:
+            opener = urllib2.build_opener(CacheHTTPHandler,
+                    urllib2.HTTPSHandler(context=ssl_context))
+        elif exported_proxies == True and ssl_context is None:
             opener = urllib2.build_opener(urllib2.ProxyHandler, CacheHTTPHandler)
         else:
             opener = urllib2.build_opener(CacheHTTPHandler)
@@ -247,8 +262,9 @@ class Wget(FetchMethod):
         urllib2.install_opener(opener)
 
         uri = ud.url.split(";")[0]
+
         try:
-            f = urllib2.urlopen(uri)
+            urllib2.urlopen(uri)
         except:
             return False
         return True
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2015-07-08 23:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-08 23:34 [PATCHv4 0/7] Add connection cache support in wget checkstatus Aníbal Limón
2015-07-08 23:34 ` [PATCHv4 1/7] fetch2/__init__.py: Add FetchConnectionCache class Aníbal Limón
2015-07-08 23:34 ` [PATCHv4 2/7] fetch2: Add fetch parameter to checkstatus Aníbal Limón
2015-07-08 23:34 ` [PATCHv4 3/7] fetch2/wget.py: Add support of connection cache in checkstatus Aníbal Limón
2015-07-08 23:34 ` [PATCHv4 4/7] tests/fetch.py: Add FetchCheckStatusTest tests Aníbal Limón
2015-07-08 23:34 ` [PATCHv4 5/7] fetch2/wget.py: checkstatus fix using proxy handler Aníbal Limón
2015-07-08 23:34 ` [PATCHv4 6/7] tests/fetch.py: FetchCheckStatusTest add cases for ftp and https Aníbal Limón
2015-07-08 23:34 ` [PATCHv4 7/7] fetch2/wget.py: checkstatus disable SSL cert validation Aníbal Limón

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox