471,050 Members | 1,094 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,050 software developers and data experts.

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. 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.

Thanks
Jeff

Jan 31 '06 #1
2 2033
jd*****@gmail.com 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>

Jan 31 '06 #2
Fredrik Lundh wrote:
jd*****@gmail.com 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>


That was correct...i started to see it just after posting, the open
file was hidden behind the 4Suite library via the FromUri method.
Reading the xml file as a string and passing it to fromString instead
and closing the file myself solved this.

Jeff

Jan 31 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by John Salerno | last post: by
6 posts views Thread by rahulthathoo | last post: by
30 posts views Thread by Adam Baker | last post: by
13 posts views Thread by eclipsme | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.