/
update.py
46 lines (35 loc) · 906 Bytes
/
update.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
from config import *
import time
import subprocess
from threading import Timer
import sys
games = set()
def popen(game_id, delay):
while True:
subprocess.Popen(["python", "roomranking.py", str(game_id)])
time.sleep(delay)
def popen_leaderboard():
while True:
subprocess.Popen(["python", "leaderboard.py"])
time.sleep(10)
t = Timer(0, popen_leaderboard)
t.start()
i = 0
no_delay = False
while True:
for game_id, game_name in get_game_list():
if game_id in games:
continue
games.add(game_id)
delay = 5*60
start_delay = i*20
if '-f' in sys.argv:
start_delay = i*2
if no_delay:
start_delay = 1
print 'New room: {}'.format(game_id)
t = Timer(start_delay, popen, [game_id, delay])
t.start()
i += 1
time.sleep(10)
no_delay = True