run_python_script#

abstractmethod Project.run_python_script(script: str, args: Sequence[object] | None = None, run_async: bool = False) → Tuple[str, str] | str#

Load a Python script in a project context and run it.

Parameters:
scriptstr

Python commands to execute on the server.

argsSequence[object], None, optional

Sequence of arguments used in the Python script. The default is None.

run_async: bool, optional

Whether to run the python script as an asynchronous, non-blocking long running operation. If True, this method returns immediately with the ID of the long running operation instead of the script output. By default False.

Note

Argument is supported for Ansys optiSLang version >= 27.1 only.

Returns:
Union[Tuple[str, str], str]

STDOUT and STDERR from the executed Python script, or the ID of the long running operation if run_async is True.

Raises:
OslCommunicationError

Raised when an error occurs while communicating with the server.

OslCommandError

Raised when a command or query fails.

OslVersionError

Raised when run_async is True and the connected Ansys optiSLang server is older than version 27.1.

TimeoutError

Raised when the timeout float value expires.