0

I am trying to break from a while and for loop as below whenever retry and last_submitted_tag_retryare equal but it doesn't, how do I break from this loop?

import re
retry = 0
last_submitted_tag_retry = 0 
train = 'train1'

output = '''Thu Jan 24 18:08:18 2019 firstname lastname <first_last@company.com> submitted project-394 to train1
Thu Jan 24 18:08:18 2019 firstname lastname <first_last@company.com> forwarded project-394 to train2, train2SideFive, train4, train3, train3SideFive, train1SideFive, bridgeOSJazz, and bridgeOSJazzSideTwo
Thu Jan 24 19:18:47 2019 firstname lastname <first_last@company.com> submitted project-395 to train1
Thu Jan 24 19:18:47 2019 firstname lastname <first_last@company.com> forwarded project-395 to train2, train2SideFive, train4, train3, train3SideFive, train1SideFive, bridgeOSJazz, and bridgeOSJazzSideTwo
Fri Jan 25 14:52:00 2019 username System <username@company.com> submitted project-397 to train1
Fri Jan 25 14:52:00 2019 username System <username@company.com> forwarded project-397 to train2, train2SideFive, train4, train3, train3SideFive, train1SideFive, bridgeOSJazz, and bridgeOSJazzSideTwo
Wed Jan 30 14:40:43 2019 username System <username@company.com> submitted project-398 to train1
Wed Jan 30 14:40:43 2019 username System <username@company.com> forwarded project-398 to train2, train2SideFive, train4, train3, train3SideFive, train1SideFive, bridgeOSJazz, and bridgeOSJazzSideTwo
Sat Feb  2 17:28:10 2019 username System <username@company.com> submitted project-401 to train1
Sat Feb  2 17:28:10 2019 username System <username@company.com> forwarded project-401 to train2, train2SideFive, train4, train3, train3SideFive, train1SideFive, bridgeOSJazz, and bridgeOSJazzSideTwo
Sat Feb  2 17:31:11 2019 username System <username@company.com> submitted project-401 to train1
Sat Feb  2 17:31:11 2019 username System <username@company.com> forwarded project-401 to train2, train2SideFive, train4, train3, train3SideFive, train1SideFive, bridgeOSJazz, and bridgeOSJazzSideTwo'''
last_submitted_tag_retry = 0
retry = 0
while True:
    print 'retry %s last_submitted_tag_retry %s'%(retry,last_submitted_tag_retry)
    for line in reversed(output.splitlines()) :
        line = line.strip()
        #logger.info('line2')
        print 'submissionInfo line%s'%line
        #match = re.fullmatch(r"(?ms).*(?:submitted|forwarded)\s+(.*?)\s+to.*release2(?!.*project.*release2).*",output)
        match = re.match(r'.*(submitted|forwarded)(.*) to .*\b%s\b.*'%train,line)
        print'retry %s last_submitted_tag_retry %s'%(retry,last_submitted_tag_retry)

        if retry != last_submitted_tag_retry:
            print 'not equal'
            retry +=1
        elif retry == last_submitted_tag_retry:
            print 'matches,breaking...'
            break
skaul05
  • 2,154
  • 3
  • 16
  • 26
Ritz
  • 1,193
  • 6
  • 15
  • 26

0 Answers0