aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDavid Wagner <david.wagner@intel.com>2015-01-09 19:20:02 +0100
committerDavid Wagner <david.wagner@intel.com>2015-01-28 20:02:40 +0100
commit03b951fa8ac82daf8fb3f0cee7d47a7baff9f359 (patch)
tree84eb272955d33356333c158dab475434d977e388 /tools
parent7d996811c0e80b30a40a5add1f01f0314f2ebef4 (diff)
downloadexternal_parameter-framework-03b951fa8ac82daf8fb3f0cee7d47a7baff9f359.zip
external_parameter-framework-03b951fa8ac82daf8fb3f0cee7d47a7baff9f359.tar.gz
external_parameter-framework-03b951fa8ac82daf8fb3f0cee7d47a7baff9f359.tar.bz2
xmlGenerator: modularize hostConfig.py for easier reuse
Instead of calling this script from command line, we will need to use it from another python script/module. Change-Id: Ic3b1f55c0a73c4edff005687327cd19570ab7743 Signed-off-by: David Wagner <david.wagner@intel.com>
Diffstat (limited to 'tools')
-rwxr-xr-xtools/xmlGenerator/hostConfig.py22
1 files changed, 11 insertions, 11 deletions
diff --git a/tools/xmlGenerator/hostConfig.py b/tools/xmlGenerator/hostConfig.py
index c8ec3ac..871f8f2 100755
--- a/tools/xmlGenerator/hostConfig.py
+++ b/tools/xmlGenerator/hostConfig.py
@@ -32,19 +32,17 @@
import xml.dom.minidom
import sys
-serverPort=sys.argv[1]
-structPath=sys.argv[2]
-
-def main():
+def configure(infile=sys.stdin, outfile=sys.stdout, serverPort=None, structPath=None):
""" Format an xml PFW config file (standard input) for simulation.
- Allow tuning on argv[1] port, remove the plugins and settings need,
+ Allow tuning on @serverPort port, remove the plugins and settings need,
and change the structure path to absolute."""
- dom = xml.dom.minidom.parse(sys.stdin)
+ dom = xml.dom.minidom.parse(infile)
for node in dom.getElementsByTagName("ParameterFrameworkConfiguration"):
- node.setAttribute("ServerPort", serverPort)
+ if serverPort is not None:
+ node.setAttribute("ServerPort", serverPort)
node.setAttribute("TuningAllowed", "true")
def delete(tag):
@@ -53,12 +51,14 @@ def main():
delete("Location")
delete("SettingsConfiguration")
- for node in dom.getElementsByTagName("StructureDescriptionFileLocation"):
- node.setAttribute("Path", structPath + "/" + node.getAttribute("Path"))
+ if structPath is not None:
+ for node in dom.getElementsByTagName("StructureDescriptionFileLocation"):
+ node.setAttribute("Path", structPath + "/" + node.getAttribute("Path"))
- sys.stdout.write(dom.toxml())
+ outfile.write(dom.toxml())
if __name__ == "__main__" :
""" Execute main if the python interpreter is running this module as the main program """
- main()
+
+ configure(serverPort=sys.argv[1], structPath=sys.argv[2])