compute the su procedure time with python

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

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-10-14 09:48:17

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

Python Django开始

1.创建工程 C:\procedure\projects>django-admin startproject mysite 2.同步数据库 C:\procedure\projects\mysite>python manage.py syncdb 3.创建app C:\procedure\projects\mysite>python manage.py startapp blog 4.启动服务 C:\procedure\projects\mysite>python manage.py

Python的MySQLdb模块安装

在配置Django时,选择的是mysql数据库,要安装MySQLdb模块,不过安装过程中,遇到了很多errors,记录一下. 系统:ubuntu 11.10 mysql:直接apt-get安装的,version:5.1.62 到官方下载MySQL for Python 然后解压,打开README: 里面有安装过程: $ tar xfz MySQL-python-1.2.1.tar.gz $ cd MySQL-python-1.2.1 $ # edit site.cfg if necessary

python中修改函数内部的变量会发生什么

最近写python遇到个函数内部变量使用外部变量的问题,现在总结下吧 #!/usr/bin/env python a = 100def su(): a = a + 1 print(a) s = su() #执行这段代码会报错(如果只是调用不修改是不会报错的) 更改为: #!/usr/bin/env python a = 100def su(): global a a = a + 1 print(a) s = su() 总结: 在python的函数中和全局同名的变量,如果修改变量的值就会变成局部变

[C3] Andrew Ng - Neural Networks and Deep Learning

About this Course If you want to break into cutting-edge AI, this course will help you do so. Deep learning engineers are highly sought after, and mastering deep learning will give you numerous new career opportunities. Deep learning is also a new "s

如何在Mac系统里面更新 Ansible 的 Extra Modules

最近遇到一个问题 seport is not a legal parameter in an Ansible task or handler 原因是我本地 Ansible 的 Extra Modules 已经过时,需要更新.但是Ansible的官方文档只给了这么一句话 There should be no need to install this repo separately as it should be included in any Ansible install using the o

php - 执行Linux命令没有报错但也没有输出

今天我需要在同事访问我的PHP页面的时候执行一段python脚本,于是我的代码是这样写的: 1 <?php 2 function my_workjob(){ 3 $this->makeLog('ok run workjob'); 4 if($this->is_internal()){ 5 $cmd = '/usr/bin/python /data/script/abc/run.py'; 6 $out = system($cmd); 7 echo 'run'; 8 echo $out; 9

Docker distrubution in django

https://www.syncano.io/blog/configuring-running-django-celery-docker-containers-pt-1/ Update: Fig has been replaced by Docker Compose, and is now deprecated. Docker Compose should serve as a drop-in replacement for fig.sh used in this article. Today,

在rhel7中搭建openstack kilo

1.       安装Controller 1.1        配置主机名 1.2        配置网络 1.3        配置Selinux 1.4        安装源配置 安装源包括:CENTOS7.EPEL7.OPENSTACK-KILO 1.5        安装Mariadb 安装mysql数据库依赖包 # yuminstall mariadb mariadb-server MySQL-python –y 编辑文件完成下列步骤: #vi /etc/my.cnf.d/maria

Openstack(Kilo)安装系列之nova(七)

控制节点 Before you install and configure the Compute service, you must create a database, service credentials, and API endpoint. 一.创建nova数据库并授权 1.登陆数据库 mysql -u root -p 2.创建数据库并授权 CREATE DATABASE nova; GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost