Edgewall Software

Opened 16 years ago

Last modified 15 years ago

#253 new defect

rmtree problem (again :-( ) on windows — at Version 1

Reported by: thomas_mueller_ffb Owned by: osimons
Priority: major Milestone: 0.6.1
Component: Build slave Version: dev
Keywords: rmtree Cc:
Operating System: Windows

Description (last modified by osimons)

Traceback (most recent call last):
  File "C:\Python25\Scripts\bitten-slave-script.py", line 8, in <module>
    load_entry_point('Bitten==0.6dev-r521', 'console_scripts', 'bitten-slave')()

  File "c:\python25\lib\site-packages\Bitten-0.6dev_r521-py2.5.egg\bitten\slave.
py", line 381, in main
    slave.run()
  File "c:\python25\lib\site-packages\Bitten-0.6dev_r521-py2.5.egg\bitten\slave.
py", line 150, in run
    self._create_build()
  File "c:\python25\lib\site-packages\Bitten-0.6dev_r521-py2.5.egg\bitten\slave.
py", line 195, in _create_build
    self._initiate_build(resp.info().get('location'))
  File "c:\python25\lib\site-packages\Bitten-0.6dev_r521-py2.5.egg\bitten\slave.
py", line 207, in _initiate_build
    self._execute_build(build_url, resp)
  File "c:\python25\lib\site-packages\Bitten-0.6dev_r521-py2.5.egg\bitten\slave.
py", line 238, in _execute_build
    _rmtree(basedir)
  File "c:\python25\lib\site-packages\Bitten-0.6dev_r521-py2.5.egg\bitten\slave.
py", line 43, in _rmtree
    return shutil.rmtree(root, onerror=_handle_error)
  File "C:\Python25\lib\shutil.py", line 169, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "C:\Python25\lib\shutil.py", line 169, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "C:\Python25\lib\shutil.py", line 178, in rmtree
    onerror(os.rmdir, path, sys.exc_info())
  File "c:\python25\lib\site-packages\Bitten-0.6dev_r521-py2.5.egg\bitten\slave.
py", line 42, in _handle_error
    fn(path)
WindowsError: [Error 145] The directory is not empty: 'c:\\docume~1\\deepdi~1\\l
ocals~1\\temp\\bittenufirfj\\build_Qt4.2_6\\deploy\\.svn'

Change History (1)

comment:1 Changed 15 years ago by osimons

  • Description modified (diff)
  • Owner changed from cmlenz to osimons

This I've seen before... Subversion makes various files inside a working copy read-only, and shutil.rmtree on Windows won't remove read-only files, and hence directories will not be empty when expected to.

I've got some utility code for another project that wraps rmtree, and if OS is Windows it walks all files and turns off read-only before removing:

import shutil, os
def rmtree(path, *args, **kwargs):
    if os.name == 'nt':
        for (dirpath, dirnames, filenames) in os.walk(path):
            # Windows does not allow remove of read-only files
            for filename in filenames:
                os.chmod(os.path.join(dirpath, filename),
                            stat.S_IWRITE)
    shutil.rmtree(path, *args, **kwargs)

I'll see if I can make a patch to actually test this.

Note: See TracTickets for help on using tickets.