Commit fbeee1e3 authored by Andreas Jung's avatar Andreas Jung

- refactored rmtree functionality

- further rmtree fixes for Windows
parent 10e2f007
......@@ -34,6 +34,8 @@ import pkg_resources
import zc.buildout
import zc.buildout.easy_install
from rmtree import rmtree
realpath = zc.buildout.easy_install.realpath
pkg_resources_loc = pkg_resources.working_set.find(
......@@ -570,7 +572,7 @@ class Buildout(UserDict.DictMixin):
continue
f = self._buildout_path(f)
if os.path.isdir(f):
shutil.rmtree(f)
rmtree(f)
elif os.path.isfile(f):
os.remove(f)
......@@ -992,7 +994,7 @@ class Options(UserDict.DictMixin):
except:
for p in self._created:
if os.path.isdir(p):
shutil.rmtree(p)
rmtree(p)
elif os.path.isfile(p):
os.remove(p)
else:
......
......@@ -26,6 +26,8 @@ import pkg_resources
import zc.buildout.buildout
import zc.buildout.easy_install
from rmtree import rmtree
fsync = getattr(os, 'fsync', lambda fileno: None)
setuptools_location = pkg_resources.working_set.find(
......@@ -87,13 +89,6 @@ def system(command, input=''):
def get(url):
return urllib2.urlopen(url).read()
def _rmtree (path):
def retry_writeable (func, path, exc):
os.chmod (path, 0600)
func (path)
shutil.rmtree (path, onerror = retry_writeable)
def _runsetup(setup, executable, *args):
if os.path.isdir(setup):
setup = os.path.join(setup, 'setup.py')
......@@ -109,7 +104,7 @@ def _runsetup(setup, executable, *args):
os.chdir(d)
os.spawnle(os.P_WAIT, executable, executable, setup, *args)
if os.path.exists('build'):
_rmtree('build')
rmtree('build')
finally:
os.chdir(here)
......@@ -170,7 +165,7 @@ def buildoutSetUp(test):
base = tempfile.mkdtemp('buildoutSetUp')
register_teardown(lambda base=base: _rmtree(base))
register_teardown(lambda base=base: rmtree(base))
old_home = os.environ.get('HOME')
os.environ['HOME'] = os.path.join(base, 'bbbBadHome')
......@@ -185,7 +180,7 @@ def buildoutSetUp(test):
os.mkdir(base)
tmp = tempfile.mkdtemp('buildouttests')
register_teardown(lambda: _rmtree(tmp))
register_teardown(lambda: rmtree(tmp))
zc.buildout.easy_install.default_index_url = 'file://'+tmp
os.environ['buildout-testing-index-url'] = (
......
......@@ -2693,6 +2693,7 @@ def test_suite():
]),
),
zc.buildout.testselectingpython.test_suite(),
zc.buildout.rmtree.test_suite(),
doctest.DocFileSuite(
'windows.txt',
setUp=zc.buildout.testing.buildoutSetUp,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment