Reputation: 870
I have an xml file on a windows network drive that I am trying to read and write to. I have full permission to edit the file normally (in gedit or anything), but when I attempt to parse the xml file in python, I get a permissions error. Any ideas?
Here is an example of what I am trying to do:
from xml.etree import ElementTree as ET
file = "/directory/to/xml/file"
nfo = ET.parse(file)
I then read info from the file and write to the file. It hangs up when trying to write to the file (even though when I use gedit, I can write to the file fine)
the error I get is:
Traceback (most recent call last):
File "parser.py", line 277, in <module>
nfo.write(file)
File "/usr/lib/python2.7/xml/etree/ElementTree.py", line 803, in write
file = open(file_or_filename, "wb")
IOError: [Errno 13] Permission denied: '/directory/to/xml/file'
Upvotes: 2
Views: 1927
Reputation: 6796
are you sure that gedit does not ignore lack of write permission if you're the file owner? vim can do that, and maybe gedit too? I'd start with simple ls -l /directory/to/xml/file
.
you can always do strace -f /path/to/your_program.py
, that should give you more info on what is actually being attempted by python runtime.
Upvotes: 1