<br><div class="gmail_quote">2009/5/7 Alexander Belchenko <span dir="ltr"><<a href="mailto:bialix@ukr.net">bialix@ukr.net</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi Maritza,<br>
<br>
Because I'm the one who was involved in writing _win32_delete_readonly,<br>
I'll try to provide some hints for you.<br>
<br>
def _win32_delete_readonly(function, path, excinfo):<br>
"""Error handler for shutil.rmtree function [for win32]<br>
Helps to remove files and dirs marked as read-only.<br>
"""<br>
exception = excinfo[1]<br>
if function in (os.remove, os.rmdir) \<br>
and isinstance(exception, OSError) \<br>
and exception.errno == errno.EACCES:<br>
make_writable(path)<br>
function(path)<br>
else:<br>
raise<br>
<br>
The problem in the code above is that it used too-broad testing for error, e.g.<br>
<br>
and exception.errno == errno.EACCES:<br>
<br>
errno.EACCES it's a POSIX-style error constant, IIUC it's about Access Denied.<br>
<br>
Fortunately it seems like actually we have there WindowsError exception, and therefore can get real Windows Error Code (as of GetLastError() returns).<br>
<br>
So, if you're adding following debugging prints to the function:<br>
<br>
def _win32_delete_readonly(function, path, excinfo):<br>
"""Error handler for shutil.rmtree function [for win32]<br>
Helps to remove files and dirs marked as read-only.<br>
"""<br>
exception = excinfo[1]<br>
<br>
+ print type(exception), dir(exception)<br>
+ print getattr(exception, 'winerror', None)<br>
<br>
if function in (os.remove, os.rmdir) \<br>
and isinstance(exception, OSError) \<br>
and exception.errno == errno.EACCES:<br>
make_writable(path)<br>
function(path)<br>
else:<br>
raise<br>
<br>
<br>
You will obtain additional information about your error with BeyondCompare3. Especially the second print should print to you actual Windows error code (<a href="http://msdn.microsoft.com/en-us/library/ms681381%28VS.85%29.aspx" target="_blank">http://msdn.microsoft.com/en-us/library/ms681381(VS.85).aspx</a>)<br>
<br>
Knowing actual error code there is possible to imprtove _win32_delete_readonly function to make more fine-grained analysis why deletion of file fails and provide appropriate solution for different cases: deleting read-only files, files currently in use etc.<br>
<br>
HTH<br>
<br>
</blockquote><div><br>That's very helpful and informative, Alexander. Thanks! I will try to follow your lead and report back to the list what this reveals. It will probably be tomorrow or the weekend before I get to it. I am impressed by how rapidly discussions progress here. Do you guys all work for a bzr-friendly boss like Canonical or do you just never sleep? :)<br>
<br>-M<br></div></div><br>