file permissions on windows XP (home)

2005-06-06 Thread barney

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

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: file permissions on windows XP (home)

2005-06-07 Thread barney
Thanks,

I tried creating a test file but I get "Access is denied" from windows
explorer! The folder appears to be read only but when I try and uncheck
read only/apply/repopen the folder properties its still read only. This
read only flag seems to propagate down from the My Music directory but
unchecking it there also has no lasting effect.

I realise that theses are windows rather than python issues but I would
expect there would be some reliable way of changing the file
permissions from within python. I'm updating ID3 tags in MP3 file to
give some context. If I use something like winamp to make the change to
the ID3 tag then the file is updated with no permission errors so there
must be a way

I have added a stat call to the code which returns:

(33206, 0L, 2, 1, 0, 0, 4142103L, 1118176036, 920221388, 442057)

and this is the output of cacls (didn't know about this command):

C:\Users\Barney\My Music\U2\The Best Of 1980 - 1990 (US CD 1)\02 - New
Year's Day.mp3 XPHOME\Barney:(special access:)
STANDARD_RIGHTS_ALL
DELETE
READ_CONTROL
WRITE_DAC
WRITE_OWNER
SYNCHRONIZE
STANDARD_RIGHTS_REQUIRED
FILE_GENERIC_READ
FILE_READ_DATA
FILE_READ_EA
FILE_WRITE_EA
FILE_READ_ATTRIBUTES
FILE_WRITE_ATTRIBUTES

XPHOME\None:(special access:)
READ_CONTROL
SYNCHRONIZE
FILE_GENERIC_READ
FILE_READ_DATA
FILE_READ_EA
FILE_READ_ATTRIBUTES

Everyone:(special access:)
READ_CONTROL
SYNCHRONIZE
FILE_GENERIC_READ
FILE_READ_DATA
FILE_READ_EA
FILE_READ_ATTRIBUTES


I'm not entirely sure how to interpret these but will do some reading.
In the meantime if someone could show me some python to force the file
to be writeable that's all I really need at this stage.

Thanks
Barney

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: file permissions on windows XP (home)

2005-06-08 Thread barney
Thanks, I will go the win32security.SetFileSecurity route. It seems a
pity that I can't use platform independant code to sort this out but I
guess you're saying that I've managed to get my files into a non
standard state that needs non standard code to sort it out. I wonder
how winamp/itunes manage to bypass it.

Barney

-- 
http://mail.python.org/mailman/listinfo/python-list