router-7F2C13#show engine app stats test on TEST/switch1234-15E8CC
--------------------------------------------------------------------------------
APPLICATION BYTES_IN BYTES_OUT NUM_FLOWS
--------------------------------------------------------------------------------
test 0 0 4
--------------------------------------------------------------------------------
router-7F2C13#
---------------------------------------------------------------
router-7F2C13#
import re
def pass_fail_criteria(x):
if int(re.findall(r"NUM_FLOWS\n-+[\s\S]*?(\d+)\s*-+",x)[0]):
return "pass"
else:
return "fail"
print pass_fail_criteria(x)
But When I use this is in RFW. Its not working. I am getting "IndexError: index out of range: 0" error.
***Settings***
Library calc.Calculator WITH NAME Calculator
Library Telnet
Library regexp_def.py
*** Variables ***
${HOST} 1.1.1.1
${USERNAME} test
${PASSWORD} test
***Test Cases***
Start Blue stack
startBluestack
sleep 40
clickSearchinbluestaks
clickSearchtypeocto
clickOctoapp
sleep 20
clickClose
Check Deep Packet Inspection Stats
Open Connection ${HOST}
Login ${USERNAME} ${PASSWORD}
Write enable
Write show engine app stats test on AVC/test-15E8CC
${x} Read Until Regexp .*#
Log ${x}
${status} pass fail criteria ${x}
IndexError: index out of range: 0
Please find the logs below:
C:\RFW>jybot.bat octo.robot
==============================================================================
Octo
==============================================================================
Start Blue stack | PASS |
------------------------------------------------------------------------------
Check Deep Packet Inspection Stats | FAIL |
IndexError: index out of range: 0
------------------------------------------------------------------------------
Octo | FAIL |
2 critical tests, 1 passed, 1 failed
2 tests total, 1 passed, 1 failed
==============================================================================
Output: C:\RFW\output.xml
Log: C:\RFW\log.html
Report: C:\RFW\report.html
C:\RFW>
import re
def pass_fail_criteria(x):
if not int(re.findall(r"NUM_FLOWS\n-+[\s\S]*?(\d+)\s*-+",x)[0]):
raise Exception('NUM_FLOWS = 0')
> email to robotframework-users+unsub...@googlegroups.com.
import re
def pass_fail_criteria(x):
if not int(re.findall(r"NUM_FLOWS\r\n-+[\s\S]*?(\d+)\s*-+",x)[0]):
raise Exception('NUM_FLOWS = 0')
>> > email to robotframework-users+unsub...@googlegroups.com.
>> > To post to this group, send email to robotframe...@googlegroups.com.
>> > Visit this group at http://groups.google.com/group/robotframework-users.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "robotframework-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to robotframework-users+unsub...@googlegroups.com.
Classification: //Dell SecureWorks/Confidential - Limited External Distribution:
Hello Balu,
I have 3 points for you:
1) “IndexError: index out of range: 0” MUST be coming from the end of the line with the “[0]”, so that means your regexp isn’t matching.
2) For debugging issues like this, break things up and add print statements:
def pass_fail_criteria(x):
print "DEBUG: x = '%s'" % x
match_check = re.findall(r"NUM_FLOWS\n-+[\s\S]*?(\d+)\s*-+",x)
print "DEBUG: match_check = '%s'" % match_check
if not int(re.findall(r"NUM_FLOWS\n-+[\s\S]*?(\d+)\s*-+",x)[0]):
raise Exception('NUM_FLOWS = 0')
The output of the “print” statements should be in your “log.html” file.
3) I think your real problem is that the lines end with a space before the “\n”, so change your regexp so it has a space between NUM_FLOWS and the “\n”.
-Michael
>> > email to robotframework-u...@googlegroups.com.
>> > To post to this group, send email to
robotframe...@googlegroups.com.
>> > Visit this group at
http://groups.google.com/group/robotframework-users.
>> > For more options, visit
https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "robotframework-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to robotframework-u...@googlegroups.com.
> To post to this group, send email to robotframe...@googlegroups.com.
> Visit this group at
http://groups.google.com/group/robotframework-users.
> For more options, visit
https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.