Mercurial > repos > bcclaywell > argo_navis
comparison venv/lib/python2.7/site-packages/pip/utils/filesystem.py @ 0:d67268158946 draft
planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author | bcclaywell |
---|---|
date | Mon, 12 Oct 2015 17:43:33 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:d67268158946 |
---|---|
1 import os | |
2 import os.path | |
3 | |
4 from pip.compat import get_path_uid | |
5 | |
6 | |
7 def check_path_owner(path): | |
8 # If we don't have a way to check the effective uid of this process, then | |
9 # we'll just assume that we own the directory. | |
10 if not hasattr(os, "geteuid"): | |
11 return True | |
12 | |
13 previous = None | |
14 while path != previous: | |
15 if os.path.lexists(path): | |
16 # Check if path is writable by current user. | |
17 if os.geteuid() == 0: | |
18 # Special handling for root user in order to handle properly | |
19 # cases where users use sudo without -H flag. | |
20 try: | |
21 path_uid = get_path_uid(path) | |
22 except OSError: | |
23 return False | |
24 return path_uid == 0 | |
25 else: | |
26 return os.access(path, os.W_OK) | |
27 else: | |
28 previous, path = path, os.path.dirname(path) |