53 lines
3.2 KiB
Python
53 lines
3.2 KiB
Python
import os
|
|
from ChaChaGameStats import GameStatsSupervisor
|
|
|
|
|
|
#unitary test
|
|
if __name__ == '__main__':
|
|
|
|
_GameStatsSupervisorFactory = GameStatsSupervisor.GameStatsSupervisorFactory()
|
|
|
|
if os.name == 'nt':
|
|
#for windows
|
|
dir_path = os.path.dirname(os.path.realpath(__file__))
|
|
qstatpath = dir_path+"\\Ext\qstat.exe"
|
|
print(qstatpath)
|
|
_GameStatsSupervisorFactory._QuakeStatFactory.add_common_options(QStatCmd=qstatpath)
|
|
|
|
ar_games = []
|
|
|
|
""" duplicate this record for all your games
|
|
ar_games.append( _GameStatsSupervisorFactory.create( name = "foo", # game instance name
|
|
gametype = "foo", # gametype name: ut99,ut2k4,ut3,cod4,cod5,codmw3,codbo2,cry1,mc,q2,q3a
|
|
ip = "xx.xx.xx.xx", # gameserver ip or dns name
|
|
|
|
# Stats Interfaces registration:
|
|
# - at least one interface must be configured
|
|
|
|
#[optional] QuakeStat Interface registration:
|
|
Interface_QuakeStats = { "port":xxxx}, # quakestat protocol port (usually same as game port)
|
|
|
|
#[optional] Rcon/Web Interface registration:
|
|
# rcon interface is 'real' rcon for cod(s) and quake(s) games, xmlrpc for crysis and http webgui for ut(s)
|
|
Interface_RconBase = { "port":xxxx, # rcon/web protocol port
|
|
"username":"fooo", # rcon/Web user
|
|
"password":"fooo"} # rcon/web password
|
|
)
|
|
)
|
|
"""
|
|
|
|
print("### Unitary test START")
|
|
for i in range(1):
|
|
for game in ar_games:
|
|
print("")
|
|
print("== Testing: " + game.GameName + "==")
|
|
res = game.API_GetGameServerStatusResult()
|
|
print("res: " + str(res.__dict__))
|
|
for player in res.players:
|
|
print(player.__dict__)
|
|
if 'QuakeStats' in res.raw:
|
|
print("res: { 'raw': {'QuakeStats': " + str(res.raw['QuakeStats'].__dict__) +"},...}")
|
|
if 'RconBase' in res.raw:
|
|
print("res: { 'raw': {'RconBase': " + str(res.raw['RconBase'].__dict__) +"},...}")
|
|
|
|
print("### Unitary test END") |