Commit b6315a90 authored by andreasjung's avatar andreasjung

- refactored rmtree functionality

- further rmtree fixes for Windows


git-svn-id: http://svn.zope.org/repos/main/zc.buildout/trunk@84136 62d5b8a3-27da-0310-9561-8e5933582275
parent edde0942
...@@ -34,6 +34,8 @@ import pkg_resources ...@@ -34,6 +34,8 @@ import pkg_resources
import zc.buildout import zc.buildout
import zc.buildout.easy_install import zc.buildout.easy_install
from rmtree import rmtree
realpath = zc.buildout.easy_install.realpath realpath = zc.buildout.easy_install.realpath
pkg_resources_loc = pkg_resources.working_set.find( pkg_resources_loc = pkg_resources.working_set.find(
...@@ -570,7 +572,7 @@ class Buildout(UserDict.DictMixin): ...@@ -570,7 +572,7 @@ class Buildout(UserDict.DictMixin):
continue continue
f = self._buildout_path(f) f = self._buildout_path(f)
if os.path.isdir(f): if os.path.isdir(f):
shutil.rmtree(f) rmtree(f)
elif os.path.isfile(f): elif os.path.isfile(f):
os.remove(f) os.remove(f)
...@@ -992,7 +994,7 @@ class Options(UserDict.DictMixin): ...@@ -992,7 +994,7 @@ class Options(UserDict.DictMixin):
except: except:
for p in self._created: for p in self._created:
if os.path.isdir(p): if os.path.isdir(p):
shutil.rmtree(p) rmtree(p)
elif os.path.isfile(p): elif os.path.isfile(p):
os.remove(p) os.remove(p)
else: else:
......
...@@ -26,6 +26,8 @@ import pkg_resources ...@@ -26,6 +26,8 @@ import pkg_resources
import zc.buildout.buildout import zc.buildout.buildout
import zc.buildout.easy_install import zc.buildout.easy_install
from rmtree import rmtree
fsync = getattr(os, 'fsync', lambda fileno: None) fsync = getattr(os, 'fsync', lambda fileno: None)
setuptools_location = pkg_resources.working_set.find( setuptools_location = pkg_resources.working_set.find(
...@@ -87,13 +89,6 @@ def system(command, input=''): ...@@ -87,13 +89,6 @@ def system(command, input=''):
def get(url): def get(url):
return urllib2.urlopen(url).read() 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): def _runsetup(setup, executable, *args):
if os.path.isdir(setup): if os.path.isdir(setup):
setup = os.path.join(setup, 'setup.py') setup = os.path.join(setup, 'setup.py')
...@@ -109,7 +104,7 @@ def _runsetup(setup, executable, *args): ...@@ -109,7 +104,7 @@ def _runsetup(setup, executable, *args):
os.chdir(d) os.chdir(d)
os.spawnle(os.P_WAIT, executable, executable, setup, *args) os.spawnle(os.P_WAIT, executable, executable, setup, *args)
if os.path.exists('build'): if os.path.exists('build'):
_rmtree('build') rmtree('build')
finally: finally:
os.chdir(here) os.chdir(here)
...@@ -170,7 +165,7 @@ def buildoutSetUp(test): ...@@ -170,7 +165,7 @@ def buildoutSetUp(test):
base = tempfile.mkdtemp('buildoutSetUp') base = tempfile.mkdtemp('buildoutSetUp')
register_teardown(lambda base=base: _rmtree(base)) register_teardown(lambda base=base: rmtree(base))
old_home = os.environ.get('HOME') old_home = os.environ.get('HOME')
os.environ['HOME'] = os.path.join(base, 'bbbBadHome') os.environ['HOME'] = os.path.join(base, 'bbbBadHome')
...@@ -185,7 +180,7 @@ def buildoutSetUp(test): ...@@ -185,7 +180,7 @@ def buildoutSetUp(test):
os.mkdir(base) os.mkdir(base)
tmp = tempfile.mkdtemp('buildouttests') tmp = tempfile.mkdtemp('buildouttests')
register_teardown(lambda: _rmtree(tmp)) register_teardown(lambda: rmtree(tmp))
zc.buildout.easy_install.default_index_url = 'file://'+tmp zc.buildout.easy_install.default_index_url = 'file://'+tmp
os.environ['buildout-testing-index-url'] = ( os.environ['buildout-testing-index-url'] = (
......
...@@ -2693,6 +2693,7 @@ def test_suite(): ...@@ -2693,6 +2693,7 @@ def test_suite():
]), ]),
), ),
zc.buildout.testselectingpython.test_suite(), zc.buildout.testselectingpython.test_suite(),
zc.buildout.rmtree.test_suite(),
doctest.DocFileSuite( doctest.DocFileSuite(
'windows.txt', 'windows.txt',
setUp=zc.buildout.testing.buildoutSetUp, 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