From a7452d2dde24e0107660ec037e1b1acb8cfcd377 Mon Sep 17 00:00:00 2001 From: WillB97 Date: Sat, 12 Oct 2024 15:36:11 +0100 Subject: [PATCH] Also support running webots from appdata --- scripts/run_simulator.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/scripts/run_simulator.py b/scripts/run_simulator.py index eb5b326..8b9f301 100755 --- a/scripts/run_simulator.py +++ b/scripts/run_simulator.py @@ -8,6 +8,7 @@ import sys import traceback +from os.path import expandvars from pathlib import Path from shutil import which from subprocess import Popen @@ -43,7 +44,17 @@ def get_webots_parameters() -> tuple[Path, Path]: if sys.platform == "darwin": webots = "/Applications/Webots.app/Contents/MacOS/webots" elif sys.platform == "win32": - webots = "C:\\Program Files\\Webots\\msys64\\mingw64\\bin\\webotsw.exe" + possible_paths = [ + "C:\\Program Files\\Webots\\msys64\\mingw64\\bin\\webotsw.exe", + expandvars("%LOCALAPPDATA%\\Programs\\Webots\\msys64\\mingw64\\bin\\webotsw.exe"), + ] + for path in possible_paths: + if Path(path).exists(): + webots = path + break + else: + print("Webots executable not found.") + raise RuntimeError elif sys.platform.startswith("linux"): possible_paths = ["/usr/local/bin/webots", "/usr/bin/webots"] for path in possible_paths: