diff --git a/src/outils.py b/src/outils.py index a4da11a5c2551cd94ff273b4897876e5d341e012..6d23850a316cd3111b14b260f44c7fa410048a3e 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