-
Notifications
You must be signed in to change notification settings - Fork 66
Expand file tree
/
Copy pathdsear.py
More file actions
59 lines (54 loc) · 1.62 KB
/
dsear.py
File metadata and controls
59 lines (54 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/env python
# -*- coding: utf8 -*-
import os
import sys
import time
import re
import zipfile
import datetime
from subprocess import Popen
#groupid
gid = ''
#src update package path
src_path = 'D:\\update'
#des update package path
des_path = 'D:\\'
#process list
pro_lt = ''
#src backup package path
bsrc_path_lt = ['D:\\bin', 'D:\\conf', 'D:\\tdata']
#des backup package path
bdes_path = 'D:\\backup'
def check_start():
filelist = os.listdir('D:{0}\\Log'.format(gid))
fls = []
for filename in filelist:
log_list = ['', '', '', '', '']
for file_log in log_list:
log_s = file_log + '_' + datetime.datetime.now().strftime('%Y%m%d%H')
if filename.startswith(log_s) and filename.endswith('.txt'):
fl_nm = os.path.join('D:{0}\\Log'.format(gid), filename)
with open(fl_nm) as f:
if 'Server initialize end server started!' in f.read():
ret = '{0} - Ok!'.format(filename)
fls.append(ret)
else:
ret = '{0} - Failed!'.format(filename)
fls.append(ret)
else:
pass
rtfl = []
for srnm in ['', '', '', '', '']:
retls = []
for dnm in fls:
if re.match(srnm, dnm):
retls.append(dnm)
else:
pass
rtfl.append(retls[-1])
if 'Failed!' in ''.join(rtfl):
print ''.join(rtfl).replace('!', '\n')
sys.exit(1)
else:
return ''.join(rtfl).replace('!', '\n')
print check_start()