From 30ac8ea5bc4802176a51e06dca640875abadbbd1 Mon Sep 17 00:00:00 2001 From: George Marchment <georgemarchment@yahoo.fr> Date: Wed, 23 Apr 2025 10:47:26 +0200 Subject: [PATCH] Update the extraction of the tools in processes --- src/outils.py | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/src/outils.py b/src/outils.py index a4da11a..6d23850 100644 --- a/src/outils.py +++ b/src/outils.py @@ -1565,20 +1565,25 @@ def extract_tools(script, extract_general_tools = False): command = command[:-1] if(command[0]=="&"): command = command[1:] - test_apptainer = True - #In the case the command is "var = ..." we don't run it - for match in re.finditer(r"\w+\s*=", command): - if(match.span(0)[0]==0): - test_apptainer = False - #Running the command in the empty environment - if(test_apptainer): - apptainer_command = f"apptainer exec ../ressources/empty.sif {command} >> output.txt 2>&1" - f = open("apptainer_script.sh", "w") - f.write(apptainer_command) - f.close() - os.system(f"chmod +x apptainer_script.sh") - #apptainer pull empty.sif docker://cfgarden/empty - os.system(f"./apptainer_script.sh >> .out 2>&1 && rm -rf .out") + for c in command.split(";"): + c = c.strip() + test_apptainer = True + if(c[:len("do ")]=="do "): + c = c[len("do "):] + c = c.strip() + #In the case the command is "var = ..." we don't run it + for match in re.finditer(r"\w+\s*=", c): + if(match.span(0)[0]==0): + test_apptainer = False + #Running the command in the empty environment + if(test_apptainer): + apptainer_command = f"apptainer exec ../ressources/empty.sif {c} >> output.txt 2>&1" + f = open("apptainer_script.sh", "w") + f.write(apptainer_command) + f.close() + os.system(f"chmod +x apptainer_script.sh") + #apptainer pull empty.sif docker://cfgarden/empty + os.system(f"./apptainer_script.sh >> .out 2>&1 && rm -rf .out") #Parsing the error to extarct the tool -- GitLab