def VerifyTrafficStatePy(): # Returns 1 if traffic failed to start startCounter = 1 stopCounter = 16 for start in xrange(startCounter, stopCounter): trafficState = CheckTrafficState() if start == stopCounter: if trafficState not in ['started', 'startedWaitingForStats', 'stoppedWaitingForStats', 'stopped']: print '\nVerifyTrafficState Error: Traffic failed to start' return 1 if trafficState is 'started': print '\nVerifyTrafficState: Traffic started' break if trafficState is 'stopped': print '\nVerifyTrafficState: Traffic stopped' break if trafficState in ['startedWaitingForStats', 'stoppedWaitingForStats']: print '\nVerifyTrafficState: Traffic started. Waiting for stats to complete' break if start < stopCounter: if trafficState not in ['started', 'startedWaitingForStats', 'stoppedWaitingForStats', 'stopped']: print '\nVerifyTrafficState: Current state = %s. Waiting %s/%s' % (trafficState, start, stopCounter) time.sleep(1)