-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathregularcheck.py
49 lines (44 loc) · 1.56 KB
/
regularcheck.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
import time
import os
from apscheduler.schedulers.blocking import BlockingScheduler
utc = 0
# draw all the plot in the waitlist file
def regular():
# copy waitlistmission to onging
os.system('cp website/waitlistmission.sh website/ongingmission.sh')
# delete expired waitlist
os.system('rm website/waitlistmission.sh')
# create new waitlist file for further mission
f = open('website/waitlistmission.sh', 'w+')
f.close()
# execute the latest onging mission
os.system('sh website/ongingmission.sh')
# determine whether there are new waitlist plots
def isnewmission():
f = open('website/waitlistmission.sh') # Read waitlist mission
line = f.readline()
if line != '':
f.close()
return True
f.close()
return False
# main program to update all plots to the latest
print('[' + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time() + utc * 60 * 60)) + ']' + '\tPlot System Start')
count = 1 * 60 * 60 / 5
while True:
count += 1
# delete all the products every hour
if count >= 1 * 60 * 60 / 5:
count = 0
path = 'website/static/images/'
files = os.listdir(path)
for file in files:
if file[-3:] == 'png':
os.system('rm website/static/images/'+file)
if isnewmission():
print('[' + time.strftime('%Y-%m-%d %H:%M:%S',
time.localtime(time.time() + utc * 60 * 60)) + ']' + '\tPlot Start')
regular()
else:
#print('NO new mission or onging mission is in place...')
time.sleep(5)