mirror of
https://github.com/LTTLabsOSS/markbench-tests.git
synced 2026-01-09 14:07:56 -05:00
@@ -12,4 +12,3 @@ def remove_files(paths: list[str]) -> None:
|
|||||||
logging.info("Removed file: %s", path)
|
logging.info("Removed file: %s", path)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
logging.info("File already removed: %s", path)
|
logging.info("File already removed: %s", path)
|
||||||
#test
|
|
||||||
|
|||||||
@@ -7,4 +7,3 @@ def terminate_processes(*process_names: str) -> None:
|
|||||||
for process in psutil.process_iter():
|
for process in psutil.process_iter():
|
||||||
if name.lower() in process.name().lower():
|
if name.lower() in process.name().lower():
|
||||||
process.terminate()
|
process.terminate()
|
||||||
# test
|
|
||||||
|
|||||||
@@ -41,16 +41,19 @@ args = get_args()
|
|||||||
kerasService = KerasService(args.keras_host, args.keras_port, os.path.join(
|
kerasService = KerasService(args.keras_host, args.keras_port, os.path.join(
|
||||||
LOG_DIRECTORY, "screenshot.jpg"))
|
LOG_DIRECTORY, "screenshot.jpg"))
|
||||||
|
|
||||||
|
|
||||||
def get_run_game_id_command(game_id: int) -> str:
|
def get_run_game_id_command(game_id: int) -> str:
|
||||||
"""Build string to launch game"""
|
"""Build string to launch game"""
|
||||||
return "com.epicgames.launcher://apps/" + str(game_id)
|
return "com.epicgames.launcher://apps/" + str(game_id)
|
||||||
|
|
||||||
|
|
||||||
def start_game():
|
def start_game():
|
||||||
"""Start the game"""
|
"""Start the game"""
|
||||||
cmd_string = get_run_game_id_command(GAME_ID)
|
cmd_string = get_run_game_id_command(GAME_ID)
|
||||||
logging.info("%s %s", EXECUTABLE_PATH, cmd_string)
|
logging.info("%s %s", EXECUTABLE_PATH, cmd_string)
|
||||||
return Popen([EXECUTABLE_PATH, cmd_string])
|
return Popen([EXECUTABLE_PATH, cmd_string])
|
||||||
|
|
||||||
|
|
||||||
def run_benchmark():
|
def run_benchmark():
|
||||||
"""Run the test!"""
|
"""Run the test!"""
|
||||||
copy_replay()
|
copy_replay()
|
||||||
@@ -161,6 +164,7 @@ def run_benchmark():
|
|||||||
terminate_processes(PROCESS_NAME)
|
terminate_processes(PROCESS_NAME)
|
||||||
return test_start_time, test_end_time
|
return test_start_time, test_end_time
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
start_time, end_time = run_benchmark()
|
start_time, end_time = run_benchmark()
|
||||||
height, width = get_resolution()
|
height, width = get_resolution()
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
"""Rocket League test utils"""
|
"""Rocket League test utils"""
|
||||||
from argparse import ArgumentParser
|
from argparse import ArgumentParser
|
||||||
import winreg
|
import winreg
|
||||||
import os
|
import getpass
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
USERNAME = os.getlogin()
|
USERNAME = getpass.getuser()
|
||||||
SCRIPT_DIRECTORY = os.path.dirname(os.path.realpath(__file__))
|
SCRIPT_DIRECTORY = Path(__file__).resolve().parent
|
||||||
REPLAY_LOCATION = f"C:\\Users\\{USERNAME}\\Documents\\My Games\\Rocket League\\TAGame\\Demos"
|
REPLAY_LOCATION = Path(
|
||||||
config_path = f"C:\\Users\\{USERNAME}\\Documents\\My Games\\Rocket League\\TAGame\\Config\\TASystemSettings.ini"
|
f"C:\\Users\\{USERNAME}\\Documents\\My Games\\Rocket League\\TAGame\\Demos")
|
||||||
|
CONFIG_PATH = Path(
|
||||||
|
f"C:\\Users\\{USERNAME}\\Documents\\My Games\\Rocket League\\TAGame\\Config\\TASystemSettings.ini")
|
||||||
DEFAULT_EXECUTABLE_NAME = "EpicGamesLauncher.exe"
|
DEFAULT_EXECUTABLE_NAME = "EpicGamesLauncher.exe"
|
||||||
|
|
||||||
|
|
||||||
def get_args() -> any:
|
def get_args() -> any:
|
||||||
"""Returns command line arg values"""
|
"""Returns command line arg values"""
|
||||||
parser = ArgumentParser()
|
parser = ArgumentParser()
|
||||||
@@ -22,14 +25,14 @@ def get_args() -> any:
|
|||||||
help="Port for Keras OCR service", required=True)
|
help="Port for Keras OCR service", required=True)
|
||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def get_resolution():
|
def get_resolution():
|
||||||
"""Get current resolution from settings file"""
|
"""Get current resolution from settings file"""
|
||||||
height_pattern = re.compile(r"^ResY=(\d+)")
|
height_pattern = re.compile(r"^ResY=(\d+)")
|
||||||
width_pattern = re.compile(r"^ResX=(\d+)")
|
width_pattern = re.compile(r"^ResX=(\d+)")
|
||||||
cfg = f"{config_path}"
|
|
||||||
height = 0
|
height = 0
|
||||||
width = 0
|
width = 0
|
||||||
with open(cfg, encoding="utf-8") as f:
|
with CONFIG_PATH.open(encoding="utf-8") as f:
|
||||||
lines = f.readlines()
|
lines = f.readlines()
|
||||||
for line in lines:
|
for line in lines:
|
||||||
height_match = height_pattern.search(line)
|
height_match = height_pattern.search(line)
|
||||||
@@ -42,23 +45,21 @@ def get_resolution():
|
|||||||
return (height, width)
|
return (height, width)
|
||||||
return (height, width)
|
return (height, width)
|
||||||
|
|
||||||
|
|
||||||
def copy_replay() -> None:
|
def copy_replay() -> None:
|
||||||
"""Copy replay to install directory"""
|
"""Copy replay to install directory"""
|
||||||
src_file = os.path.join(SCRIPT_DIRECTORY, "D83190474AB0043E7595FDB3E1EC12E0.replay")
|
|
||||||
is_valid_replay = os.path.isfile(src_file)
|
|
||||||
if not is_valid_replay:
|
|
||||||
raise Exception(f"Can't find replay file: {src_file}")
|
|
||||||
try:
|
try:
|
||||||
Path(REPLAY_LOCATION).mkdir(parents=True, exist_ok=True)
|
replay_file = "D83190474AB0043E7595FDB3E1EC12E0.replay"
|
||||||
except FileExistsError as e:
|
src_path = SCRIPT_DIRECTORY / replay_file
|
||||||
logging.error(
|
REPLAY_LOCATION.mkdir(parents=True, exist_ok=True)
|
||||||
"Could not directory - likely due to non-directory file existing at path.")
|
|
||||||
raise e
|
dest_path = REPLAY_LOCATION / replay_file
|
||||||
|
logging.info("Copying: %s -> %s", src_path, dest_path)
|
||||||
|
shutil.copy(src_path, dest_path)
|
||||||
|
except OSError as err:
|
||||||
|
logging.error("Could not copy replay file")
|
||||||
|
raise err
|
||||||
|
|
||||||
# Copy the replay over
|
|
||||||
destination_file = os.path.join(REPLAY_LOCATION, os.path.basename(src_file))
|
|
||||||
logging.info("Copying: %s -> %s", src_file, destination_file)
|
|
||||||
shutil.copy(src_file, destination_file)
|
|
||||||
|
|
||||||
def find_rocketleague_executable() -> any:
|
def find_rocketleague_executable() -> any:
|
||||||
"""Get path to rocket league executable"""
|
"""Get path to rocket league executable"""
|
||||||
@@ -69,6 +70,6 @@ def find_rocketleague_executable() -> any:
|
|||||||
value, _ = winreg.QueryValueEx(registry_key, "ModSdkCommand")
|
value, _ = winreg.QueryValueEx(registry_key, "ModSdkCommand")
|
||||||
winreg.CloseKey(registry_key)
|
winreg.CloseKey(registry_key)
|
||||||
return value
|
return value
|
||||||
# pylint:disable=undefined-variable
|
except OSError as err:
|
||||||
except WindowsError:
|
logging.error("Could not find executable path")
|
||||||
return None
|
raise err
|
||||||
|
|||||||
Reference in New Issue
Block a user