当前位置: 首页>>代码示例>>Python>>正文


Python download.PipSession方法代码示例

本文整理汇总了Python中pip.download.PipSession方法的典型用法代码示例。如果您正苦于以下问题:Python download.PipSession方法的具体用法?Python download.PipSession怎么用?Python download.PipSession使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pip.download的用法示例。


在下文中一共展示了download.PipSession方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _build_session

# 需要导入模块: from pip import download [as 别名]
# 或者: from pip.download import PipSession [as 别名]
def _build_session(self, options):
        session = PipSession()

        # Handle custom ca-bundles from the user
        if options.cert:
            session.verify = options.cert

        # Handle timeouts
        if options.timeout:
            session.timeout = options.timeout

        # Handle configured proxies
        if options.proxy:
            session.proxies = {
                "http": options.proxy,
                "https": options.proxy,
            }

        # Determine if we can prompt the user for authentication or not
        session.auth.prompting = not options.no_input

        return session 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:24,代码来源:basecommand.py

示例2: downloaded_reqs_from_path

# 需要导入模块: from pip import download [as 别名]
# 或者: from pip.download import PipSession [as 别名]
def downloaded_reqs_from_path(path, argv):
    """Return a list of DownloadedReqs representing the requirements parsed
    out of a given requirements file.

    :arg path: The path to the requirements file
    :arg argv: The commandline args, starting after the subcommand

    """
    finder = package_finder(argv)

    def downloaded_reqs(parsed_reqs):
        """Just avoid repeating this list comp."""
        return [DownloadedReq(req, argv, finder) for req in parsed_reqs]

    try:
        return downloaded_reqs(parse_requirements(
            path, options=EmptyOptions(), finder=finder))
    except TypeError:
        # session is a required kwarg as of pip 6.0 and will raise
        # a TypeError if missing. It needs to be a PipSession instance,
        # but in older versions we can't import it from pip.download
        # (nor do we need it at all) so we only import it in this except block
        from pip.download import PipSession
        return downloaded_reqs(parse_requirements(
            path, options=EmptyOptions(), session=PipSession(), finder=finder)) 
开发者ID:mozilla,项目名称:feedthefox,代码行数:27,代码来源:peep.py

示例3: _build_session

# 需要导入模块: from pip import download [as 别名]
# 或者: from pip.download import PipSession [as 别名]
def _build_session(self, options, retries=None, timeout=None):
        session = PipSession(
            cache=(
                normalize_path(os.path.join(options.cache_dir, "http"))
                if options.cache_dir else None
            ),
            retries=retries if retries is not None else options.retries,
            insecure_hosts=options.trusted_hosts,
        )

        # Handle custom ca-bundles from the user
        if options.cert:
            session.verify = options.cert

        # Handle SSL client certificate
        if options.client_cert:
            session.cert = options.client_cert

        # Handle timeouts
        if options.timeout or timeout:
            session.timeout = (
                timeout if timeout is not None else options.timeout
            )

        # Handle configured proxies
        if options.proxy:
            session.proxies = {
                "http": options.proxy,
                "https": options.proxy,
            }

        # Determine if we can prompt the user for authentication or not
        session.auth.prompting = not options.no_input

        return session 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:37,代码来源:basecommand.py

示例4: _get_content_type

# 需要导入模块: from pip import download [as 别名]
# 或者: from pip.download import PipSession [as 别名]
def _get_content_type(url, session=None):
        """Get the Content-Type of the given url, using a HEAD request"""
        if session is None:
            session = PipSession()

        scheme, netloc, path, query, fragment = urlparse.urlsplit(url)
        if not scheme in ('http', 'https', 'ftp', 'ftps'):
            ## FIXME: some warning or something?
            ## assertion error?
            return ''

        resp = session.head(url, allow_redirects=True)
        resp.raise_for_status()

        return resp.headers.get("Content-Type", "") 
开发者ID:aliyun,项目名称:oss-ftp,代码行数:17,代码来源:index.py

示例5: get_pip

# 需要导入模块: from pip import download [as 别名]
# 或者: from pip.download import PipSession [as 别名]
def get_pip():
    """
    Deprecated, see https://github.com/zsimic/setupmeta/issues/49
    Left around for a while because some callers import this, they will have to adapt to pip 20.1+
    """
    try:
        # pip >= 19.3
        from pip._internal.req import parse_requirements
        from pip._internal.network.session import PipSession

        return parse_requirements, PipSession

    except ImportError:
        pass

    try:
        # pip >= 10.0
        from pip._internal.req import parse_requirements
        from pip._internal.download import PipSession

        return parse_requirements, PipSession

    except ImportError:
        pass

    try:
        # pip < 10.0
        from pip.req import parse_requirements
        from pip.download import PipSession

        return parse_requirements, PipSession

    except ImportError:
        from setupmeta import warn

        warn("Can't find PipSession, won't auto-fill requirements")
        return None, None 
开发者ID:zsimic,项目名称:setupmeta,代码行数:39,代码来源:model.py

示例6: parse_reqs

# 需要导入模块: from pip import download [as 别名]
# 或者: from pip.download import PipSession [as 别名]
def parse_reqs(req_type):
    reqs_file = os.path.join('requirements', '%s.txt' % req_type)
    install_reqs = parse_requirements(reqs_file, session=PipSession())
    reqs = [str(ir.req) for ir in install_reqs]
    return reqs


# Get requirements for all types 
开发者ID:marionleborgne,项目名称:cloudbrain,代码行数:10,代码来源:setup.py


注:本文中的pip.download.PipSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。