-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
executable file
·42 lines (33 loc) · 961 Bytes
/
run.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
#!/usr/bin/env python3
import sys
import os
import subprocess
os.system("./build.py")
dataDir = os.path.abspath("data")
binDir = os.path.abspath("bin")
executable = None
current = iter(sys.argv)
next(current)
try:
while True:
arg = next(current)
if arg == "--data":
dataDir = os.path.abspath(next(current))
elif arg == "--client":
binDir = os.path.abspath('bin/client')
executable = "GameClient"
elif arg == "--server":
binDir = os.path.abspath('bin/server')
executable = "GameServer"
elif arg == "-h" or arg == "--help":
print("Options:\n\
--server\tRun server\n\
--client\tRun client\n\
--data DIR\t Set data directory\n\
")
except StopIteration:
pass
os.chdir(dataDir)
result = subprocess.run([binDir+"/"+executable])
if result.returncode != 0:
exit(1)