Re: File permissions script vs shell



jdlists@xxxxxxxxx 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 exceptions stating
> permission denied when trying to delete or rename
>
> My exception print out...
> Files system said no: [Errno 13] Permission denied:
> u'D:\\Data\\00-0C-41-DD-87-E5.xml'
>
> But i can go into the python shell and execute...
>
> fileString = 'D:\\Data\\00-0C-41-DD-87-E5.xml'
> import os
> os.unlink(fileString)
>
> and the file deletes fine
>
> Any ideas? This is on my development windows xp box and i'm the only
> user.

did you close the file correctly after processing it ?

>>> f = open("somefile.txt", "w")
>>> import os
>>> os.remove("somefile.txt")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OSError: [Errno 13] Permission denied: 'somefile.txt'
>>> f.close()
>>> f = open("somefile.txt", "r")
>>> os.remove("somefile.txt")
Traceback (most recent call last):
File "<stdin>", line 1, in ?
OSError: [Errno 13] Permission denied: 'somefile.txt'
>>> f.close()
>>> os.remove("somefile.txt")
>>>

</F>



.



Relevant Pages

  • Re: File permissions script vs shell
    ... >> I'm running python on windows and have a program that watches a ... >> In the script version I repeatedly get OSError exceptions stating ... This is on my development windows xp box and i'm the only ... > Traceback: ...
    (comp.lang.python)
  • File permissions script vs shell
    ... I'm running python on windows and have a program that watches a ... directory and acts on files as they come into the directory. ... In the script version I repeatedly get OSError exceptions stating ... This is on my development windows xp box and i'm the only ...
    (comp.lang.python)
  • select() on WinXP
    ... I'm running Python 2.5 on Windows XP. ... Traceback: ... 'An invalid argument was supplied') ...
    (comp.lang.python)
  • Re: gmpy 1.0 for python 2.4 alpha 2 Windows-packaged
    ... I generally don't run package test suites on Windows ... >The problem is that a real traceback doesn't look like that. ... >exception detail starts. ... ZeroDivisionError: float division ...
    (comp.lang.python)
  • Re: read from standard input
    ... but its giving ArgumentError in windows. ... Unless you give the /actual/ error and full traceback, ... The error log is here for my above program in windows: ... what version of Python are your running? ...
    (comp.lang.python)