#!/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 NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Compute the SU procedure time with Python