From 7f929238defb06862eb29b22611f40d8966ce589 Mon Sep 17 00:00:00 2001 From: "clemens.fricke" Date: Thu, 7 Sep 2023 14:03:41 +0200 Subject: [PATCH] Run_all_examples script hardened, against calling from outside of parent folder. --- examples/run_all_examples.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/run_all_examples.py b/examples/run_all_examples.py index 9c29fc6d4..32189d48d 100644 --- a/examples/run_all_examples.py +++ b/examples/run_all_examples.py @@ -1,14 +1,15 @@ """Call all *.py files in the working directory. """ import glob +import pathlib import subprocess import sys if __name__ == "__main__": files_not_completed = [] - for file in glob.glob("*.py"): - if file == "run_all_examples.py": + for file in glob.glob(str(pathlib.Path(__file__).parent) + "/*.py"): + if file.split("/")[-1] == "run_all_examples.py": continue print(f"Calling {file}") proc_return = subprocess.run([sys.executable, file])