-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
54 lines (40 loc) · 1.36 KB
/
main.py
File metadata and controls
54 lines (40 loc) · 1.36 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import config
import Logger
import Server
import TestParser
import optparse
import os
import sys
def RunTest( file, server ):
parser = TestParser.TestParser(file, server)
t = parser.Parse()
if parser.HasError():
print(parser.GetError())
return None
return t
parser = optparse.OptionParser()
parser.add_option("-l", "--log", dest="log", help="Display full log on STDERR", default=False, action="store_true")
parser.add_option("-p", "--allow-players", dest="allow_players", help="Allow tests to run whilst players are on the server", default=False, action="store_true")
parser.add_option("-c", "--config", dest="config_file", help="Location of config.ini", default="config.ini", action="store", type="string")
(options, args) = parser.parse_args()
Logger.Logger.Enable(options.log)
config.read_config(options.config_file)
if not len(args):
print("No test files supplied")
else:
server = Server.Server(
config.config_value('RCON_HOST'),
config.config_value('RCON_PORT'),
config.config_value('RCON_PASS')
);
if not options.allow_players and server.HasPlayers():
print("Players are on the server:")
print(server.Status())
os._exit(0)
for i in args:
t = RunTest(i, server)
if t == None:
continue
if t.Prepare():
t.Run()
t.Cleanup()