-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathdailydump.py
More file actions
39 lines (35 loc) · 1.07 KB
/
Copy pathdailydump.py
File metadata and controls
39 lines (35 loc) · 1.07 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
'''
Created on Jul 17, 2014
@author: tliu
'''
from datetime import datetime, date, time, timedelta
from time import sleep
from apscheduler.scheduler import Scheduler
from dateutil import tz
import atexit
from subprocess import call
import logging
logging.basicConfig()
def runDateDump():
call("python CtpRealTimeDump.py -d", shell=True)
def main():
d = date.today()
t = time(00,30)
startDate = datetime.combine(d,t)
startDate = startDate.replace(tzinfo=tz.tzutc())
startDate = startDate.astimezone(tz.tzlocal())
timeStr = startDate.strftime("%Y-%m-%d %H:%M:%S")
print timeStr
startDate = datetime.strptime(timeStr, "%Y-%m-%d %H:%M:%S")
if (datetime.now() - startDate) > timedelta(seconds=1):
startDate = startDate + timedelta(days=1)
sched = Scheduler()
sched.start()
sched.add_interval_job(runDateDump, days=1, start_date=startDate.strftime("%Y-%m-%d %H:%M:%S"))
sched.print_jobs()
while True:
sleep(1)
print "."
atexit.register(lambda: sched.shutdown(wait=True))
if __name__ == '__main__':
main()