gtg-user team mailing list archive
-
gtg-user team
-
Mailing list archive
-
Message #00028
Inappropriate permissions on projects.xml
Hi,
Inappropriate permissions on projects.xml file lead to an unexpected
program termination (you thought about it, if I believe you comments in
cleanxml.py :). Here is a really simple patch to warn users and to
finish the program properly.
Regards,
Carl Chenet
www.ohmytux.com
19a20
> import sys
65,78c66,83
< if os.path.exists(zefile) :
< #We should be more defensive here
< doc = xml.dom.minidom.parse(zefile)
< cleanDoc(doc,tab,enter)
< #We should be more defensive here
< xmlproject = doc.getElementsByTagName(root)[0]
< #the file didn't exist, create it now
< else :
< doc,xmlproject = emptydoc(root)
< #then we create the file
< f = open(zefile, mode='a+')
< f.write(doc.toxml().encode("utf-8"))
< f.close()
< return doc,xmlproject
---
> try:
> if os.path.exists(zefile) :
> #We should be more defensive here
> doc = xml.dom.minidom.parse(zefile)
> cleanDoc(doc,tab,enter)
> #We should be more defensive here
> xmlproject = doc.getElementsByTagName(root)[0]
> #the file didn't exist, create it now
> else :
> doc,xmlproject = emptydoc(root)
> #then we create the file
> f = open(zefile, mode='a+')
> f.write(doc.toxml().encode("utf-8"))
> f.close()
> return doc,xmlproject
> except IOError, msg:
> print msg
> sys.exit(1)
Follow ups