integrate on ut99 v469c

This commit is contained in:
2023-04-18 00:12:02 +02:00
parent abb92f0638
commit 83ca522a9d
4 changed files with 57 additions and 36 deletions

View File

@@ -46,7 +46,6 @@ class RconUTEngineWebAdmin(RconBase.RconBase,metaclass=abc.ABCMeta):
self.GameServerStatusResult = None
self.timeout = timeout
self.initConstant()
self.fetchData = {};
def initConstant(self):
pass
@@ -65,8 +64,7 @@ class RconUTEngineWebAdmin(RconBase.RconBase,metaclass=abc.ABCMeta):
def _fetchPageRAW(self,page) -> str:
try:
response = self.session.get(page,data=self.fetchData,timeout=self.timeout)
self.fetchData = {}
response = self.session.get(page,timeout=self.timeout)
if response.status_code != 200:
raise RconBase.ExceptionWrongRconPassword
except requests.exceptions.RequestException as e:
@@ -150,32 +148,47 @@ class RconUTEngineWebAdminMODCENTRAL(RconUTEngineWebAdmin,metaclass=abc.ABCMeta)
tree = self._fetchPageETree(url)
try:
level1 = tree.findall(".//form[@action='"+element+"']")[0]
level2 = level1.findall(".//table")[0]
infoChart = level2.findall(".//tr")
for info_record in infoChart:
data = info_record.findall(".//td/select")
if data :
attributename = data[0].attrib["name"].split('.')[-1] #get last var name: BLABLA.keyname => keyname
data_value = data[0].findall(".//option[@selected]")
level2 = level1.findall(".//table")
# table based page
if level2:
level2 = level2[0]
infoChart = level2.findall(".//tr")
for info_record in infoChart:
data = info_record.findall(".//td/select")
if data :
attributename = data[0].attrib["name"].split('.')[-1] #get last var name: BLABLA.keyname => keyname
data_value = data[0].findall(".//option[@selected]")
if data_value:
if "value" in data_value[0].attrib:
ar_ServerRules[attributename] = data_value[0].attrib["value"]
else:
ar_ServerRules[attributename] = data_value[0].text
continue
data = info_record.findall(".//td/input")
if data and data[0].attrib["name"]!="Apply":
attributename = data[0].attrib["name"].split('.')[-1] #get last var name: BLABLA.keyname => keyname
if "value" in data[0].attrib:
ar_ServerRules[attributename] = data[0].attrib["value"]
else:
ar_ServerRules[attributename] = data[0].text
if data[0].attrib["type"] == "checkbox" :
if "checked" in data[0].attrib:
ar_ServerRules[attributename] = "true"
else:
ar_ServerRules[attributename] = "false"
continue
else:
#new pages UT99 469c .... :-/
selects = level1.findall(".//select")
for _select in selects:
attributename = _select.attrib["name"].split('.')[-1] #get last var name: BLABLA.keyname => keyname
data_value = _select.findall(".//option[@selected]")
if data_value:
if "value" in data_value[0].attrib:
ar_ServerRules[attributename] = data_value[0].attrib["value"]
else:
ar_ServerRules[attributename] = data_value[0].text
continue
data = info_record.findall(".//td/input")
if data and data[0].attrib["name"]!="Apply":
attributename = data[0].attrib["name"].split('.')[-1] #get last var name: BLABLA.keyname => keyname
if "value" in data[0].attrib:
ar_ServerRules[attributename] = data[0].attrib["value"]
else:
ar_ServerRules[attributename] = data[0].text
if data[0].attrib["type"] == "checkbox" :
if "checked" in data[0].attrib:
ar_ServerRules[attributename] = "true"
else:
ar_ServerRules[attributename] = "false"
continue
continue
except Exception as e:
raise RconBase.ExceptionRconResultParse(e)
return ar_ServerRules

View File

@@ -171,8 +171,13 @@ class RconUTEngineWebAdminUT99(RconUTEngineWebAdmin.RconUTEngineWebAdminMODCENTR
ar_PlayersStats = []
tree = self._fetchPageETree(self.currentplayersUrl)
try:
level1 = tree.findall(".//form[@action='current_players']")[0]
level2 = level1.findall(".//table")[1]
level1 = tree.findall(".//form[@action='current_players']")
if len(level1) == 2: #ut469c
level1 = level1[1]
level2 = level1.findall(".//table")[0]
else:
level1 = level1[0]
level2 = level1.findall(".//table")[1]
player_chart = level2.findall(".//tr")
del player_chart[0]
for player_record in player_chart:

View File

@@ -7,4 +7,4 @@ Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International Unported
You should have received a copy of the license along with this
work. If not, see <https://creativecommons.org/licenses/by-nc-sa/4.0/>.
"""
__version__ = "0.1.3"
__version__ = "0.1.4"

View File

@@ -1,7 +1,7 @@
import os
import time
from ChaChaGameStats import GameStatsSupervisor
from pprint import pprint
#unitary test
if __name__ == '__main__':
@@ -37,7 +37,7 @@ if __name__ == '__main__':
)
"""
"""
ar_games.append( _GameStatsSupervisorFactory.create( name = "ut99-dm",
gametype = "ut99",
ip = "172.16.1.41",
@@ -50,6 +50,7 @@ if __name__ == '__main__':
"password":"cfographut"}
)
)
"""
ar_games.append( _GameStatsSupervisorFactory.create( name = "ut99-niut",
gametype = "ut99",
ip = "172.16.1.40",
@@ -73,7 +74,8 @@ if __name__ == '__main__':
"username":"chacha",
"password":"cfographut"}
)
)
)
ar_games.append( _GameStatsSupervisorFactory.create( name = "ut99-utp",
gametype = "ut99",
ip = "172.16.1.42",
@@ -86,7 +88,7 @@ if __name__ == '__main__':
"password":"AmL992gxE"}
)
)
"""
ar_games.append( _GameStatsSupervisorFactory.create( name = "codbo2-3",
gametype = "codbo2",
ip = "GAME-CODBO2",
@@ -98,7 +100,8 @@ if __name__ == '__main__':
"username":"admin",
"password":"cfographut"}
)
)
)
"""
print("### Unitary test START")
timestart = time.time()
for i in range(200):
@@ -106,12 +109,12 @@ if __name__ == '__main__':
print("")
print("== Testing: " + game.GameName + "==")
res = game.API_GetGameServerStatusResult()
print("res: " + str(res.__dict__))
pprint("res: " + str(res.__dict__))
for player in res.players:
print(player.__dict__)
pprint(player.__dict__)
if 'QuakeStats' in res.raw:
print("res: { 'raw': {'QuakeStats': " + str(res.raw['QuakeStats'].__dict__) +"},...}")
pprint("res: { 'raw': {'QuakeStats': " + str(res.raw['QuakeStats'].__dict__) +"},...}")
if 'RconBase' in res.raw:
print("res: { 'raw': {'RconBase': " + str(res.raw['RconBase'].__dict__) +"},...}")
pprint("res: { 'raw': {'RconBase': " + str(res.raw['RconBase'].__dict__) +"},...}")
timestop = time.time() - timestart
print("### Unitary test END ({})".format(timestop))