whitlockjc / sync-ldap-groups-to-svn-authz

Simple Python script that can take your LDAP group definitions and create a Subversion authz file equivalent.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

os.rename() and os.remove() don't work in Windows

whitlockjc opened this issue · comments

print_group_model throws unhandled exceptions under Windows because the OS thinks that the temp file is open at the time you're trying to rename or delete it.

More details from previous issue.

Yeah, we've had the same issue. os.remove(tmp_authz_path) cannot remove the file due to it being used by another process, or as I suspect, the same process. This script isn't able to close the file before it's supposed to be removed. We put in a time.sleep(5) before os.remove but no improvement.

We are running windows 2008 32bit.

We experienced the same problem. I fixed it by adding os.close(tmp_fd) before os.remove(tmp_authz_path)
In the end it looks like this:

...
tmpfile.close()
os.close(tmp_fd)
os.remove(tmp_authz_path)
...

Hope this helps.
Stefan