Add cli argument to use different .topo or .params files

- Add cli arguments
- Refactor xmlparser functions
- Cleaned up and fixed some logging
- main.testDir is now set to the directory where the test file is
  located
- main.testsRoot is now set to the full path of TestON/tests/
    - Fixed usages accordingly

Change-Id: I2a0f0c3728b5732b242a2e860e6538a6f3b65166
diff --git a/TestON/core/logger.py b/TestON/core/logger.py
index dc2b2b2..551bacc 100644
--- a/TestON/core/logger.py
+++ b/TestON/core/logger.py
@@ -43,9 +43,9 @@
         for component in main.componentDictionary.keys():
             logmsg = logmsg + "\n\t" + component + " Session Log : " + main.logdir + "/" + component + ".session" + ""
 
-        logmsg = logmsg + "\n\tTest Script :" + path + "Tests/" + main.TEST + ".py" + ""
-        logmsg = logmsg + "\n\tTest Params : " + path + "Tests/" + main.TEST + ".params" + ""
-        logmsg = logmsg + "\n\tTopology : " + path + "Tests/" + main.TEST + ".topo" + ""
+        logmsg = logmsg + "\n\tTest Script : " + main.testFile + ""
+        logmsg = logmsg + "\n\tTest Params : " + main.testDir + "/" +  main.paramsFile + ""
+        logmsg = logmsg + "\n\tTopology : " + main.testDir + "/" + main.topoFile + ""
         logmsg = logmsg + "\n" + " " * 30 + "+" + "-" * 18 + "+" + "\n" + "-" * 27 + "  { Script Exec Params }  " + "-" * 27 + "\n" + " " * 30 + "+" + "-" * 18 + "+\n"
         values = "\n\t" + str( main.params )
         values = re.sub( ",", "\n\t", values )
diff --git a/TestON/core/teston.py b/TestON/core/teston.py
index 6794564..19449f4 100644
--- a/TestON/core/teston.py
+++ b/TestON/core/teston.py
@@ -90,6 +90,7 @@
         self.test_target = None
         self.lastcommand = None
         self.testDir = tests_path
+        self.testsRoot = tests_path
         self.configFile = config_path + "teston.cfg"
         self.parsingClass = "xmlparser"
         self.parserPath = core_path + "/xmlparser"
@@ -935,6 +936,7 @@
                         main.classPath = directory[ index: ].replace( '/', '.' ) + "." + main.TEST
                         break
     openspeakfile = directory + "/" + main.TEST + ".ospk"
+    main.testDir = directory
     main.testFile = directory + "/" + main.TEST + ".py"
     if os.path.exists( openspeakfile ):
         # Openspeak file found, compiling to python
@@ -962,8 +964,10 @@
     testClass = getattr( testModule, main.TEST )
     main.testObject = testClass()
     load_parser()
-    main.params = main.parser.parseParams( main.classPath )
-    main.topology = main.parser.parseTopology( main.classPath )
+    main.paramsFile = main.TEST + ".params" if options.paramsFile is None else options.paramsFile
+    main.topoFile = main.TEST + ".topo" if options.topoFile is None else options.topoFile
+    main.params = main.parser.parseFile( main.testDir + "/" + main.paramsFile )
+    main.topology = main.parser.parseFile( main.testDir + "/" + main.topoFile )
 
 def verifyParams( options ):
     try:
@@ -1039,8 +1043,7 @@
                                             -1 )
                 parsingClass = getattr( parsingModule, parsingClass )
                 main.parser = parsingClass()
-                if hasattr( main.parser, "parseParams" ) and\
-                   hasattr( main.parser, "parseTopology" ) and\
+                if hasattr( main.parser, "parseFile" ) and\
                    hasattr( main.parser, "parse" ):
                     pass
                 else:
@@ -1072,8 +1075,7 @@
                                     -1 )
         parsingClass = getattr( parsingModule, parsingClass )
         main.parser = parsingClass()
-        if hasattr( main.parser, "parseParams" ) and\
-           hasattr( main.parser, "parseTopology" ) and\
+        if hasattr( main.parser, "parseFile" ) and\
            hasattr( main.parser, "parse" ):
             pass
         else:
diff --git a/TestON/core/xmlparser.py b/TestON/core/xmlparser.py
index 12a3f61..d7af564 100644
--- a/TestON/core/xmlparser.py
+++ b/TestON/core/xmlparser.py
@@ -27,6 +27,7 @@
 
 import xmldict
 import re
+import os.path
 
 class xmlparser:
 
@@ -49,23 +50,10 @@
         else:
             print "File name is not correct"
 
-    def parseParams( self, paramsPath ):
+    def parseFile( self, fileName ):
         '''
-         It will take the params file path and will return the params dictionary
+         It will take a file path of an xml file and return the contents as a dictionary
         '''
-        paramsPath = re.sub( "\.", "/", paramsPath )
-        paramsPath = re.sub( "tests|examples", "", paramsPath )
-        params = self.parse( main.tests_path + paramsPath + ".params" )
-        paramsAsString = str( params )
-        return eval( paramsAsString )
-
-    def parseTopology( self, topologyPath ):
-        '''
-          It will take topology file path and will return topology dictionary
-        '''
-        topologyPath = re.sub( "\.", "/", topologyPath )
-        topologyPath = re.sub( "tests|examples", "", topologyPath )
-        topology = self.parse( main.tests_path + topologyPath + ".topo" )
-        topoAsString = str( topology )
-        return eval( topoAsString )
+        contents = self.parse( fileName )
+        return eval( str( contents ) )