#!/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

compute the su procedure time with python的更多相关文章

  1. Python Django开始

    1.创建工程 C:\procedure\projects>django-admin startproject mysite 2.同步数据库 C:\procedure\projects\mysit ...

  2. Conclusions about Deep Learning with Python

     Conclusions about Deep Learning with Python  Last night, I start to learn the python for deep learn ...

  3. python 面试题1

    1.大数据的文件读取 ① 利用生成器generator ②迭代器进行迭代遍历:for line in file 2.迭代器和生成器的区别 1)迭代器是一个更抽象的概念,任何对象,如果它的类有next方 ...

  4. 整理的最全 python常见面试题(基本必考)

    整理的最全 python常见面试题(基本必考) python 2018-05-17 作者 大蛇王 1.大数据的文件读取 ① 利用生成器generator ②迭代器进行迭代遍历:for line in ...

  5. python 面试题--你能做出多少?

    python3中__get__,getattr,__getattribute__的区别 什么是 GIL 详细博客 GIL = Global Intercept Lock 全局解释器锁,任意时刻在解释器 ...

  6. python常见面试题(mark)

    1.大数据的文件读取 ① 利用生成器generator ②迭代器进行迭代遍历:for line in file 2.迭代器和生成器的区别 1)迭代器是一个更抽象的概念,任何对象,如果它的类有next方 ...

  7. 运行python时提示:ImportError: No module named plyvel ,ImportError No module named irc 解决过程:

    (当前python版本:2.7) 1.在git下载electrum-server: cd / git clone https://github.com/spesmilo/electrum-server ...

  8. 整理的最全 python常见面试题

      整理的最全 python常见面试题(基本必考)① ②③④⑤⑥⑦⑧⑨⑩ 1.大数据的文件读取: ① 利用生成器generator: ②迭代器进行迭代遍历:for line in file; 2.迭代 ...

  9. python基础===通过菲波那契数列,理解函数

    def fib(n): # write Fibonacci series up to n """Print a Fibonacci series up to n.&quo ...

随机推荐

  1. python输出字典中的中文

    如果不用本文指定的方法,会有如下报错: UnicodeDecodeError: 'utf8' codec can't decode byte 0xbf in position 2: invalid s ...

  2. <深入理解计算机系统> CSAPP Tiny web 服务器

    本文是我学习<深入理解计算机系统>中网络编程部分的学习笔记. 1. Web基础       web客户端和服务器之间的交互使用的是一个基于文本的应用级协议HTTP(超文本传输协议).一个w ...

  3. Drupal 有用的模块

    投票模块drigg https://www.drupal.org/project/drigg

  4. 关于微信浏览器不支持offset()的兼容性处理

    问题的背景: 在手机触屏版中,当页面向上滑动的时候,导航条可以固定在顶部,通过判断offset().top的值来实现这个功能,其他的浏览器都可以,只有微信浏览器中出现问题(向上滑动的时候,导航条就会直 ...

  5. Echarts-之显示百分比

    对于使用echarts要显示百分比,要改两个地方,第一个地方时坐标轴显示为百分比的格式,第二个是让值以百分比的形式显示,如50,在图上面显示为50%. yAxis: [ { type: 'value' ...

  6. python 之 线程池实现并发

    使用线程池实现高IO并发 模块:ThreadPoolExecutor, as_completed 测试代码如下: #!/opt/python3/bin/python3 from concurrent. ...

  7. 关于编写Windows程序中启动兼容性问题

    之前用qt4编写Windows程序的时候遇到了一个软件在系统的兼容性问题:用户在win10系统下使用这个程序的时候,如果没有用低于win10版本的兼容模式运行的时候,存在运行某部分功能的时候无法使用的 ...

  8. 【前台 ajax】前台ajax请求,地址正确,但是报错不进入后台

    前台ajax请求,地址正确,但是报错不进入后台 出现上述问题,可能的情况是 1.ajax用的post,而后台限定用get,或者所有的post请求都被拦截,所以不能正常进入并且报错403 @Reques ...

  9. 【bootstrap】Bootstrap Notify的使用步骤

    Bootstrap Notify说明文档:http://bootstrap-notify.remabledesigns.com/ Bootstrap Notify的GitHub地址:https://g ...

  10. Unity -- Collider(碰撞器与触发器)

    (2d与3d的Collider可以相互存在,但是无法相互协作,如2d是无法检测3d的,反之,一样) 在目前掌握的情况分析,在Unity中参与碰撞的物体分2大块:1.发起碰撞的物体.2.接收碰撞的物体. ...