Compute the su procedure time with python, computepython

Source: Internet
Author: User

Compute the su procedure time with python, computepython
#! /Usr/bin/python2.6
Import re, datetime
File_name = 'sim. Log'
File = open (file_name, 'R ')
Acnum = []; time_res = []; lnum = 0
Def trans_time (time ):
T1 = datetime. datetime. strptime (time, '% y/% m/% d % H: % M: % s ')
Return t1
For (num, line) in enumerate (file ):


If (re. search (R' ^ (. *) beginning sim procedure (. *) $ ', line )):
M = re. search (R' ^ (. *) beginning sim procedure (. *) $ ', line)
Print 'step % d: '% (lnum), m. group (0); lnum + = 1
Acnum. append (trans_time (line [0: 17])
Elif (re. search (R' ^ (. *) CP_W (. *) $ ', line )):
M = re. search (R' ^ (. *) CP_W (. *) $ ', line)
Print 'step % d: '% (lnum), m. group (0); lnum + = 1
Acnum. append (trans_time (line [0: 17])
Elif (re. search (r "^ (. *) VERIFY_S (. *) $", line )):
M = re. search (r "^ (. *) VERIFY_S (. *) $", line)
Print 'step % d: '% (lnum), m. group (0); lnum + = 1
Acnum. append (trans_time (line [0: 17])
Elif (re. search (r "^ (. *) -- action commit (. *) $", line )):
M = re. search (r "^ (. *) -- action commit (. *) $", line)
Print 'step % d: '% (lnum), m. group (0); lnum + = 1
Acnum. append (trans_time (line [0: 17])
Elif (re. search (r "^ (. *) completed sim procedure (. *) $", line )):
M = re. search (r "^ (. *) completed sim procedure (. *) $", line)
Print 'step % d: '% (lnum), m. group (0); lnum + = 1
Acnum. append (trans_time (line [0: 17])
Elif (re. search (r "^ (. *) resuming sim procedure (. *) $", line )):
M = re. search (r "^ (. *) resuming sim procedure (. *) $", line)
Print 'step % d: '% (lnum), m. group (0); lnum + = 1
Acnum. append (trans_time (line [0: 17])


File. close ()
If (re. search (r "^ (. *) backout (. *) $", file_name )):
Time_res.append (acnum [2]-acnum [0]). seconds/60)
Time_res.append (acnum [4]-acnum [3]). seconds/60)
Time_res.append (acnum [6]-acnum [5]). seconds/60)
Time_res.append (acnum [8]-acnum [7]) + (acnum [10]-acnum [9]) + (acnum [13]-acnum [11]). seconds/60)
Print "\ n3). sim -- proc update -- action apply to \" CP_WARNING \ "% s mins" % (time_res [0])
Print "4). sim -- proc update -- action resume to \" VERIFY_SOFTWARE \ "% s mins" % (time_res [1])
Print "5). sim -- proc update -- action resume to \" COMMIT \ "% s mins" % (time_res [2])
Print "8). Backout from RXX to RXX % s mins" % (time_res [3])
Elif (re. search (r "^ (. *) rollback (. *) $", file_name )):
Time_res.append (acnum [2]-acnum [0]). seconds/60)
Time_res.append (acnum [4]-acnum [3]). seconds/60)
Time_res.append (acnum [6]-acnum [5]). seconds/60)
Time_res.append (acnum [8]-acnum [7]). seconds/60)
Time_res.append (acnum [10]-acnum [9]) + (acnum [12]-acnum [11]) + (acnum [15]-acnum [13]). seconds/60)
Print "\ n3). sim -- proc update -- action apply to \" CP_WARNING \ "% s mins" % (time_res [0])
Print "4). sim -- proc update -- action resume to \" VERIFY_SOFTWARE \ "% s mins" % (time_res [1])
Print "5). sim -- proc update -- action resume to \" COMMIT \ "% s mins" % (time_res [2])
Print "6). sim -- proc update -- action commit to end of Patch % s mins" % (time_res [3])
Print "8). Rollback from RXX to RXX % s mins" % (time_res [4])
If _ name _ = '_ main __':
Pass

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.