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


Python filesystem.check_path_owner方法代码示例

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


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

示例1: __init__

# 需要导入模块: from pip.utils import filesystem [as 别名]
# 或者: from pip.utils.filesystem import check_path_owner [as 别名]
def __init__(self, *args, **kwargs):
        super(SafeFileCache, self).__init__(*args, **kwargs)

        # Check to ensure that the directory containing our cache directory
        # is owned by the user current executing pip. If it does not exist
        # we will check the parent directory until we find one that does exist.
        # If it is not owned by the user executing pip then we will disable
        # the cache and log a warning.
        if not check_path_owner(self.directory):
            logger.warning(
                "The directory '%s' or its parent directory is not owned by "
                "the current user and the cache has been disabled. Please "
                "check the permissions and owner of that directory. If "
                "executing pip with sudo, you may want sudo's -H flag.",
                self.directory,
            )

            # Set our directory to None to disable the Cache
            self.directory = None 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:21,代码来源:download.py

示例2: save

# 需要导入模块: from pip.utils import filesystem [as 别名]
# 或者: from pip.utils.filesystem import check_path_owner [as 别名]
def save(self, pypi_version, current_time):
        # Check to make sure that we own the directory
        if not check_path_owner(os.path.dirname(self.statefile_path)):
            return

        # Now that we've ensured the directory is owned by this user, we'll go
        # ahead and make sure that all our directories are created.
        ensure_dir(os.path.dirname(self.statefile_path))

        # Attempt to write out our version check file
        with lockfile.LockFile(self.statefile_path):
            if os.path.exists(self.statefile_path):
                with open(self.statefile_path) as statefile:
                    state = json.load(statefile)
            else:
                state = {}

            state[sys.prefix] = {
                "last_check": current_time.strftime(SELFCHECK_DATE_FMT),
                "pypi_version": pypi_version,
            }

            with open(self.statefile_path, "w") as statefile:
                json.dump(state, statefile, sort_keys=True,
                          separators=(",", ":")) 
开发者ID:Frank-qlu,项目名称:recruit,代码行数:27,代码来源:outdated.py


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