1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Merge pull request #1745 from RobberPhex/develop

delete read-only file in Windows
This commit is contained in:
Paul Moore 2014-04-26 17:16:15 +01:00
commit 7aaedd57ff

View file

@ -11,8 +11,7 @@ import zipfile
from pip.exceptions import InstallationError, BadCommand
from pip.backwardcompat import(
WindowsError, string_types, raw_input, console_to_str,
PermissionError, stdlib_pkgs
string_types, raw_input, console_to_str, stdlib_pkgs
)
from pip.locations import (
site_packages, user_site, running_under_virtualenv, virtualenv_no_global,
@ -52,19 +51,15 @@ def rmtree_errorhandler(func, path, exc_info):
"""On Windows, the files in .svn are read-only, so when rmtree() tries to
remove them, an exception is thrown. We catch that here, remove the
read-only attribute, and hopefully continue without problems."""
exctype, value = exc_info[:2]
if not ((exctype is WindowsError and value.args[0] == 5) or # others
(exctype is OSError and value.args[0] == 13) or # python2.4
(exctype is PermissionError and value.args[3] == 5) # python3.3
):
# if file type currently read only
if os.stat(path).st_mode & stat.S_IREAD:
# convert to read/write
os.chmod(path, stat.S_IWRITE)
# use the original function to repeat the operation
func(path)
return
else:
raise
# file type should currently be read only
if ((os.stat(path).st_mode & stat.S_IREAD) != stat.S_IREAD):
raise
# convert to read/write
os.chmod(path, stat.S_IWRITE)
# use the original function to repeat the operation
func(path)
def display_path(path):