def getProcessResults(cmd, timeLimit=20):
 output = ''
 startTime = time.time()
 child = pexpect.spawn(cmd, timeout=10)
 child.logfile = sys.stdout
 while 1:
  try:
   output += child.read_nonblocking(timeout=timeLimit).replace('\r', '')
  except pexpect.EOF as e:
   print str(e)
   break
  except pexpect.TIMEOUT as e:
   print str(e)
   output += ('\nProcess aborted by FlashTest after %s seconds.\n' % timeLimit)
   print child.isalive()
   child.kill(9)
   break
 endTime = time.time()
 child.close(force=True)
 duration = (endTime - startTime)
 exitStatus = child.exitstatus
 return (output, duration, exitStatus)

def getProcessResults ( cmd , timeLimit = 20 ) : output = '' startTime = time . time ( ) child = pexpect . spawn ( cmd , timeout = 10 ) child . logfile = sys . stdout while 1 : try : output += child . read_nonblocking ( timeout = timeLimit ) . replace ( '\r' , '' ) except pexpect . EOF as e : print str ( e ) break except pexpect . TIMEOUT as e : print str ( e ) output += ( '\nProcess aborted by FlashTest after %s seconds.\n' % timeLimit ) print child . isalive ( ) child . kill ( 9 ) break endTime = time . time ( ) child . close ( force = True ) duration = ( endTime - startTime ) exitStatus = child . exitstatus return ( output , duration , exitStatus )
executes cmd as a child process and returns the childs output .