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


Python compat.get_path_uid方法代码示例

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


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

示例1: check_path_owner

# 需要导入模块: from pip._internal.utils import compat [as 别名]
# 或者: from pip._internal.utils.compat import get_path_uid [as 别名]
def check_path_owner(path):
    # type: (str) -> bool
    # If we don't have a way to check the effective uid of this process, then
    # we'll just assume that we own the directory.
    if not hasattr(os, "geteuid"):
        return True

    previous = None
    while path != previous:
        if os.path.lexists(path):
            # Check if path is writable by current user.
            if os.geteuid() == 0:
                # Special handling for root user in order to handle properly
                # cases where users use sudo without -H flag.
                try:
                    path_uid = get_path_uid(path)
                except OSError:
                    return False
                return path_uid == 0
            else:
                return os.access(path, os.W_OK)
        else:
            previous, path = path, os.path.dirname(path)
    return False  # assume we don't own the path 
开发者ID:PacktPublishing,项目名称:Mastering-Elasticsearch-7.0,代码行数:26,代码来源:filesystem.py

示例2: check_path_owner

# 需要导入模块: from pip._internal.utils import compat [as 别名]
# 或者: from pip._internal.utils.compat import get_path_uid [as 别名]
def check_path_owner(path):
    # If we don't have a way to check the effective uid of this process, then
    # we'll just assume that we own the directory.
    if not hasattr(os, "geteuid"):
        return True

    previous = None
    while path != previous:
        if os.path.lexists(path):
            # Check if path is writable by current user.
            if os.geteuid() == 0:
                # Special handling for root user in order to handle properly
                # cases where users use sudo without -H flag.
                try:
                    path_uid = get_path_uid(path)
                except OSError:
                    return False
                return path_uid == 0
            else:
                return os.access(path, os.W_OK)
        else:
            previous, path = path, os.path.dirname(path) 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:24,代码来源:filesystem.py

示例3: check_path_owner

# 需要导入模块: from pip._internal.utils import compat [as 别名]
# 或者: from pip._internal.utils.compat import get_path_uid [as 别名]
def check_path_owner(path):
    # type: (str) -> bool
    # If we don't have a way to check the effective uid of this process, then
    # we'll just assume that we own the directory.
    if sys.platform == "win32" or not hasattr(os, "geteuid"):
        return True

    assert os.path.isabs(path)

    previous = None
    while path != previous:
        if os.path.lexists(path):
            # Check if path is writable by current user.
            if os.geteuid() == 0:
                # Special handling for root user in order to handle properly
                # cases where users use sudo without -H flag.
                try:
                    path_uid = get_path_uid(path)
                except OSError:
                    return False
                return path_uid == 0
            else:
                return os.access(path, os.W_OK)
        else:
            previous, path = path, os.path.dirname(path)
    return False  # assume we don't own the path 
开发者ID:ali5h,项目名称:rules_pip,代码行数:28,代码来源:filesystem.py


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