def do_do(self, line): ''' Do will translate and execute the openspeak statement for the paused test. do <OpenSpeak statement> ''' if testthread: from core import openspeak ospk = openspeak.OpenSpeak() try: translated_code = ospk.interpret(text=line) eval(translated_code) except (AttributeError, SyntaxError), e: print 'Dynamic params are not allowed in single statement translations'
def do_interpret(self,line): ''' interpret will translate the single line openspeak statement to equivalent python script. teston> interpret ASSERT result EQUALS main.TRUE ONPASS "Ping executed successfully" ONFAIL "Ping failed" utilities.assert_equals(expect=main.TRUE,actual=result,onpass="******",onfail="Ping failed") ''' from core import openspeak ospk = openspeak.OpenSpeak() try : translated_code = ospk.interpret(text=line) print translated_code except AttributeError as e: print 'Dynamic params are not allowed in single statement translations'
def do_compile(self,line): ''' compile will translate the openspeak (.ospk) file into TestON test script (python). It will receive the openspeak file path as input and will generate equivalent test-script file in the same directory. usage: ----- teston>compile /home/openflow/TestON/PoxTest.ospk Auto-generated test-script file is /home/openflow/TestON/PoxTest.py ''' from core import openspeak openspeak = openspeak.OpenSpeak() openspeakfile = line if os.path.exists(openspeakfile) : openspeak.compiler(openspeakfile=openspeakfile,writetofile=1) print "Auto-generated test-script file is "+ re.sub("ospk","py",openspeakfile,0) else: print 'There is no such file : '+line