1

Need you help. "matcherror" is a list and contains list of error codes which it needs to match with "errormsg". I want to match "Agent is not authorized to under pay on a booking" with the full error message mentioned in the "errormsg" and ignore the other parameters (i.e ignore Total Cost = 10812.00000, Total Payment = 10308". In-fact whatever i mention in the "matcherror" should match with the "errormsg" and ignore rest of the sentence.

matcherror = ["['Connection Refused']","['Link Down']","['Agent is not authorized to under pay on a booking.']"]
errormsg = "Agent is not authorized to under pay on a booking. Total Cost = 10812.00000, Total Payment = 10308"

Bacially i am trying to achieve something like:

matcherror = ["['Connection Refused']","['Link Down']","['Agent is not authorized to under pay on a booking.']"]
errormsg = "Agent is not authorized to under pay on a booking. Total Cost = 10812.00000, Total Payment = 10308"
evaluate = matcherror in errormsg
if evaluate == True:
     send_email(showfailure)
else:
     print "No failure for this hour"

1 Answer 1

1

You need to change your evaluate.You searching for a list in string.Instead loop over list and find each of its element in string.

import re
matcherror = ["['Connection Refused']","['Link Down']","['Agent is not authorized to under pay on a booking.']"]
errormsg = "Agent is not authorized to under pay on a booking. Total Cost = 10812.00000, Total Payment = 10308"
evaluate=False
for i in matcherror:
    if re.sub(r"^\['|'\]$","",i) in errormsg:
        evaluate=True
if evaluate == True:
     print "Fail"
else:
     print "No failure for this hour"
Sign up to request clarification or add additional context in comments.

1 Comment

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.