Removed rmtree_errorhandler.
The stated reason for its introduction in d18d37ce
no longer applies
since Django's code repository was switched from Subversion to git.
Furthermore it never had any effect because shutil.rmtree ignores its
onerror argument when ignore_errors is True.
The reason for its use in template management commands is unclear.
This commit is contained in:
parent
b2f331dc68
commit
c688460df6
|
@ -15,7 +15,6 @@ from django.core.management.base import BaseCommand, CommandError
|
|||
from django.core.management.utils import handle_extensions
|
||||
from django.template import Context, Template
|
||||
from django.utils import archive
|
||||
from django.utils._os import rmtree_errorhandler
|
||||
from django.utils.six.moves.urllib.request import urlretrieve
|
||||
from django.utils.version import get_docs_version
|
||||
|
||||
|
@ -172,8 +171,7 @@ class TemplateCommand(BaseCommand):
|
|||
if path.isfile(path_to_remove):
|
||||
os.remove(path_to_remove)
|
||||
else:
|
||||
shutil.rmtree(path_to_remove,
|
||||
onerror=rmtree_errorhandler)
|
||||
shutil.rmtree(path_to_remove)
|
||||
|
||||
def handle_template(self, template, subdir):
|
||||
"""
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
import stat
|
||||
import sys
|
||||
import tempfile
|
||||
from os.path import abspath, dirname, isabs, join, normcase, normpath, sep
|
||||
|
@ -10,12 +9,6 @@ from django.core.exceptions import SuspiciousFileOperation
|
|||
from django.utils import six
|
||||
from django.utils.encoding import force_text
|
||||
|
||||
try:
|
||||
WindowsError = WindowsError
|
||||
except NameError:
|
||||
class WindowsError(Exception):
|
||||
pass
|
||||
|
||||
if six.PY2:
|
||||
fs_encoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
|
||||
|
||||
|
@ -86,26 +79,6 @@ def safe_join(base, *paths):
|
|||
return final_path
|
||||
|
||||
|
||||
def rmtree_errorhandler(func, path, exc_info):
|
||||
"""
|
||||
On Windows, some files are read-only (e.g. in in .svn dirs), 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]
|
||||
# looking for a windows error
|
||||
if exctype is not WindowsError or 'Access is denied' not in str(value):
|
||||
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 symlinks_supported():
|
||||
"""
|
||||
A function to check if creating symlinks are supported in the
|
||||
|
|
|
@ -20,7 +20,7 @@ from django.core.management import call_command
|
|||
from django.template import Context, Template
|
||||
from django.test import TestCase, override_settings
|
||||
from django.utils import six
|
||||
from django.utils._os import rmtree_errorhandler, symlinks_supported, upath
|
||||
from django.utils._os import symlinks_supported, upath
|
||||
from django.utils.encoding import force_text
|
||||
from django.utils.functional import empty
|
||||
|
||||
|
@ -106,9 +106,7 @@ class BaseCollectionTestCase(BaseStaticFilesTestCase):
|
|||
self.patched_settings = self.settings(STATIC_ROOT=temp_dir)
|
||||
self.patched_settings.enable()
|
||||
self.run_collectstatic()
|
||||
# Use our own error handler that can handle .svn dirs on Windows
|
||||
self.addCleanup(shutil.rmtree, temp_dir,
|
||||
ignore_errors=True, onerror=rmtree_errorhandler)
|
||||
self.addCleanup(shutil.rmtree, temp_dir)
|
||||
|
||||
def tearDown(self):
|
||||
self.patched_settings.disable()
|
||||
|
|
Loading…
Reference in New Issue