Skip to content

Commit 811c035

Browse files
SMoraisAnsyspyansys-ci-botMaxJPRey
authored
DOCS: Add log and nosec in checked subprocess calls (#6001)
Co-authored-by: pyansys-ci-bot <[email protected]> Co-authored-by: Maxime Rey <[email protected]>
1 parent b21e9cb commit 811c035

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

doc/changelog.d/6001.documentation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add log and nosec in checked subprocess calls

doc/source/Resources/pyaedt_installer_from_aedt.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
import sys
3030

3131
try:
32-
import subprocess
32+
import subprocess # nosec
3333
except ImportError:
34-
import subprocessdotnet as subprocess
34+
import subprocessdotnet as subprocess # nosec
3535

3636
is_iron_python = platform.python_implementation().lower() == "ironpython"
3737
is_linux = os.name == "posix"
@@ -99,7 +99,7 @@ def run_pyinstaller_from_c_python(oDesktop):
9999
command.extend([r'--wheel={}'.format(wheelpyaedt)])
100100

101101
oDesktop.AddMessage("", "", 0, "Installing PyAEDT.")
102-
return_code = subprocess.call(command)
102+
return_code = subprocess.call(command) # nosec
103103

104104
err_msg = "There was an error while installing PyAEDT."
105105
if is_linux:
@@ -153,7 +153,7 @@ def run_pyinstaller_from_c_python(oDesktop):
153153

154154
command = r'"{}" "{}"'.format(python_exe, python_script)
155155
oDesktop.AddMessage("", "", 0, "Configuring PyAEDT panels in automation tab.")
156-
ret_code = subprocess.call([python_exe, python_script])
156+
ret_code = subprocess.call([python_exe, python_script]) # nosec
157157
if ret_code != 0:
158158
oDesktop.AddMessage("", "", 2, "Error occurred configuring the PyAEDT panels.")
159159
return
@@ -249,9 +249,9 @@ def install_pyaedt():
249249
if not venv_dir.exists():
250250
print("Creating the virtual environment in {}".format(venv_dir))
251251
if args.version <= "231":
252-
subprocess.run([sys.executable, "-m", "venv", str(venv_dir), "--system-site-packages"], check=True)
252+
subprocess.run([sys.executable, "-m", "venv", str(venv_dir), "--system-site-packages"], check=True) # nosec
253253
else:
254-
subprocess.run([sys.executable, "-m", "venv", str(venv_dir)], check=True)
254+
subprocess.run([sys.executable, "-m", "venv", str(venv_dir)], check=True) # nosec
255255

256256
if args.wheel and Path(args.wheel).exists():
257257
print("Installing PyAEDT using provided wheels argument")

doc/source/Resources/toolkit_installer_from_aedt.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
import os
2626
import sys
27-
import subprocessdotnet as subprocess
27+
import subprocessdotnet as subprocess # nosec
2828

2929
# This script installs PyAEDT tabs (PyAEDT Console, Jupyter, Run Script and Extension Manager)
3030
# using a specific Python interpreter.
@@ -58,7 +58,7 @@ def run_pyinstaller_from_c_python(oDesktop, pyaedt_interpreter):
5858

5959
command = [pyaedt_interpreter, python_script]
6060
oDesktop.AddMessage("", "", 0, "Configuring PyAEDT panels in automation tab.")
61-
process = subprocess.Popen(command)
61+
process = subprocess.Popen(command) # nosec
6262
process.wait()
6363

6464
# Refresh UI
@@ -80,9 +80,11 @@ def run_pyinstaller_from_c_python(oDesktop, pyaedt_interpreter):
8080
if __name__ == "__main__":
8181

8282
python_interpreter = os.getenv(pyaedt_enviroment_variable)
83-
if python_interpreter and not os.path.exists(python_interpreter):
84-
oDesktop.AddMessage("", "", 2, "Python environment does not exist.")
85-
sys.exit()
83+
if python_interpreter:
84+
oDesktop.AddMessage("", "", 0, "Using Python environment defined with the environment variable PYAEDT_INTERPRETER.")
85+
if os.path.exists(python_interpreter):
86+
oDesktop.AddMessage("", "", 2, "Python environment does not exist.")
87+
sys.exit()
8688

8789
# Check if interpreter path is defined.
8890
# Retrieve the script arguments

0 commit comments

Comments
 (0)