From 8b68a92940ed242e6590042dd67399240638bb79 Mon Sep 17 00:00:00 2001 From: Arty Blue Date: Fri, 27 Sep 2024 08:44:34 -0700 Subject: [PATCH] results screenshot and saving of config file at the end of the run --- total_war_warhammer_iii/twwh3.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/total_war_warhammer_iii/twwh3.py b/total_war_warhammer_iii/twwh3.py index db72241..da1264a 100644 --- a/total_war_warhammer_iii/twwh3.py +++ b/total_war_warhammer_iii/twwh3.py @@ -2,6 +2,7 @@ from argparse import ArgumentParser import logging import os +from pathlib import Path import time import sys import pyautogui as gui @@ -21,12 +22,19 @@ from harness_utils.output import ( ) from harness_utils.steam import get_app_install_location from harness_utils.keras_service import KerasService +from harness_utils.artifacts import ArtifactManager, ArtifactType SCRIPT_DIRECTORY = os.path.dirname(os.path.realpath(__file__)) LOG_DIRECTORY = os.path.join(SCRIPT_DIRECTORY, "run") PROCESS_NAME = "Warhammer3.exe" STEAM_GAME_ID = 1142710 +APPDATA = os.getenv("APPDATA") +CONFIG_LOCATION = f"{APPDATA}\\The Creative Assembly\\Warhammer3\\scripts" +CONFIG_FILENAME = "preferences.script.txt" + +cfg = f"{CONFIG_LOCATION}\\{CONFIG_FILENAME}" + user.FAILSAFE = False @@ -63,6 +71,8 @@ def run_benchmark(): start_game() setup_start_time = time.time() time.sleep(5) + + am = ArtifactManager(LOG_DIRECTORY) result = kerasService.look_for_word("warning", attempts=10, interval=5) if not result: @@ -84,6 +94,8 @@ def run_benchmark(): gui.mouseUp() time.sleep(2) + am.take_screenshot("main.png", ArtifactType.CONFIG_IMAGE, "picture of basic settings") + result = kerasService.look_for_word("ad", attempts=10, interval=1) if not result: logging.info("Did not find the advanced menu. Did the game skip the intros?") @@ -96,6 +108,8 @@ def run_benchmark(): gui.mouseUp() time.sleep(0.5) + am.take_screenshot("advanced.png", ArtifactType.CONFIG_IMAGE, "picture of advanced settings") + result = kerasService.look_for_word("bench", attempts=10, interval=1) if not result: logging.info("Did not find the benchmark menu. Did the game skip the intros?") @@ -144,6 +158,9 @@ def run_benchmark(): # Wait 5 seconds for benchmark info time.sleep(5) + am.take_screenshot("result.png", ArtifactType.RESULTS_IMAGE, "benchmark results") + am.copy_file(Path(cfg), ArtifactType.RESULTS_TEXT, "preferences.script.txt") + # End the run elapsed_test_time = round(test_end_time - test_start_time, 2) logging.info("Benchmark took %f seconds", elapsed_test_time)