本文整理匯總了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)