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


Python locations.USER_CACHE_DIR属性代码示例

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


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

示例1: do_clear

# 需要导入模块: from pip import locations [as 别名]
# 或者: from pip.locations import USER_CACHE_DIR [as 别名]
def do_clear():
    click.echo(crayons.white(fix_utf8("Clearing caches…"), bold=True))
    try:
        from pip._internal import locations
    except ImportError:  # pip 9.
        from pip import locations

    try:
        vistir.path.rmtree(PIPENV_CACHE_DIR, onerror=vistir.path.handle_remove_readonly)
        # Other processes may be writing into this directory simultaneously.
        vistir.path.rmtree(
            locations.USER_CACHE_DIR,
            ignore_errors=environments.PIPENV_IS_CI,
            onerror=vistir.path.handle_remove_readonly
        )
    except OSError as e:
        # Ignore FileNotFoundError. This is needed for Python 2.7.
        import errno

        if e.errno == errno.ENOENT:
            pass
        raise 
开发者ID:pypa,项目名称:pipenv,代码行数:24,代码来源:core.py

示例2: __init__

# 需要导入模块: from pip import locations [as 别名]
# 或者: from pip.locations import USER_CACHE_DIR [as 别名]
def __init__(self):
        self.statefile_path = os.path.join(USER_CACHE_DIR, "selfcheck.json")

        # Load the existing state
        try:
            with open(self.statefile_path) as statefile:
                self.state = json.load(statefile)[sys.prefix]
        except (IOError, ValueError, KeyError):
            self.state = {} 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:11,代码来源:outdated.py

示例3: pip_version_check

# 需要导入模块: from pip import locations [as 别名]
# 或者: from pip.locations import USER_CACHE_DIR [as 别名]
def pip_version_check(session):
    """Check for an update for pip.

    Limit the frequency of checks to once per week. State is stored either in
    the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix
    of the pip script path.
    """
    import pip  # imported here to prevent circular imports
    pypi_version = None

    try:
        state = load_selfcheck_statefile()

        current_time = datetime.datetime.utcnow()
        # Determine if we need to refresh the state
        if "last_check" in state.state and "pypi_version" in state.state:
            last_check = datetime.datetime.strptime(
                state.state["last_check"],
                SELFCHECK_DATE_FMT
            )
            if total_seconds(current_time - last_check) < 7 * 24 * 60 * 60:
                pypi_version = state.state["pypi_version"]

        # Refresh the version if we need to or just see if we need to warn
        if pypi_version is None:
            resp = session.get(
                PyPI.pip_json_url,
                headers={"Accept": "application/json"},
            )
            resp.raise_for_status()
            pypi_version = [
                v for v in sorted(
                    list(resp.json()["releases"]),
                    key=packaging_version.parse,
                )
                if not packaging_version.parse(v).is_prerelease
            ][-1]

            # save that we've performed a check
            state.save(pypi_version, current_time)

        pip_version = packaging_version.parse(pip.__version__)
        remote_version = packaging_version.parse(pypi_version)

        # Determine if our pypi_version is older
        if (pip_version < remote_version and
                pip_version.base_version != remote_version.base_version):
            logger.warning(
                "You are using pip version %s, however version %s is "
                "available.\nYou should consider upgrading via the "
                "'pip install --upgrade pip' command." % (pip.__version__,
                                                          pypi_version)
            )

    except Exception:
        logger.debug(
            "There was an error checking the latest version of pip",
            exc_info=True,
        ) 
开发者ID:francelabs,项目名称:datafari,代码行数:61,代码来源:outdated.py


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