-
Notifications
You must be signed in to change notification settings - Fork 22
/
update_loop.py
33 lines (28 loc) · 1.06 KB
/
update_loop.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
import os
import time
from datetime import date
import utils
import sys
utils.ensure_exists('static/status')
cmds = [
('python scrape.py', False), # downloads gamelogs from isotropic
('python parse_game.py', True), # parses data into useable format
('python load_parsed_data.py', False), # loads data into database
('python analyze.py', False), # produces data for graphs
('python goals.py', False),
('python count_buys.py', False),
('python run_trueskill.py', False)
]
extra_args = sys.argv[1:]
# should think about how to parrallelize this for multiprocessor machines.
while True:
for cmd, spittable in cmds:
status_fn = (cmd.replace(' ', '_') + '-' +
date.today().isoformat() + '-' +
time.strftime('%H:%M:%S') + '.txt')
cmd = cmd + ' ' + ' '.join(extra_args) + ' 2>&1 | tee -a ' + status_fn
print cmd
os.system(cmd)
os.system('mv %s static/status' % status_fn)
print 'sleeping'
time.sleep(60*15) # try to update every 15 mins