示例#1
0
文件: p5s.py 项目: alhazred/v9os-pkg5
        def transform_uris(urls, prefix):
                res = []

                for u in urls:
                        m = copy.copy(u)
                        if m.scheme == "http":
                                res.append(m.uri)
                        elif m.scheme == "https":
                                # The system depot handles connecting to the
                                # proxied https repositories, so the client
                                # should communicate over http to prevent it
                                # from doing tunneling.
                                m.change_scheme("http")
                                res.append(m.uri)
                        elif m.scheme == "file":
                                # The system depot provides direct access to
                                # file repositories.  The token <sysrepo> will
                                # be replaced in the client with the url it uses
                                # to communicate with the system repository.
                                res.append("http://{0}/{1}/{2}".format(
                                    publisher.SYSREPO_PROXY, prefix,
                                    digest.DEFAULT_HASH_FUNC(
                                    m.uri.rstrip("/")).hexdigest()
                                    ))
                        else:
                                assert False, "{0} is an unknown scheme.".format(
                                    u.scheme)

                # Remove duplicates, since the system-repository can only
                # provide one path to a given origin. This can happen if the
                # image has eg. two origins/mirrors configured for a publisher,
                # with one using http and the other using https, but both using
                # the same netloc and path.
                # We want to preserve origin/mirror order, so simply casting
                # into a set is not appropriate.
                values = set()
                res_unique = []
                for item in res:
                        if item not in values:
                                values.add(item)
                                res_unique.append(item)
                return res_unique
示例#2
0
def _uri_hash(uri):
    """Returns a string hash of the given URI"""
    # Unicode-objects must be encoded before hashing
    return digest.DEFAULT_HASH_FUNC(misc.force_bytes(uri)).hexdigest()
示例#3
0
def _uri_hash(uri):
        """Returns a string hash of the given URI"""
        return digest.DEFAULT_HASH_FUNC(uri).hexdigest()