From: Peter C. <pc...@us...> - 2010-03-03 04:02:11
|
Update of /cvsroot/ipbench/ipbench2/src In directory sfp-cvsdas-1.v30.ch3.sourceforge.com:/tmp/cvs-serv16889/src Modified Files: ipbench.py Log Message: Use lxml instead of xml, to get more XPATH syntax. Index: ipbench.py =================================================================== RCS file: /cvsroot/ipbench/ipbench2/src/ipbench.py,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** ipbench.py 8 Feb 2010 23:40:37 -0000 1.36 --- ipbench.py 3 Mar 2010 04:01:53 -0000 1.37 *************** *** 9,13 **** import select from optparse import OptionParser ! from xml.etree.ElementTree import parse options = None --- 9,13 ---- import select from optparse import OptionParser ! from lxml.etree import parse options = None *************** *** 288,292 **** ! tests = doc.findAll('/ipbench/test') if (len(tests) > 1): print "Error in config: please only have one <test> section" --- 288,292 ---- ! tests = doc.findall('test') if (len(tests) > 1): print "Error in config: please only have one <test> section" *************** *** 308,312 **** # go through each <client>, override default values from attributes and add it to the # clients[] list ! data = doc.findAll('/ipbench/test/client') for cclients in data: newclient = { --- 308,312 ---- # go through each <client>, override default values from attributes and add it to the # clients[] list ! data = tests[0].findall('./client') for cclients in data: newclient = { *************** *** 329,337 **** #now look for the <target_test> section, add to the targets list ! target_tests = doc.FindAll("/ipbench/target_test") for target_test in target_tests: ! target_test_name = test.get('name') ! options.target_test_args = test.get('args') ! options.target_controller_args = str(test.get('controller_args')) # it is possible that there will be multiple <target_test> --- 329,337 ---- #now look for the <target_test> section, add to the targets list ! target_tests = doc.findall("target_test") for target_test in target_tests: ! target_test_name = target_test.get('name') ! options.target_test_args = target_test.get('args') ! options.target_controller_args = str(target_test.get('controller_args')) # it is possible that there will be multiple <target_test> *************** *** 339,345 **** # make sure we only select those targets for the target # test we are currently looking at. ! tclients = doc.findAll("/ipbench/target_test[@name=\'"+target_test_name+"\']/target") if (not (len(tclients) > 0)): ! print "Please specifiy some targets in the <target_test> section!" sys.exit(1) for tclient in tclients: --- 339,345 ---- # make sure we only select those targets for the target # test we are currently looking at. ! tclients = doc.findall("target_test[@name=\'"+target_test_name+"\']/target") if (not (len(tclients) > 0)): ! print "Please specify some targets in the <target_test> section!" sys.exit(1) for tclient in tclients: *************** *** 353,361 **** newtarget["hostname"] = tclient.get('hostname', options.target_test_hostname) ! newtarget["port"] = int(tclient.get(port, options.target_test_port)) newtarget["test_args"] = str(tclient.get('test_args', options.target_test_args)) if (newtarget["hostname"] == None): ! print "Please specifiy a hostname for the target!" sys.exit(1) --- 353,361 ---- newtarget["hostname"] = tclient.get('hostname', options.target_test_hostname) ! newtarget["port"] = int(tclient.get('port', options.target_test_port)) newtarget["test_args"] = str(tclient.get('test_args', options.target_test_args)) if (newtarget["hostname"] == None): ! print "Please specify a hostname for the target!" sys.exit(1) |