newbie permission problem

Ann Anna at nospam.invalid
Sun Oct 3 04:16:06 EDT 2004


"Ann" <Anna at nospam.invalid> wrote in message
news:PUN7d.296691$mD.66455 at attbi_s02...
>
> "Sol Mumey" <smumeyyahoocom at add.dots> wrote in message
> news:7sN7d.593248$gE.589623 at pd7tw3no...
> > Ann wrote:
> > > I am new to python. I have a small program that
> > > deletes small jpeg files, but I am getting a
> > > permission error, even though I am the owner of the
> > > file and the directory has 777 permission. I have
> > > WIN XP Pro. I have mks toolkit "ls" command.
> > > Login name is "Philip"
> > >
> > > -------------
> > >
> > > 36      45      border_l_r2_c3.gif is tiny      <- printed by program
> > > Traceback (most recent call last):
> > >   File "C:\test2.py", line 28, in ?
> > >     os.remove(d) # delete the tiny files
> > > OSError: [Errno 13] Permission denied: 'border_l_r2_c3.gif'
> > >
> > > C:\>ls -ld . border_l_r2_c3.gif
> > > drwxrwsrwx   1 Philip   None     0 Oct  2 23:40 .
> > > -rwxrwxrwa   1 Philip   None   398 Oct  2 22:42 border_l_r2_c3.gif
> > >
> > >
> > Are you sure that the unix-style permission reported by ls are
> > reflecting the true permissions (and read only attribute) on the file.
> > We use Cygwin at work, at the permissions reported by ls, etc. are
> > meaningless with our installation (though that need not be the case with
> > Cygwin). From the commandline I think you can check/set this with
> > attrib.exe, if a bunch need to be checked/changed.
>
> Yes, I'm not so sure about the output of "ls" myself. (note the 'a'
> where I would expect an 'x' for the file) I did try the
> attrib command, but it only showed that the directory is "system"
> and the file is "archive". Also, I created the file via under my
> account (ls shows owner = Philip) and I can delete it manually with
> "rm" or "del" or with a perl script just fine. I also tried using
> "os.unlink(d)" with the same results. I found another command
> lsacl to list the access control list, it gives this: (YOGA is my
> workstation name)
>
> C:\>lsacl border-l-r2-c3.gif
> border-l-r3-c3[1].gif:
>  ACE: Allow YOGA\Philip            -
> R,W,X,A,DC,RE,WE,RA,WA,D,RC,WD,O,S
>  ACE: Allow NT+AUTHORITY\SYSTEM    -
> R,W,X,A,DC,RE,WE,RA,WA,D,RC,WD,O,S
>  ACE: Allow BUILTIN\Administrators -
> R,W,X,A,DC,RE,WE,RA,WA,D,RC,WD,O,S
>

I found the problem just now, the file is still open when I tried
to delete it. If I use

fp = open("filename.jpg", "rb")
im = Image.open(fp)

then I can close fp and delete the file.

How can I just use
im = Image.open("filename.jpg")
without having to use a fp





More information about the Python-list mailing list