Modify ↓
Opened 17 years ago
Last modified 15 years ago
#253 new defect
rmtree problem (again :-( ) on windows
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'
Attachments (0)
Change History (4)
comment:1 Changed 15 years ago by osimons
- Description modified (diff)
- Owner changed from cmlenz to osimons
comment:2 Changed 15 years ago by osimons
Right. So [521] contains a fix for shutil.rmtree(), and from the traceback it seems you are running that version and still see the error. It seems like that fix sets permissions, but I'm not quite sure that catches a read-only flag on the file in Windows.
Could you please also try to add this line:
-
bitten/slave.py
a b 43 43 """Catch shutil.rmtree failures on Windows when files are read-only, and only remove if root exists.""" 44 44 def _handle_error(fn, path, excinfo): 45 45 os.chmod(path, 0666) 46 os.chmod(path, stat.S_IWRITE) 46 47 fn(path) 47 48 if os.path.exists(root): 48 49 return shutil.rmtree(root, onerror=_handle_error)
comment:3 Changed 15 years ago by osimons
Sorry, forgot the line to include import stat in previous patch. And as the two os.chmod() calls try to do the same it would be interesting just to try the latest:
-
bitten/slave.py
a b 20 20 import socket 21 21 import tempfile 22 22 import time 23 import stat 23 24 24 25 from bitten.build import BuildError 25 26 from bitten.build.config import Configuration … … 42 43 def _rmtree(root): 43 44 """Catch shutil.rmtree failures on Windows when files are read-only, and only remove if root exists.""" 44 45 def _handle_error(fn, path, excinfo): 45 os.chmod(path, 0666)46 os.chmod(path, stat.S_IWRITE) 46 47 fn(path) 47 48 if os.path.exists(root): 48 49 return shutil.rmtree(root, onerror=_handle_error)
comment:4 Changed 15 years ago by osimons
- Milestone changed from 0.6 to 0.6.1
Note: See
TracTickets for help on using
tickets.
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:
I'll see if I can make a patch to actually test this.