From 158f31c44fe74f04746efac5ea4c2ef4e54b9fdf Mon Sep 17 00:00:00 2001 From: Nikolas Date: Wed, 17 Apr 2024 15:49:31 -0700 Subject: [PATCH] linter fixes --- pugetbench/pugetbench.py | 14 ++++++-------- pugetbench/utils.py | 7 ++++++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/pugetbench/pugetbench.py b/pugetbench/pugetbench.py index 0b3147a..3032397 100644 --- a/pugetbench/pugetbench.py +++ b/pugetbench/pugetbench.py @@ -1,5 +1,4 @@ """pugetbench for creators test script""" -import win32api import logging import os.path from pathlib import Path @@ -16,8 +15,7 @@ from harness_utils.output import ( seconds_to_milliseconds, setup_log_directory, write_report_json, - DEFAULT_LOGGING_FORMAT, - DEFAULT_DATE_FORMAT, + DEFAULT_LOGGING_FORMAT ) script_dir = os.path.dirname(os.path.realpath(__file__)) @@ -32,11 +30,12 @@ formatter = logging.Formatter(DEFAULT_LOGGING_FORMAT) console.setFormatter(formatter) logging.getLogger('').addHandler(console) -executable_name = "PugetBench for Creators.exe" +EXECUTABLE_NAME = "PugetBench for Creators.exe" def run_benchmark(application: str, app_version: str) -> Popen: + """run benchmark""" start_time = time.time() - executable_path = Path(f"C:\\Program Files\\PugetBench for Creators\\{executable_name}") + executable_path = Path(f"C:\\Program Files\\PugetBench for Creators\\{EXECUTABLE_NAME}") command_args = ["--run_count" , "1", "--rerun_count", "1", "--benchmark_version", "1.0.0", "--preset", "Standard", "--app_version", f"{app_version}"] photoshop_args = command_args + ["--app", "photoshop"] premiere_args = command_args + ["--app", "premierepro"] @@ -46,12 +45,12 @@ def run_benchmark(application: str, app_version: str) -> Popen: process = Popen([executable_path] + premiere_args) elif application == "photoshop": process = Popen([executable_path] + photoshop_args) - exit_code = process.wait() end_time = time.time() return start_time, end_time, exit_code def main(): + """main""" start_time = time.time() parser = ArgumentParser() parser.add_argument( @@ -88,7 +87,6 @@ def main(): if exit_code > 0: logging.error("Test failed!") sys.exit(exit_code) - log_file = find_latest_log() score = find_score_in_log(log_file) destination = Path(script_dir) / "run" / os.path.split(log_file)[1] @@ -105,7 +103,7 @@ def main(): except Exception as e: logging.error("Something went wrong running the benchmark!") logging.exception(e) - terminate_processes(executable_name) + terminate_processes(EXECUTABLE_NAME) sys.exit(1) diff --git a/pugetbench/utils.py b/pugetbench/utils.py index 9f5251e..da5a3ab 100644 --- a/pugetbench/utils.py +++ b/pugetbench/utils.py @@ -1,11 +1,12 @@ +"""utils file for pugetbench harness""" import re import os from pathlib import Path import win32api -from win32com.client import Dispatch def find_latest_log(): + """find latest log from pugetbench""" appdata_path = os.getenv('LOCALAPPDATA') puget_lunch_dir = Path(appdata_path) / "com.puget.benchmark" / "csv" files = [os.path.join(puget_lunch_dir, file) for file in os.listdir( @@ -16,6 +17,7 @@ def find_latest_log(): def find_score_in_log(log_path): + """find score in pugentbench log file""" with open(log_path, 'r') as file: for line in file: score = is_score_line(line) @@ -24,6 +26,7 @@ def find_score_in_log(log_path): def is_score_line(line): + """check if string is a score using regex""" regex_pattern = r"^Overall Score.+,+(\d+),+" match = re.search(regex_pattern, line) if match and len(match.groups()) > 0: @@ -32,6 +35,7 @@ def is_score_line(line): return None def get_photoshop_version() -> str: + """get current photoshop version string""" path = "C:\\Program Files\\Adobe\\Adobe Photoshop 2024\\Photoshop.exe" try: lang, codepage = win32api.GetFileVersionInfo(path, "\\VarFileInfo\\Translation")[0] @@ -42,6 +46,7 @@ def get_photoshop_version() -> str: return None def get_premierepro_version() -> str: + """get current premiere pro version string""" path = "C:\\Program Files\\Adobe\\Adobe Premiere Pro 2024\\Adobe Premiere Pro.exe" try: lang, codepage = win32api.GetFileVersionInfo(path, "\\VarFileInfo\\Translation")[0]