#!/usr/bin/python
import os
import sys
import linecache
import time
import glob
cur_ptah = os.getcwd()
regress_path = cur_path
cur_path_slpit = cur_path.split('/')
if cur_path_split[-1] == '07_regress':
tc_path_split = cur_path.replace('07_regress', '03_tc')
else:
print('current path is not 07_regress')
sys.exit()
os.chdir('/home/xxxxx')
os.system('r'source .cshrc')
os.chdir(regress_path)
os.chdir('../../cshrc')
os.system(r'source cshrc')
os.chdir(regress_path)
print(os.getenv('HUANGJINGBIANLIANG'))
tc_path='/'.join(tc_path_split)
first_regre_tc = linecache.getline('rgs000.log',2)
first_regre_tc_split = first_regre_tc.split('\n')
first_regre_tc_path_split=[tc_path_split, first_regre_tc_split[-2]]
first_regre_tc_path='/'.join(first_tc_regre_tc_path_split)
os.chdir(first_regre_tc_path)
find_log = glob.glob(r'./**/*.log',recurvsive=True)
for i in find_log:
os.unlink(i)
os.system(r'bsub xxxxx')
cur_file_list=[]
xrun_log_name =[]
while (1):
cur_file_list = os.listdir('./')
for i in cur_file_list:
if '.log' in i and 'log.' not in i:
xrun_log_name = i
break
if len(xrun_log_name) != 0:
break
time.sleep(60)
print('wait xxxx')
xrun_log_file=open(xrun_log_name,'r')
while(1):
xrun_log_context = xrun_log_file.read()
if 'xxxxx' in xrun_log_context:
os.chdir(regress_path)
break
time.sleep(60)
print('wait xxx')
xrun_log_file.close()
os.system(r'xxxxx')