當前位置: 首頁>>代碼示例>>Python>>正文


Python compat.get_path_uid方法代碼示例

本文整理匯總了Python中pip._internal.compat.get_path_uid方法的典型用法代碼示例。如果您正苦於以下問題:Python compat.get_path_uid方法的具體用法?Python compat.get_path_uid怎麽用?Python compat.get_path_uid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在pip._internal.compat的用法示例。


在下文中一共展示了compat.get_path_uid方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: check_path_owner

# 需要導入模塊: from pip._internal import compat [as 別名]
# 或者: from pip._internal.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:HaoZhang95,項目名稱:Python24,代碼行數:24,代碼來源:filesystem.py


注:本文中的pip._internal.compat.get_path_uid方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。