When working ALU IMS Patch team, we need to static the SU duration to add it to the patch report, the duration time alway is hard work, so I write the follow tool to auto do this work.

 #!/usr/bin/python2.6
import re,datetime
file_name='/home/alzhong/logs/qtat1/R2860.01.13/sim-applycommitrollback-bld1.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

The output of the script as follows:

<lsslogin1-alzhong>/home/alzhong/tools: ls
simt
<lsslogin1-alzhong>/home/alzhong/tools: ./simt
Step 0: 14/06/16 12:31:32 BEGINNING SIM PROCEDURE 'update apply' type=hot ...
Step 1: 14/06/16 13:18:42 RESUMING SIM PROCEDURE 'update apply' type=hot ...
Step 2: 14/06/16 13:30:43 SIM0317 PAUSE_REQUEST: (PROCEDURE) [PAUSE(CP_WARNING): Use 'sim --proc update --action resume' to continue...] (update:1435)
Step 3: 14/06/16 13:43:40 RESUMING SIM PROCEDURE 'update apply' type=hot ...
Step 4: 14/06/16 13:47:49 SIM0343 PAUSE_REQUEST: (PROCEDURE) [PAUSE(VERIFY_SOFTWARE): Use 'sim --proc update --action resume' to continue...] (update:1634)
Step 5: 14/06/16 13:54:26 RESUMING SIM PROCEDURE 'update apply' type=hot ...
Step 6: 14/06/16 14:25:41 SIM0496 PAUSE_REQUEST: (COMMIT) [PAUSE(COMMIT): Use 'sim --proc update --action commit' to continue...] (update:2579)
Step 7: 14/06/16 14:41:51 RESUMING SIM PROCEDURE 'update commit' type=hot ...
Step 8: 14/06/16 15:18:34 COMPLETED SIM PROCEDURE 'update commit' type=hot
Step 9: 14/06/16 15:31:35 BEGINNING SIM PROCEDURE 'update rollback' type=hot level=9999 ...
Step 10: 14/06/16 15:47:34 SIM0091 PAUSE_REQUEST: (PROCEDURE) [PAUSE(CP_WARNING): Use 'sim --proc update --action resume' to continue...] (update_rlbk:421)
Step 11: 14/06/16 15:53:30 RESUMING SIM PROCEDURE 'update rollback' type=hot level=9999 ...
Step 12: 14/06/16 16:02:03 SIM0135 PAUSE_REQUEST: (PROCEDURE) [PAUSE(VERIFY_SOFTWARE): Use 'sim --proc update --action resume' to continue...] (update_rlbk:564)
Step 13: 14/06/16 16:04:22 RESUMING SIM PROCEDURE 'update rollback' type=hot level=9999 ...
Step 14: 14/06/16 16:09:42 RESUMING SIM PROCEDURE 'update rollback' type=hot level=9999 ...
Step 15: 14/06/16 16:26:56 COMPLETED SIM PROCEDURE 'update rollback' type=hot level=9999 3). sim --proc update --action apply to "CP_WARNING" 59 mins
4). sim --proc update --action resume to "VERIFY_SOFTWARE" 4 mins
5). sim --proc update --action resume to "COMMIT" 31 mins
6). sim --proc update --action commit to end of Patch 36 mins
8). Rollback from RXX to RXX 47 mins

A python tool to static sim.log duration time的更多相关文章

  1. Python Tool Visual Studio简单使用

    由于一直在做.NET的开发,一直用的IDE是VS系列的,所以想用VS也能开发Python,刚好微软提供一个插件PTVS(Python Tool Visual Studio)专门应用于Python开发的 ...

  2. Cppcheck - A tool for static C/C++ code analysis

    cppcheck是一个个检测源码的工具,对编译工具的一个补充,mark Cppcheck - A tool for static C/C++ code analysis Syntax: cppchec ...

  3. Python的logging,记录log的包

    最近在做自动化测试时,想给他加上日志,所以用到logging的模块,以下是python增加log的几种方式 一.python代码配置方式(当然还有一种是可以多模块通用的一个python代码设置,这个网 ...

  4. Python OOP(2)-static method,class method and instance method

    静态方法(Static Method): 一种简单函数,符合以下要求: 1.嵌套在类中. 2.没有self参数. 特点: 1.类调用.实例调用,静态方法都不会接受自动的self参数. 2.会记录所有实 ...

  5. python脚本攻略之log日志

    1 logging模块简介 logging模块是Python内置的标准模块,主要用于输出运行日志,可以设置输出日志的等级.日志保存路径.日志文件回滚等:相比print,具备如下优点: 可以通过设置不同 ...

  6. python django 访问static静态文件

    settings 文件配置: STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'),)PROJEC ...

  7. python 中 logging 模块的 log 函数以及坑

    记录下吧,一个日志的函数,但有个坑是在调用函数时需要先将函数实例化为一个变量,否则进入某个循环时会多次刷新日志: """ 日志模块 """ ...

  8. python的logging,将log保存到文件

    import logging logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(filename)s[line:%(line ...

  9. pythonのdjango 在控制台用log打印操作日志

    在Django项目的settings.py文件中,在最后复制粘贴如下代码: LOGGING = { 'version': 1, 'disable_existing_loggers': False, ' ...

随机推荐

  1. JS Date.Format

    // 对Date的扩展,将 Date 转化为指定格式的String // 月(M).日(d).小时(h).分(m).秒(s).季度(q) 可以用 1-2 个占位符, // 年(y)可以用 1-4 个占 ...

  2. 【C#进阶系列】05 基元类型、引用类型和值类型

     基元类型和FCL类型 FCL类型就是指Int32这种类型,这是CLR支持的类型. 而基元类型就是指int这种类型,这是C#编译器支持的,实际上在编译后,还是会被转为Int32类型. 而且学过C的朋友 ...

  3. 【C#进阶系列】04 类型基础

    关于System.Object 所有类型都从System.Object派生而来. System.Object的公共方法中ToString()一般是返回对象的类型的全名,只有Int32这些类型将其重写后 ...

  4. 重新想象 Windows 8.1 Store Apps (78) - 控件增强: ScrollViewer, FlipView, Popup

    [源码下载] 重新想象 Windows 8.1 Store Apps (78) - 控件增强: ScrollViewer, FlipView, Popup 作者:webabcd 介绍重新想象 Wind ...

  5. 中国各城市PM2.5数据间的相关分析

    code{white-space: pre;} pre:not([class]) { background-color: white; }if (window.hljs && docu ...

  6. ruby on rails 2.3+的版本不再支持cgi

    ruby on rails 2.3+的版本不再支持cgi了,恶心到了,换其他框架,看了款cramp,完全没资料,完全不让人入门 操蛋的厉害,ruby果然是小众的窝里乐,放弃使用

  7. Android 手机卫士15--程序锁

    1.基本思路 ①.创建已加锁应用的数据库(字段:_id,packagename),如果应用已加锁,将加锁应用的包名维护到数据库中 ②.已加锁+未加锁 == 手机中所有应用(AppInfoProvide ...

  8. linux下log4j乱码解决

    使用log4j的时候,在WIN系统的时候正常显示中文,但是发布到linux系统的时候中文就显示成乱码了 由于log4j配置文件中没有设置编码格式(encoding),所以log4j就使用系统默认编码. ...

  9. 使用div创建选取框

    使用div实现了选取框效果. 代码如下 <!DOCTYPE html> <html> <head> <title>myCanvasTest</ti ...

  10. SharePoint2013 - 移动文档

    In SharePoint 2010, the easiest way to transfer documents from one library to another involved using ...