fixes and remove debug code
This commit is contained in:
parent
fe3bd5a557
commit
1601fb3738
@ -20,12 +20,19 @@ from xml.dom.ext import *
|
|||||||
from xml.dom.ext.reader import Sax2
|
from xml.dom.ext.reader import Sax2
|
||||||
|
|
||||||
def read_policy_xml(filename):
|
def read_policy_xml(filename):
|
||||||
|
try:
|
||||||
|
xml_fh = open(filename)
|
||||||
|
except:
|
||||||
|
error("error opening " + filename)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
reader = Sax2.Reader()
|
reader = Sax2.Reader()
|
||||||
doc = reader.fromStream(filename)
|
doc = reader.fromString(xml_fh.read())
|
||||||
except:
|
except:
|
||||||
|
xml_fh.close()
|
||||||
error("Error while parsing xml")
|
error("Error while parsing xml")
|
||||||
|
|
||||||
|
xml_fh.close()
|
||||||
return doc
|
return doc
|
||||||
|
|
||||||
def gen_tunable_conf(doc, file):
|
def gen_tunable_conf(doc, file):
|
||||||
@ -185,12 +192,13 @@ def gen_docs(doc, dir, templatedir):
|
|||||||
for args in interface.getElementsByTagName("parameter"):
|
for args in interface.getElementsByTagName("parameter"):
|
||||||
paramdesc = args.firstChild.data
|
paramdesc = args.firstChild.data
|
||||||
paramname = None
|
paramname = None
|
||||||
paramopt = False
|
paramopt = "No"
|
||||||
for name,val in args.attributes.items():
|
for name,val in args.attributes.items():
|
||||||
if name[1] == "name":
|
if name[1] == "name":
|
||||||
paramname = val.value
|
paramname = val.value
|
||||||
if name[1] == "optional":
|
if name[1] == "optional":
|
||||||
paramopt = val.value
|
if val.value == "true":
|
||||||
|
paramopt = "yes"
|
||||||
parameter = { "name" : paramname,
|
parameter = { "name" : paramname,
|
||||||
"desc" : paramdesc,
|
"desc" : paramdesc,
|
||||||
"optional" : paramopt }
|
"optional" : paramopt }
|
||||||
@ -228,7 +236,6 @@ def error(error):
|
|||||||
sys.stderr.write("%s exiting for: " % sys.argv[0])
|
sys.stderr.write("%s exiting for: " % sys.argv[0])
|
||||||
sys.stderr.write("%s\n" % error)
|
sys.stderr.write("%s\n" % error)
|
||||||
sys.stderr.flush()
|
sys.stderr.flush()
|
||||||
raise
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def usage():
|
def usage():
|
||||||
@ -247,7 +254,7 @@ except getopt.GetoptError:
|
|||||||
usage()
|
usage()
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
tunables = modules = docs = None
|
tunables = modules = docsdir = None
|
||||||
templatedir = "templates/"
|
templatedir = "templates/"
|
||||||
xmlfile = "policy.xml"
|
xmlfile = "policy.xml"
|
||||||
|
|
||||||
@ -263,10 +270,6 @@ for opt, val in opts:
|
|||||||
if opt in ("-T", "--templates"):
|
if opt in ("-T", "--templates"):
|
||||||
templatedir = val
|
templatedir = val
|
||||||
|
|
||||||
if xmlfile == None:
|
|
||||||
usage()
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
doc = read_policy_xml(xmlfile)
|
doc = read_policy_xml(xmlfile)
|
||||||
|
|
||||||
if tunables:
|
if tunables:
|
||||||
|
Loading…
Reference in New Issue
Block a user