-
Notifications
You must be signed in to change notification settings - Fork 21
/
debug-site-game.py
38 lines (33 loc) · 1.09 KB
/
debug-site-game.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
import sys
import os
import subprocess
import time
import atexit
REPEATER_SUBDIR = 'repeater'
def startRepeater(token):
cwd = os.getcwd()
try:
os.chdir(REPEATER_SUBDIR)
repeater = subprocess.Popen(['java', '-cp', '.;*;%s/*' % os.getcwd(), '-jar',
'repeater.jar', token], shell=False)
time.sleep(0.5)
finally:
os.chdir(cwd)
def repeaterStop(proc=repeater):
if proc.poll() is None:
proc.kill()
atexit.register(repeaterStop)
def main(gameNumber, repeaterToken):
os.chdir(os.path.abspath(os.path.dirname(__file__)))
if not startRepeater(repeaterToken):
sys.exit('cannot start repeater')
runner = subprocess.Popen([sys.executable, os.path.abspath('local-runner/replay-dump.py'),
gameNumber], shell=False)
runner.wait()
if __name__ == '__main__':
try:
gameNumber, repeaterToken = sys.argv[1:]
except ValueError:
sys.exit('Usage: %s game-number repeater-token' % sys.argv[0])
else:
main(gameNumber, repeaterToken)