admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | ''' |
| 3 | Created on 22-Oct-2012 |
Jon Hall | 65844a3 | 2015-03-09 19:09:37 -0700 | [diff] [blame] | 4 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 5 | @author: Anil Kumar (anilkumar.s@paxterrasolutions.com) |
| 6 | |
| 7 | |
| 8 | TestON is free software: you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation, either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | TestON is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
Jon Hall | 65844a3 | 2015-03-09 19:09:37 -0700 | [diff] [blame] | 19 | along with TestON. If not, see <http://www.gnu.org/licenses/>. |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 20 | |
| 21 | |
| 22 | |
| 23 | teston is the main module. |
| 24 | |
| 25 | ''' |
| 26 | |
| 27 | import sys |
| 28 | import getpass |
| 29 | import os |
| 30 | import re |
| 31 | import __builtin__ |
| 32 | import new |
| 33 | import xmldict |
Jon Hall | 30b82fa | 2015-03-04 17:15:43 -0800 | [diff] [blame] | 34 | import importlib |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 35 | module = new.module("test") |
| 36 | import openspeak |
| 37 | global path, drivers_path, core_path, tests_path,logs_path |
| 38 | path = re.sub("(core|bin)$", "", os.getcwd()) |
| 39 | drivers_path = path+"drivers/" |
| 40 | core_path = path+"core" |
| 41 | tests_path = path+"tests" |
| 42 | logs_path = path+"logs/" |
| 43 | config_path = path + "config/" |
| 44 | sys.path.append(path) |
| 45 | sys.path.append( drivers_path) |
| 46 | sys.path.append(core_path ) |
| 47 | sys.path.append(tests_path) |
| 48 | |
| 49 | from core.utilities import Utilities |
kelvin-onlab | fb52166 | 2015-02-27 09:52:40 -0800 | [diff] [blame] | 50 | from core.Thread import Thread |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 51 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 52 | |
| 53 | class TestON: |
| 54 | ''' |
| 55 | |
| 56 | TestON will initiate the specified test. |
| 57 | The main tasks are : |
| 58 | * Initiate the required Component handles for the test. |
| 59 | * Create Log file Handles. |
| 60 | |
| 61 | ''' |
| 62 | def __init__(self,options): |
| 63 | ''' |
| 64 | Initialise the component handles specified in the topology file of the specified test. |
| 65 | |
| 66 | ''' |
| 67 | # Initialization of the variables. |
| 68 | __builtin__.main = self |
Jon Hall | a118598 | 2014-09-15 14:55:10 -0700 | [diff] [blame] | 69 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 70 | __builtin__.path = path |
| 71 | __builtin__.utilities = Utilities() |
| 72 | self.TRUE = 1 |
| 73 | self.FALSE = 0 |
| 74 | self.ERROR = -1 |
| 75 | self.FAIL = False |
| 76 | self.PASS = True |
| 77 | self.CASERESULT = self.TRUE |
| 78 | self.init_result = self.TRUE |
| 79 | self.testResult = "Summary" |
| 80 | self.stepName ="" |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 81 | self.EXPERIMENTAL_MODE = False |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 82 | self.test_target = None |
| 83 | self.lastcommand = None |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 84 | self.testDir = tests_path |
| 85 | self.configFile = config_path + "teston.cfg" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 86 | self.parsingClass = "xmlparser" |
| 87 | self.parserPath = core_path + "/xmlparser" |
| 88 | self.loggerPath = core_path + "/logger" |
| 89 | self.loggerClass = "Logger" |
| 90 | self.logs_path = logs_path |
| 91 | self.driver = '' |
kelvin-onlab | fb52166 | 2015-02-27 09:52:40 -0800 | [diff] [blame] | 92 | self.Thread = Thread |
Jon Hall | 65844a3 | 2015-03-09 19:09:37 -0700 | [diff] [blame] | 93 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 94 | self.configparser() |
| 95 | verifyOptions(options) |
| 96 | load_logger() |
| 97 | self.componentDictionary = {} |
| 98 | self.componentDictionary = self.topology ['COMPONENT'] |
| 99 | self.driversList=[] |
| 100 | if type(self.componentDictionary) == str : |
| 101 | self.componentDictionary = dict(self.componentDictionary) |
Jon Hall | 65844a3 | 2015-03-09 19:09:37 -0700 | [diff] [blame] | 102 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 103 | for component in self.componentDictionary : |
| 104 | self.driversList.append(self.componentDictionary[component]['type']) |
Jon Hall | 65844a3 | 2015-03-09 19:09:37 -0700 | [diff] [blame] | 105 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 106 | self.driversList = list(set(self.driversList)) # Removing duplicates. |
| 107 | # Checking the test_target option set for the component or not |
| 108 | if type(self.componentDictionary) == dict: |
| 109 | for component in self.componentDictionary.keys(): |
| 110 | if 'test_target' in self.componentDictionary[component].keys(): |
| 111 | self.test_target = component |
Jon Hall | 65844a3 | 2015-03-09 19:09:37 -0700 | [diff] [blame] | 112 | |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 113 | # Checking for the openspeak file and test script |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 114 | self.logger.initlog(self) |
| 115 | |
| 116 | # Creating Drivers Handles |
| 117 | initString = "\n"+"*" * 30+"\n CASE INIT \n"+"*" * 30+"\n" |
| 118 | self.log.exact(initString) |
| 119 | self.driverObject = {} |
| 120 | self.random_order = 111 # Random order id to connect the components |
| 121 | components_connect_order = {} |
| 122 | #component_list.append() |
| 123 | if type(self.componentDictionary) == dict: |
| 124 | for component in self.componentDictionary.keys(): |
| 125 | self.componentDictionary[component]['connect_order'] = self.componentDictionary[component]['connect_order'] if ('connect_order' in self.componentDictionary[component].keys()) else str(self.get_random()) |
| 126 | components_connect_order[component] = eval(self.componentDictionary[component]['connect_order']) |
| 127 | #Ordering components based on the connect order. |
| 128 | ordered_component_list =sorted(components_connect_order, key=lambda key: components_connect_order[key]) |
| 129 | print ordered_component_list |
| 130 | |
| 131 | for component in ordered_component_list: |
| 132 | self.componentInit(component) |
| 133 | |
| 134 | def configparser(self): |
| 135 | ''' |
| 136 | It will parse the config file (teston.cfg) and return as dictionary |
| 137 | ''' |
| 138 | matchFileName = re.match(r'(.*)\.cfg', self.configFile, re.M | re.I) |
| 139 | if matchFileName: |
| 140 | xml = open(self.configFile).read() |
| 141 | try : |
| 142 | self.configDict = xmldict.xml_to_dict(xml) |
| 143 | return self.configDict |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 144 | except Exception: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 145 | print "There is no such file to parse " + self.configFile |
| 146 | |
| 147 | def componentInit(self,component): |
| 148 | ''' |
| 149 | This method will initialize specified component |
| 150 | ''' |
| 151 | global driver_options |
| 152 | self.log.info("Creating component Handle: "+component) |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 153 | driver_options = {} |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 154 | if 'COMPONENTS' in self.componentDictionary[component].keys(): |
| 155 | driver_options =dict(self.componentDictionary[component]['COMPONENTS']) |
| 156 | |
| 157 | driver_options['name']=component |
| 158 | driverName = self.componentDictionary[component]['type'] |
| 159 | driver_options ['type'] = driverName |
| 160 | |
| 161 | classPath = self.getDriverPath(driverName.lower()) |
Jon Hall | 30b82fa | 2015-03-04 17:15:43 -0800 | [diff] [blame] | 162 | driverModule = importlib.import_module(classPath) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 163 | driverClass = getattr(driverModule, driverName) |
| 164 | driverObject = driverClass() |
| 165 | |
| 166 | connect_result = driverObject.connect(user_name = self.componentDictionary[component]['user'] if ('user' in self.componentDictionary[component].keys()) else getpass.getuser(), |
| 167 | ip_address= self.componentDictionary[component]['host'] if ('host' in self.componentDictionary[component].keys()) else 'localhost', |
| 168 | pwd = self.componentDictionary[component]['password'] if ('password' in self.componentDictionary[component].keys()) else 'changeme', |
| 169 | port = self.componentDictionary[component]['port'] if ('port' in self.componentDictionary[component].keys()) else None, |
| 170 | options = driver_options) |
| 171 | if not connect_result: |
| 172 | self.log.error("Exiting form the test execution because the connecting to the "+component+" component failed.") |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 173 | self.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 174 | |
| 175 | vars(self)[component] = driverObject |
| 176 | |
| 177 | def run(self): |
| 178 | ''' |
| 179 | The Execution of the test script's cases listed in the Test params file will be done here. |
| 180 | And Update each test case result. |
| 181 | This method will return TRUE if it executed all the test cases successfully, |
| 182 | else will retun FALSE |
| 183 | ''' |
| 184 | |
| 185 | self.testCaseResult = {} |
Jon Hall | a118598 | 2014-09-15 14:55:10 -0700 | [diff] [blame] | 186 | self.TOTAL_TC = 0 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 187 | self.TOTAL_TC_RUN = 0 |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 188 | self.TOTAL_TC_PLANNED = 0 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 189 | self.TOTAL_TC_NORESULT = 0 |
| 190 | self.TOTAL_TC_FAIL = 0 |
| 191 | self.TOTAL_TC_PASS = 0 |
Jon Hall | a118598 | 2014-09-15 14:55:10 -0700 | [diff] [blame] | 192 | self.TEST_ITERATION = 0 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 193 | self.stepCount = 0 |
| 194 | self.CASERESULT = self.TRUE |
| 195 | |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 196 | import testparser |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 197 | testFile = self.tests_path + "/"+self.TEST + "/"+self.TEST + ".py" |
| 198 | test = testparser.TestParser(testFile) |
| 199 | self.testscript = test.testscript |
| 200 | self.code = test.getStepCode() |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 201 | repeat= int(self.params['repeat']) if ('repeat' in self.params) else 1 |
| 202 | self.TOTAL_TC_PLANNED = len(self.testcases_list)*repeat |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 203 | |
| 204 | result = self.TRUE |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 205 | while(repeat): |
Jon Hall | a118598 | 2014-09-15 14:55:10 -0700 | [diff] [blame] | 206 | for self.CurrentTestCaseNumber in self.testcases_list: |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 207 | result = self.runCase(self.CurrentTestCaseNumber) |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 208 | repeat-=1 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 209 | return result |
| 210 | |
| 211 | def runCase(self,testCaseNumber): |
| 212 | self.CurrentTestCaseNumber = testCaseNumber |
| 213 | result = self.TRUE |
| 214 | self.stepCount = 0 |
| 215 | self.EXPERIMENTAL_MODE = self.FALSE |
| 216 | self.addCaseHeader() |
| 217 | self.testCaseNumber = str(testCaseNumber) |
| 218 | stopped = False |
| 219 | try : |
| 220 | self.stepList = self.code[self.testCaseNumber].keys() |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 221 | except KeyError: |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 222 | self.log.error("There is no Test-Case "+ self.testCaseNumber) |
| 223 | return self.FALSE |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 224 | |
| 225 | self.stepCount = 0 |
| 226 | while self.stepCount < len(self.code[self.testCaseNumber].keys()): |
| 227 | result = self.runStep(self.stepList,self.code,self.testCaseNumber) |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 228 | if result == self.FALSE: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 229 | break |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 230 | elif result == self.TRUE: |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 231 | continue |
| 232 | |
| 233 | if not stopped : |
| 234 | self.testCaseResult[str(self.CurrentTestCaseNumber)] = self.CASERESULT |
| 235 | self.logger.updateCaseResults(self) |
| 236 | return result |
| 237 | |
| 238 | def runStep(self,stepList,code,testCaseNumber): |
| 239 | if not cli.pause: |
| 240 | try : |
| 241 | step = stepList[self.stepCount] |
| 242 | exec code[testCaseNumber][step] in module.__dict__ |
| 243 | self.stepCount = self.stepCount + 1 |
| 244 | except TypeError,e: |
Jon Hall | 6360493 | 2015-02-26 17:09:50 -0800 | [diff] [blame] | 245 | print "Exception in the following section of code: Test Step " +\ |
| 246 | str(testCaseNumber) + "." + str(step) + " ):" |
| 247 | #print code[testCaseNumber][step] |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 248 | self.stepCount = self.stepCount + 1 |
Jon Hall | 30b82fa | 2015-03-04 17:15:43 -0800 | [diff] [blame] | 249 | self.log.exception(e) |
shahshreya | 957feaa | 2015-03-23 16:08:29 -0700 | [diff] [blame] | 250 | self.cleanup() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 251 | return main.TRUE |
| 252 | |
| 253 | if cli.stop: |
| 254 | cli.stop = False |
| 255 | stopped = True |
| 256 | self.TOTAL_TC_NORESULT = self.TOTAL_TC_NORESULT + 1 |
| 257 | self.testCaseResult[str(self.CurrentTestCaseNumber)] = "Stopped" |
| 258 | self.logger.updateCaseResults(self) |
| 259 | result = self.cleanup() |
| 260 | return main.FALSE |
| 261 | |
| 262 | def addCaseHeader(self): |
| 263 | caseHeader = "\n"+"*" * 30+"\n Result summary for Testcase"+str(self.CurrentTestCaseNumber)+"\n"+"*" * 30+"\n" |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 264 | self.log.exact(caseHeader) |
| 265 | caseHeader = "\n"+"*" * 40 +"\nStart of Test Case"+str(self.CurrentTestCaseNumber)+" : " |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 266 | for driver in self.componentDictionary.keys(): |
| 267 | vars(self)[driver+'log'].info(caseHeader) |
| 268 | |
| 269 | def addCaseFooter(self): |
| 270 | if self.stepCount-1 > 0 : |
| 271 | previousStep = " "+str(self.CurrentTestCaseNumber)+"."+str(self.stepCount-1)+": "+ str(self.stepName) + "" |
| 272 | stepHeader = "\n"+"*" * 40+"\nEnd of Step "+previousStep+"\n"+"*" * 40+"\n" |
| 273 | |
| 274 | caseFooter = "\n"+"*" * 40+"\nEnd of Test case "+str(self.CurrentTestCaseNumber)+"\n"+"*" * 40+"\n" |
| 275 | |
| 276 | for driver in self.driversList: |
| 277 | vars(self)[driver].write(stepHeader+"\n"+caseFooter) |
| 278 | |
| 279 | def cleanup(self): |
| 280 | ''' |
| 281 | Release all the component handles and the close opened file handles. |
| 282 | This will return TRUE if all the component handles and log handles closed properly, |
| 283 | else return FALSE |
| 284 | |
| 285 | ''' |
| 286 | result = self.TRUE |
| 287 | self.logger.testSummary(self) |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 288 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 289 | #self.reportFile.close() |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 290 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 291 | |
admin | 2c7034f | 2013-08-02 15:09:17 -0700 | [diff] [blame] | 292 | #utilities.send_mail() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 293 | try : |
| 294 | for component in self.componentDictionary.keys(): |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 295 | tempObject = vars(self)[component] |
| 296 | print "Disconnecting " + str(tempObject) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 297 | tempObject.disconnect() |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 298 | #tempObject.execute(cmd="exit",prompt="(.*)",timeout=120) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 299 | |
| 300 | except(Exception): |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 301 | self.log.exception( "Exception while disconnecting from " + |
| 302 | str( component ) ) |
Jon Hall | a118598 | 2014-09-15 14:55:10 -0700 | [diff] [blame] | 303 | #print " There is an error with closing hanldes" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 304 | result = self.FALSE |
| 305 | # Closing all the driver's session files |
| 306 | for driver in self.componentDictionary.keys(): |
| 307 | vars(self)[driver].close_log_handles() |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 308 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 309 | return result |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 310 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 311 | def pause(self): |
| 312 | ''' |
| 313 | This function will pause the test's execution, and will continue after user provide 'resume' command. |
| 314 | ''' |
| 315 | __builtin__.testthread.pause() |
| 316 | |
| 317 | def onfail(self,*components): |
| 318 | ''' |
| 319 | When test step failed, calling all the components onfail. |
| 320 | ''' |
| 321 | |
| 322 | if not components: |
| 323 | try : |
| 324 | for component in self.componentDictionary.keys(): |
| 325 | tempObject = vars(self)[component] |
| 326 | result = tempObject.onfail() |
| 327 | except(Exception),e: |
| 328 | print str(e) |
| 329 | result = self.FALSE |
| 330 | |
| 331 | else: |
| 332 | try : |
| 333 | for component in components: |
| 334 | tempObject = vars(self)[component] |
| 335 | result = tempObject.onfail() |
| 336 | except(Exception),e: |
| 337 | print str(e) |
| 338 | result = self.FALSE |
| 339 | |
| 340 | |
| 341 | def getDriverPath(self,driverName): |
| 342 | ''' |
| 343 | Based on the component 'type' specified in the params , this method will find the absolute path , |
| 344 | by recursively searching the name of the component. |
| 345 | ''' |
| 346 | import commands |
| 347 | |
| 348 | cmd = "find "+drivers_path+" -name "+driverName+".py" |
| 349 | result = commands.getoutput(cmd) |
| 350 | |
| 351 | result_array = str(result).split('\n') |
| 352 | result_count = 0 |
| 353 | |
| 354 | for drivers_list in result_array: |
| 355 | result_count = result_count+1 |
| 356 | if result_count > 1 : |
| 357 | print "found "+driverName+" "+ str(result_count) + " times"+str(result_array) |
| 358 | self.exit() |
| 359 | |
| 360 | result = re.sub("(.*)drivers","",result) |
| 361 | result = re.sub("\.py","",result) |
| 362 | result = re.sub("\.pyc","",result) |
| 363 | result = re.sub("\/",".",result) |
| 364 | result = "drivers"+result |
| 365 | return result |
| 366 | |
| 367 | |
| 368 | def step(self,stepDesc): |
| 369 | ''' |
| 370 | The step information of the test-case will append to the logs. |
| 371 | ''' |
| 372 | previousStep = " "+str(self.CurrentTestCaseNumber)+"."+str(self.stepCount-1)+": "+ str(self.stepName) + "" |
| 373 | self.stepName = stepDesc |
| 374 | |
| 375 | stepName = " "+str(self.CurrentTestCaseNumber)+"."+str(self.stepCount)+": "+ str(stepDesc) + "" |
| 376 | try : |
| 377 | if self.stepCount == 0: |
| 378 | stepName = " INIT : Initializing the test case :"+self.CurrentTestCase |
| 379 | except AttributeError: |
| 380 | stepName = " INIT : Initializing the test case :"+str(self.CurrentTestCaseNumber) |
| 381 | |
| 382 | self.log.step(stepName) |
| 383 | stepHeader = "" |
| 384 | if self.stepCount > 1 : |
| 385 | stepHeader = "\n"+"-"*45+"\nEnd of Step "+previousStep+"\n"+"-"*45+"\n" |
| 386 | |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 387 | stepHeader += "\n"+"-"*45+"\nStart of Step"+stepName+"\n"+"-"*45+"\n" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 388 | for driver in self.componentDictionary.keys(): |
| 389 | vars(self)[driver+'log'].info(stepHeader) |
| 390 | |
| 391 | def case(self,testCaseName): |
| 392 | ''' |
| 393 | Test's each test-case information will append to the logs. |
| 394 | ''' |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 395 | self.CurrentTestCase = testCaseName |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 396 | testCaseName = " " + str(testCaseName) + "" |
| 397 | self.log.case(testCaseName) |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 398 | caseHeader = testCaseName+"\n"+"*" * 40+"\n" |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 399 | for driver in self.componentDictionary.keys(): |
| 400 | vars(self)[driver+'log'].info(caseHeader) |
| 401 | |
| 402 | def testDesc(self,description): |
| 403 | ''' |
| 404 | Test description will append to the logs. |
| 405 | ''' |
| 406 | description = "Test Description : " + str (description) + "" |
| 407 | self.log.info(description) |
| 408 | |
| 409 | def _getTest(self): |
| 410 | ''' |
| 411 | This method will parse the test script to find required test information. |
| 412 | ''' |
| 413 | testFile = self.tests_path + "/"+self.TEST + "/"+self.TEST + ".py" |
| 414 | testFileHandler = open(testFile, 'r') |
| 415 | testFileList = testFileHandler.readlines() |
| 416 | testFileHandler.close() |
| 417 | #self.TOTAL_TC_PLANNED = 0 |
| 418 | counter = 0 |
| 419 | for index in range(len(testFileList)): |
| 420 | lineMatch = re.match('\s+def CASE(\d+)(.*):',testFileList[index],0) |
| 421 | if lineMatch: |
| 422 | counter = counter + 1 |
Jon Hall | a118598 | 2014-09-15 14:55:10 -0700 | [diff] [blame] | 423 | self.TC_PLANNED = len(self.testcases_list) |
| 424 | |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 425 | |
| 426 | def response_parser(self,response, return_format): |
| 427 | ''' It will load the default response parser ''' |
| 428 | response_dict = {} |
| 429 | response_dict = self.response_to_dict(response, return_format) |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 430 | return_format_string = self.dict_to_return_format(response,return_format,response_dict) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 431 | return return_format_string |
| 432 | |
| 433 | def response_to_dict(self,response,return_format): |
| 434 | |
| 435 | response_dict = {} |
| 436 | json_match = re.search('^\s*{', response) |
| 437 | xml_match = re.search('^\s*\<', response) |
| 438 | ini_match = re.search('^\s*\[', response) |
| 439 | if json_match : |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 440 | self.log.info(" Response is in 'JSON' format and Converting to '"+return_format+"' format") |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 441 | # Formatting the json string |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 442 | |
| 443 | response = re.sub(r"{\s*'?(\w)", r'{"\1', response) |
| 444 | response = re.sub(r",\s*'?(\w)", r',"\1', response) |
| 445 | response = re.sub(r"(\w)'?\s*:", r'\1":', response) |
| 446 | response = re.sub(r":\s*'(\w)'\s*([,}])", r':"\1"\2', response) |
| 447 | |
| 448 | try : |
| 449 | import json |
| 450 | response_dict = json.loads(response) |
Jon Hall | 30b82fa | 2015-03-04 17:15:43 -0800 | [diff] [blame] | 451 | except Exception, e: |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 452 | self.log.exception( e ) |
| 453 | self.log.error("Json Parser is unable to parse the string") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 454 | return response_dict |
| 455 | |
| 456 | elif ini_match : |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 457 | self.log.info(" Response is in 'INI' format and Converting to '"+return_format+"' format") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 458 | from configobj import ConfigObj |
| 459 | response_file = open("respnse_file.temp",'w') |
| 460 | response_file.write(response) |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 461 | response_file.close() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 462 | response_dict = ConfigObj("respnse_file.temp") |
| 463 | return response_dict |
| 464 | |
| 465 | elif xml_match : |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 466 | self.log.info(" Response is in 'XML' format and Converting to '"+return_format+"' format") |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 467 | try : |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 468 | response_dict = xmldict.xml_to_dict("<response> "+str(response)+" </response>") |
| 469 | except Exception, e: |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 470 | self.log.exception( e ) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 471 | return response_dict |
| 472 | |
| 473 | def dict_to_return_format(self,response,return_format,response_dict): |
| 474 | |
| 475 | if return_format =='table' : |
| 476 | ''' Will return in table format''' |
| 477 | to_do = "Call the table output formatter" |
| 478 | global response_table |
| 479 | response_table = '\n' |
| 480 | response_table = response_table +'\t'.join(response_dict)+"\n" |
| 481 | |
| 482 | def get_table(value_to_convert): |
| 483 | ''' This will parse the dictionary recusrsively and print as table format''' |
| 484 | table_data = "" |
| 485 | if type(value_to_convert) == dict : |
| 486 | table_data = table_data +'\t'.join(value_to_convert)+"\n" |
| 487 | for temp_val in value_to_convert.values() : |
| 488 | table_data = table_data + get_table(temp_val) |
| 489 | else : |
| 490 | table_data = table_data + str(value_to_convert) +"\t" |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 491 | return table_data |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 492 | |
| 493 | for value in response_dict.values() : |
| 494 | response_table = response_table + get_table(value) |
| 495 | |
| 496 | |
| 497 | |
Jon Hall | 88e498c | 2015-03-06 09:54:35 -0800 | [diff] [blame] | 498 | # response_table = response_table + '\t'.join(response_dict.values()) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 499 | |
| 500 | return response_table |
| 501 | |
| 502 | elif return_format =='config': |
| 503 | ''' Will return in config format''' |
| 504 | to_do = 'Call dict to config coverter' |
| 505 | response_string = str(response_dict) |
| 506 | print response_string |
| 507 | response_config = re.sub(",", "\n\t", response_string) |
| 508 | response_config = re.sub("u\'", "\'", response_config) |
| 509 | response_config = re.sub("{", "", response_config) |
| 510 | response_config = re.sub("}", "\n", response_config) |
| 511 | response_config = re.sub(":", " =", response_config) |
| 512 | return "[response]\n\t "+response_config |
| 513 | |
| 514 | elif return_format == 'xml': |
| 515 | ''' Will return in xml format''' |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 516 | response_xml = xmldict.dict_to_xml(response_dict) |
| 517 | response_xml = re.sub(">\s*<", ">\n<", response_xml) |
| 518 | return "\n"+response_xml |
| 519 | |
| 520 | elif return_format == 'json': |
| 521 | ''' Will return in json format''' |
| 522 | to_do = 'Call dict to xml coverter' |
| 523 | import json |
| 524 | response_json = json.dumps(response_dict) |
| 525 | return response_json |
| 526 | |
| 527 | def get_random(self): |
| 528 | self.random_order = self.random_order + 1 |
| 529 | return self.random_order |
| 530 | |
| 531 | def exit(self): |
| 532 | __builtin__.testthread = None |
| 533 | sys.exit() |
| 534 | |
| 535 | def verifyOptions(options): |
| 536 | ''' |
| 537 | This will verify the command line options and set to default values, if any option not given in command line. |
| 538 | ''' |
| 539 | import pprint |
| 540 | pp = pprint.PrettyPrinter(indent=4) |
| 541 | |
Jon Hall | 88e498c | 2015-03-06 09:54:35 -0800 | [diff] [blame] | 542 | # pp.pprint(options) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 543 | verifyTest(options) |
| 544 | verifyExample(options) |
| 545 | verifyTestScript(options) |
| 546 | verifyParams() |
| 547 | verifyLogdir(options) |
| 548 | verifyMail(options) |
| 549 | verifyTestCases(options) |
| 550 | |
| 551 | def verifyTest(options): |
| 552 | if options.testname: |
| 553 | main.TEST = options.testname |
| 554 | main.classPath = "tests."+main.TEST+"."+main.TEST |
| 555 | main.tests_path = tests_path |
| 556 | elif options.example : |
| 557 | main.TEST = options.example |
| 558 | main.tests_path = path+"/examples/" |
| 559 | main.classPath = "examples."+main.TEST+"."+main.TEST |
| 560 | else : |
| 561 | print "Test or Example not specified please specify the --test <test name > or --example <example name>" |
| 562 | self.exit() |
| 563 | |
| 564 | def verifyExample(options): |
| 565 | if options.example: |
| 566 | main.testDir = path+'/examples/' |
| 567 | main.tests_path = path+"/examples/" |
| 568 | main.classPath = "examples."+main.TEST+"."+main.TEST |
| 569 | |
| 570 | def verifyLogdir(options): |
Jon Hall | 88e498c | 2015-03-06 09:54:35 -0800 | [diff] [blame] | 571 | # Verifying Log directory option |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 572 | if options.logdir: |
| 573 | main.logdir = options.logdir |
| 574 | else : |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 575 | main.logdir = main.FALSE |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 576 | |
| 577 | def verifyMail(options): |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 578 | # Checking the mailing list |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 579 | if options.mail: |
| 580 | main.mail = options.mail |
| 581 | elif main.params.has_key('mail'): |
| 582 | main.mail = main.params['mail'] |
| 583 | else : |
| 584 | main.mail = 'paxweb@paxterrasolutions.com' |
| 585 | |
| 586 | def verifyTestCases(options): |
Jon Hall | 88e498c | 2015-03-06 09:54:35 -0800 | [diff] [blame] | 587 | # Getting Test cases list |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 588 | if options.testcases: |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 589 | testcases_list = options.testcases |
Jon Hall | 88e498c | 2015-03-06 09:54:35 -0800 | [diff] [blame] | 590 | # sys.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 591 | testcases_list = re.sub("(\[|\])", "", options.testcases) |
| 592 | main.testcases_list = eval(testcases_list+",") |
| 593 | else : |
| 594 | if 'testcases' in main.params.keys(): |
Jon Hall | a118598 | 2014-09-15 14:55:10 -0700 | [diff] [blame] | 595 | temp = eval(main.params['testcases']+",") |
| 596 | list1=[] |
| 597 | if type(temp[0])==list: |
Jon Hall | febb1c7 | 2015-03-05 13:30:09 -0800 | [diff] [blame] | 598 | for test in temp: |
| 599 | for testcase in test: |
| 600 | if type(testcase)==int: |
| 601 | testcase=[testcase] |
| 602 | list1.extend(testcase) |
| 603 | else : |
| 604 | temp=list(temp) |
| 605 | for testcase in temp: |
| 606 | if type(testcase)==int: |
| 607 | testcase=[testcase] |
| 608 | list1.extend(testcase) |
| 609 | main.testcases_list=list1 |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 610 | else : |
| 611 | print "testcases not specifed in params, please provide in params file or 'testcases' commandline argument" |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 612 | sys.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 613 | |
| 614 | def verifyTestScript(options): |
| 615 | ''' |
| 616 | Verifyies test script. |
| 617 | ''' |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 618 | main.openspeak = openspeak.OpenSpeak() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 619 | openspeakfile = main.testDir+"/" + main.TEST + "/" + main.TEST + ".ospk" |
| 620 | testfile = main.testDir+"/" + main.TEST + "/" + main.TEST + ".py" |
| 621 | if os.path.exists(openspeakfile) : |
| 622 | main.openspeak.compiler(openspeakfile=openspeakfile,writetofile=1) |
| 623 | elif os.path.exists(testfile): |
| 624 | print '' |
| 625 | else: |
| 626 | print "\nThere is no :\""+main.TEST+"\" test, Please Provide OpenSpeak Script/ test script" |
| 627 | __builtin__.testthread = None |
| 628 | main.exit() |
| 629 | |
| 630 | try : |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 631 | testModule = __import__(main.classPath, globals(), locals(), [main.TEST], -1) |
| 632 | except(ImportError): |
Jon Hall | f8ecf73 | 2014-12-02 21:14:16 -0500 | [diff] [blame] | 633 | print "There was an import error, it might mean that there is no test like "+main.TEST |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 634 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 635 | |
| 636 | testClass = getattr(testModule, main.TEST) |
| 637 | main.testObject = testClass() |
| 638 | load_parser() |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 639 | main.params = main.parser.parseParams(main.classPath) |
| 640 | main.topology = main.parser.parseTopology(main.classPath) |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 641 | |
| 642 | def verifyParams(): |
| 643 | try : |
| 644 | main.params = main.params['PARAMS'] |
| 645 | except(KeyError): |
| 646 | print "Error with the params file: Either the file not specified or the format is not correct" |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 647 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 648 | |
| 649 | try : |
| 650 | main.topology = main.topology['TOPOLOGY'] |
| 651 | except(KeyError): |
| 652 | print "Error with the Topology file: Either the file not specified or the format is not correct" |
| 653 | main.exit() |
| 654 | |
| 655 | def load_parser() : |
| 656 | ''' |
| 657 | It facilitates the loading customised parser for topology and params file. |
| 658 | It loads parser mentioned in tab named parser of teston.cfg file. |
| 659 | It also loads default xmlparser if no parser have specified in teston.cfg file. |
| 660 | |
| 661 | ''' |
| 662 | confighash = main.configDict |
| 663 | if 'file' in confighash['config']['parser'] and 'class' in confighash['config']['parser']: |
| 664 | if confighash['config']['parser']['file'] != None or confighash['config']['parser']['class']!= None : |
| 665 | if os.path.exists(confighash['config']['parser']['file']) : |
| 666 | module = re.sub(r".py\s*$","",confighash['config']['parser']['file']) |
| 667 | moduleList = module.split("/") |
| 668 | newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]]) |
| 669 | try : |
| 670 | parsingClass = confighash['config']['parser']['class'] |
| 671 | parsingModule = __import__(newModule, globals(), locals(), [parsingClass], -1) |
| 672 | parsingClass = getattr(parsingModule, parsingClass) |
| 673 | main.parser = parsingClass() |
| 674 | #hashobj = main.parser.parseParams(main.classPath) |
| 675 | if hasattr(main.parser,"parseParams") and hasattr(main.parser,"parseTopology") and hasattr(main.parser,"parse") : |
| 676 | |
| 677 | pass |
| 678 | else: |
| 679 | main.exit() |
| 680 | |
| 681 | except ImportError: |
| 682 | print sys.exc_info()[1] |
| 683 | main.exit() |
| 684 | else : |
| 685 | print "No Such File Exists !!"+ confighash['config']['parser']['file'] +"using default parser" |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 686 | load_defaultParser() |
| 687 | elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None : |
| 688 | load_defaultParser() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 689 | else: |
| 690 | load_defaultParser() |
| 691 | |
| 692 | def load_defaultParser(): |
| 693 | ''' |
| 694 | It will load the default parser which is xml parser to parse the params and topology file. |
| 695 | ''' |
| 696 | moduleList = main.parserPath.split("/") |
| 697 | newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]]) |
| 698 | try : |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 699 | parsingClass = main.parsingClass |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 700 | parsingModule = __import__(newModule, globals(), locals(), [parsingClass], -1) |
| 701 | parsingClass = getattr(parsingModule, parsingClass) |
| 702 | main.parser = parsingClass() |
| 703 | if hasattr(main.parser,"parseParams") and hasattr(main.parser,"parseTopology") and hasattr(main.parser,"parse") : |
| 704 | pass |
| 705 | else: |
| 706 | main.exit() |
| 707 | |
| 708 | except ImportError: |
| 709 | print sys.exc_info()[1] |
| 710 | |
| 711 | |
| 712 | def load_logger() : |
| 713 | ''' |
| 714 | It facilitates the loading customised parser for topology and params file. |
| 715 | It loads parser mentioned in tab named parser of teston.cfg file. |
| 716 | It also loads default xmlparser if no parser have specified in teston.cfg file. |
| 717 | |
| 718 | ''' |
| 719 | confighash = main.configDict |
| 720 | if 'file' in confighash['config']['logger'] and 'class' in confighash['config']['logger']: |
| 721 | if confighash['config']['logger']['file'] != None or confighash['config']['logger']['class']!= None : |
| 722 | if os.path.exists(confighash['config']['logger']['file']) : |
| 723 | module = re.sub(r".py\s*$","",confighash['config']['logger']['file']) |
| 724 | moduleList = module.split("/") |
| 725 | newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]]) |
| 726 | try : |
| 727 | loggerClass = confighash['config']['logger']['class'] |
| 728 | loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1) |
| 729 | loggerClass = getattr(loggerModule, loggerClass) |
| 730 | main.logger = loggerClass() |
| 731 | #hashobj = main.parser.parseParams(main.classPath) |
| 732 | |
| 733 | except ImportError: |
| 734 | print sys.exc_info()[1] |
| 735 | else : |
| 736 | print "No Such File Exists !!"+confighash['config']['logger']['file']+ "Using default logger" |
| 737 | load_defaultlogger() |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 738 | elif confighash['config']['parser']['file'] == None or confighash['config']['parser']['class'] == None : |
| 739 | load_defaultlogger() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 740 | else: |
| 741 | load_defaultlogger() |
| 742 | |
| 743 | def load_defaultlogger(): |
| 744 | ''' |
| 745 | It will load the default parser which is xml parser to parse the params and topology file. |
| 746 | ''' |
| 747 | moduleList = main.loggerPath.split("/") |
| 748 | newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]]) |
| 749 | try : |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 750 | loggerClass = main.loggerClass |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 751 | loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1) |
| 752 | loggerClass = getattr(loggerModule, loggerClass) |
| 753 | main.logger = loggerClass() |
| 754 | |
| 755 | except ImportError: |
| 756 | print sys.exc_info()[1] |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 757 | main.exit() |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 758 | |
| 759 | def load_defaultlogger(): |
| 760 | ''' |
| 761 | It will load the default parser which is xml parser to parse the params and topology file. |
| 762 | ''' |
| 763 | moduleList = main.loggerPath.split("/") |
| 764 | newModule = ".".join([moduleList[len(moduleList) - 2],moduleList[len(moduleList) - 1]]) |
| 765 | try : |
Jon Hall | d61331b | 2015-02-17 16:35:47 -0800 | [diff] [blame] | 766 | loggerClass = main.loggerClass |
admin | bae64d8 | 2013-08-01 10:50:15 -0700 | [diff] [blame] | 767 | loggerModule = __import__(newModule, globals(), locals(), [loggerClass], -1) |
| 768 | loggerClass = getattr(loggerModule, loggerClass) |
| 769 | main.logger = loggerClass() |
| 770 | |
| 771 | except ImportError: |
| 772 | print sys.exc_info()[1] |
| 773 | main.exit() |
| 774 | |
| 775 | |
| 776 | |
| 777 | |
| 778 | def _echo(self): |
| 779 | print "THIS IS ECHO" |