Re: File Permissions

2006-03-18 Thread Christos Georgiou
On Fri, 10 Mar 2006 16:43:15 +0200, rumours say that Juho Schultz <[EMAIL PROTECTED]> might have written: >VJ wrote: >> Hi All >> >> Basically i want to write into a file .If the permissions are not there >> then print a error message. >> How do i achive this ??? >> >> Thanks, >> VJ >One way w

Re: File Permissions

2006-03-10 Thread Fredrik Lundh
"VJ" wrote: > I need to get the user permission of a file using python. I was trying > the following code which i found on google grups > > st = os.stat(myfile) > mode = st[stat.ST_MODE] > if mode & stat.ST_IREAD: > print "readable" > if mode & stat.ST_IWRITE: > print

Re: File Permissions

2006-03-10 Thread Sybren Stuvel
Sebastjan Trepca enlightened us with: > Those constants are in stat module so add "import stat" before the > program. Yeah, but just opening the file is more Pythonic than first checking if it can be opened in the first place. Sybren -- The problem with the world is stupidity. Not saying there s

Re: File Permissions

2006-03-10 Thread Juho Schultz
VJ wrote: > Hi All > > Basically i want to write into a file .If the permissions are not there > then print a error message. > How do i achive this ??? > > Thanks, > VJ > One way would be a try-except block, and leave the permission checking error message generation, etc. to the operating syst

Re: File Permissions

2006-03-10 Thread Sybren Stuvel
VJ enlightened us with: > Basically i want to write into a file .If the permissions are not > there then print a error message. How do i achive this ??? f = file('somefile', 'w') then catch the exception that's thrown when it can't be done. Sybren -- The problem with the world is stupidity. No

Re: File Permissions

2006-03-10 Thread Sebastjan Trepca
Those constants are in stat module so add "import stat" before the program. On 10 Mar 2006 06:20:18 -0800, VJ <[EMAIL PROTECTED]> wrote: > Hi All > > I need to get the user permission of a file using python. I was trying > the following code which i found on google grups > > st = os.stat(myfile)

Re: File permissions script vs shell

2006-01-31 Thread jdlists
Fredrik Lundh wrote: > [EMAIL PROTECTED] wrote: > > > I'm running python on windows and have a program that watches a > > directory and acts on files as they come into the directory. After > > processing is complete, i delete the file, or in this case attempt > > to > > > > In the script versi

Re: File permissions script vs shell

2006-01-31 Thread Fredrik Lundh
[EMAIL PROTECTED] wrote: > I'm running python on windows and have a program that watches a > directory and acts on files as they come into the directory. After > processing is complete, i delete the file, or in this case attempt > to > > In the script version I repeatedly get OSError exceptio

Re: file permissions on windows XP (home)

2005-06-08 Thread Ivan Van Laningham
Hi All-- [EMAIL PROTECTED] wrote: > > I have noticed a bug that if I have a folder open for viewing in > Windows Explorer with Thumbnail view enabled that I often run into > inexplicable problems with modify permissions, say when I want to > rename or delete an item. Changing the view to Detaile

Re: file permissions on windows XP (home)

2005-06-08 Thread gratzel
I have noticed a bug that if I have a folder open for viewing in Windows Explorer with Thumbnail view enabled that I often run into inexplicable problems with modify permissions, say when I want to rename or delete an item. Changing the view to Detailed or rebooting seems to make the issue go away

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

Re: file permissions on windows XP (home)

2005-06-08 Thread Duncan Booth
barney wrote: > 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 >

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 unch

Re: file permissions on windows XP (home)

2005-06-07 Thread Duncan Booth
Peter Hansen wrote: >> >> Why is python returing True from os.access? >> Why isn't chmod doing anything? > > Check your results using os.stat() after doing that, perhaps? If it > shows the right values for the permissions, then clearly the problem has > nothing to do with Python per se, or yo

Re: file permissions on windows XP (home)

2005-06-07 Thread Peter Hansen
barney wrote (having trouble with a file): [snip] > IOError: [Errno 13] Permission denied: "02 - New Year's Day.mp3" [snip] > 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? Check your results using os.stat() after do