(self, *args, **kwargs)
return (hdr, buf)
Encapsulates the call to GetURL.get() so that authentication
        for v1 and v2 repositories can be treated differently.
        Example:
             _get_url(url, ctimeout=5, timeout=5, header=[]):
Encapsulates the call to GetURL.get() so that authentication
        for v1 and v2 repositories can be treated differently.
        Example:
             _get_url(url, ctimeout=5, timeout=5, header=[]):
Encapsulates the call to GetURL . get () so that authentication for v1 and v2 repositories can be treated differently . Example : _get_url ( url ctimeout = 5 timeout = 5 header = [] ) :
def _get_url(self, *args, **kwargs):
        """Encapsulates the call to GetURL.get() so that authentication
        for v1 and v2 repositories can be treated differently.
        Example:
             _get_url(url, ctimeout=5, timeout=5, header=[]):
        """
        url = str(args[0])
        if "RETRY" not in kwargs:
            kwargs["RETRY"] = 3
        if "FOLLOW" not in kwargs:
            kwargs["FOLLOW"] = 3
        kwargs["RETRY"] -= 1
        (hdr, buf) = self.curl.get(*args, **kwargs)
        Msg().out("Info: header: %s" % (hdr.data), l=Msg.DBG)
        Msg().out("Info: buffer: %s" % (buf.getvalue()), l=Msg.DBG)
        status_code = self.curl.get_status_code(hdr.data["X-ND-HTTPSTATUS"])
        if status_code == 200:
            return (hdr, buf)
        if not kwargs["RETRY"]:
            hdr.data["X-ND-CURLSTATUS"] = 13  # Permission denied
            return (hdr, buf)
        auth_kwargs = kwargs.copy()
        if "location" not in hdr.data:
            kwargs["FOLLOW"] = 3
        if "location" in hdr.data and hdr.data['location']:
            if not kwargs["FOLLOW"]:
                hdr.data["X-ND-CURLSTATUS"] = 13
                return (hdr, buf)
            kwargs["FOLLOW"] -= 1
            args = [hdr.data['location']]
            if "header" in auth_kwargs:
                del auth_kwargs["header"]
        elif status_code == 401:
            if "www-authenticate" in hdr.data:
                www_authenticate = hdr.data["www-authenticate"]
                if not "realm" in www_authenticate:
                    return (hdr, buf)
                if 'error="insufficient_scope"' in www_authenticate:
                    return (hdr, buf)
                auth_header = ""
                if "/v2/" in url:
                    auth_header = self._get_v2_auth(www_authenticate,
                                                    kwargs["RETRY"])
                if "/v1/" in url:
                    auth_header = self._get_v1_auth(www_authenticate)
                auth_kwargs.update({"header": [auth_header]})
        (hdr, buf) = self._get_url(*args, **auth_kwargs)
        return (hdr, buf)
def _get_url ( self , * args , * * kwargs ) : url = str ( args [ 0 ] ) if "RETRY" not in kwargs : kwargs [ "RETRY" ] = 3 if "FOLLOW" not in kwargs : kwargs [ "FOLLOW" ] = 3 kwargs [ "RETRY" ] -= 1 ( hdr , buf ) = self . curl . get ( * args , * * kwargs ) Msg ( ) . out ( "Info: header: %s" % ( hdr . data ) , l = Msg . DBG ) Msg ( ) . out ( "Info: buffer: %s" % ( buf . getvalue ( ) ) , l = Msg . DBG ) status_code = self . curl . get_status_code ( hdr . data [ "X-ND-HTTPSTATUS" ] ) if status_code == 200 : return ( hdr , buf ) if not kwargs [ "RETRY" ] : hdr . data [ "X-ND-CURLSTATUS" ] = 13 # Permission denied return ( hdr , buf ) auth_kwargs = kwargs . copy ( ) if "location" not in hdr . data : kwargs [ "FOLLOW" ] = 3 if "location" in hdr . data and hdr . data [ 'location' ] : if not kwargs [ "FOLLOW" ] : hdr . data [ "X-ND-CURLSTATUS" ] = 13 return ( hdr , buf ) kwargs [ "FOLLOW" ] -= 1 args = [ hdr . data [ 'location' ] ] if "header" in auth_kwargs : del auth_kwargs [ "header" ] elif status_code == 401 : if "www-authenticate" in hdr . data : www_authenticate = hdr . data [ "www-authenticate" ] if not "realm" in www_authenticate : return ( hdr , buf ) if 'error="insufficient_scope"' in www_authenticate : return ( hdr , buf ) auth_header = "" if "/v2/" in url : auth_header = self . _get_v2_auth ( www_authenticate , kwargs [ "RETRY" ] ) if "/v1/" in url : auth_header = self . _get_v1_auth ( www_authenticate ) auth_kwargs . update ( { "header" : [ auth_header ] } ) ( hdr , buf ) = self . _get_url ( * args , * * auth_kwargs ) return ( hdr , buf )