file permissions on windows XP (home)

barney barney.dalton at gmail.com
Mon Jun 6 18:33:19 EDT 2005


I'm trying to write to an existing file under windows XP (home). The
files are in 'My Music' which I think may be treated in some special
way under XP. The relevant python code is as follows:

os.chdir(dir)
os.chmod(filename, 0744)
print "Okay to write = "+str(os.access(filename, os.W_OK))
afile = file(filename, 'r+b')

When I run this I get the following console output:

Okay to write = True
Traceback (most recent call last):
  File "c:\temp\eyed3-0.6.6\src\test.py", line 28, in ?
    processFiles(root,files)
  File "c:\temp\eyed3-0.6.6\src\test.py", line 24, in processFiles
    afile = file(filename, 'r+b')
IOError: [Errno 13] Permission denied: "02 - New Year's Day.mp3"

If I look at the files in explorer then the read only flag is not set.
If I change to cygwin and then do an ls -l I get something like:

-r--r--r--  1 Barney None 4142103 Feb 28  1999 02 - New Year's Day.mp3

If I do a chmod 644 from bash first then the python works fine?

I'm at a loss to understand what is going on.

Why is python returing True from os.access?
Why isn't chmod doing anything?
Why is cygwin able to sort the problem out?

Thanks
Barney

p.s. I'm using ActiveState Python 2.4




More information about the Python-list mailing list