-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproductinitialize_WTP.py
53 lines (48 loc) · 2.18 KB
/
productinitialize_WTP.py
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
import os
import time
utc = 0
def plotinitialize():
f = open('/root/GFS/plot.sh', 'w+')
f.close()
os.system('rm -rf product/WTP')
print('['+time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time() + utc * 60 * 60))+']'+'Erase expired product')
os.system('mkdir product/WTP')
print('[' + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time() + utc * 60 * 60)) + ']' + 'Create product folder')
f = open('/root/GFS/sysreport/plotreport.txt', 'w+')
f.close()
print('[' + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time() + utc * 60 * 60)) + ']' + 'Create system plot report file...')
f = open('/root/GFS/sysreport/errreport.txt', 'w+')
f.close()
print('[' + time.strftime('%Y-%m-%d %H:%M:%S',
time.localtime(time.time() + utc * 60 * 60)) + ']' + 'Create system plot error report file...')
def createsh():
path = 'rawfile/'
files = os.listdir(path)
print(files)
for file in files:
if file[0:3] == 'gfs':
try:
f = open('/root/GFS/plot.sh', 'a+')
f.write(
'python3 plotWTP.py --path ' + file + ' --area CN\n')
f.close()
except:
print('[FATAL ERR] PROGRAM STOP' + file)
f = open('/root/GFS/sysreport/errreport.txt', 'a+')
f.write(
'[' + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time() + utc * 60 * 60)) + ']' + '\t' +
file + ' SCRIPT INITIALIZE FAILED! PLEASE CHECK\n')
f.close()
print('[' + time.strftime('%Y-%m-%d %H:%M:%S',
time.localtime(time.time() + utc * 60 * 60)) + ']' + 'Script Done. Ready to run.\n')
def start():
print('[' + time.strftime('%Y-%m-%d %H:%M:%S',
time.localtime(time.time() + utc * 60 * 60)) + ']' + 'Start plot script.\n')
f = open('/root/GFS/sysreport/running.txt', 'a+')
f.write(
'[' + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time() + utc * 60 * 60)) + ']' + '\tStart running plot script.\n')
f.close()
os.system('sh plot.sh')
plotinitialize()
createsh()
start()