OslServerProcess#

class ansys.optislang.core.osl_process.OslServerProcess(executable: str | Path | None = None, project_path: str | Path | None = None, batch: bool = True, service: bool = False, port_range: Tuple[int, int] | None = None, password: str | None = None, no_run: bool | None = None, no_save: bool = False, force: bool = True, reset: bool = False, auto_relocate: bool = False, enable_tcp_server: bool = True, server_info: str | Path | None = None, log_server_events: bool = False, listener: Tuple[str, int] | None = None, listener_id: str | None = None, multi_listener: Iterable[Tuple[str, int, str | None]] | None = None, notifications: Iterable[ServerNotification] | None = None, shutdown_on_finished: bool = True, env_vars: Mapping[str, str] | None = None, logger=None, log_process_stdout: bool = True, log_process_stderr: bool = True, import_project_properties_file: str | Path | None = None, export_project_properties_file: str | Path | None = None, import_placeholders_file: str | Path | None = None, export_placeholders_file: str | Path | None = None, output_file: str | Path | None = None, dump_project_state: str | Path | None = None, opx_project_definition_file: str | Path | None = None, additional_args: Iterable[str] | None = None)#

Starts and controls local optiSLang server process.

Parameters:
executableOptional[Union[str, pathlib.Path]], optional

Path to the optiSLang executable file. Defaults to None.

project_pathOptional[Union[str, pathlib.Path]], optional

Path to the optiSLang project file. - If the project file exists, it is opened. - If the project file does not exist, a new project is created on the specified path. - If the path is None, a new project is created in the temporary directory. Defaults to None.

batchbool, optional

Determines whether to start optiSLang server in batch mode. Defaults to True.

..note:: Cannot be used in combination with service mode.

service: bool, optional

Determines whether to start optiSLang server in service mode. If True, batch argument is set to False. Defaults to False.

..note:: Cannot be used in combination with batch mode.

port_rangeTuple[int, int], optional

Defines the port range for optiSLang server. Defaults to None.

passwordOptional[str], optional

The server password. Use when communication with the server requires the request to contain a password entry. Defaults to None.

no_runOptional[bool], optional

Determines whether not to run the specified project when started in batch mode. Defaults to None.

Note

Only supported in batch mode.

no_savebool, optional

Determines whether not to save the specified project after all other actions are completed. Defaults to False.

Note

Only supported in batch mode.

forcebool, optional

Determines whether to force opening/processing specified project when started in batch mode even if issues occur. Defaults to True.

Note

Only supported in batch mode.

resetbool, optional

Determines whether to reset specified project after load. Defaults to False.

Note

Only supported in batch mode.

auto_relocatebool, optional

Determines whether to automatically relocate missing file paths. Defaults to False.

Note

Only supported in batch mode.

enable_tcp_serverbool, optional

Determines whether to enable optiSLang TCP server. Defaults to True.

server_infoOptional[Union[str, pathlib.Path]], optional

Path to the server information file. If a relative path is provided, it is considered to be relative to the project working directory. If None, no server information file will be written. Defaults to None.

log_commandsbool, optional

Determines whether to display server events in the Message log pane. Defaults to False.

listenerOptional[Tuple[str, int]], optional

Host and port of the remote listener (plain TCP/IP based) to be registered at optiSLang server. Defaults to None.

listener_idOptional[str], optional

Specific unique ID for the TCP listener. Defaults to None.

multi_listenerIterable[Tuple[str, int, Optional[str]]], optional

Multiple remote listeners (plain TCP/IP based) to be registered at optiSLang server. Each listener is a combination of host, port and (optionally) listener ID. Defaults to None.

notificationsOptional[Iterable[ServerNotification]], optional

Notifications to be sent to the listener. Defaults to None.

shutdown_on_finished: bool, optional

Shut down when execution is finished. Defaults to True.

Note

Only supported in batch mode.

env_varsOptional[Mapping[str, str]], optional

Additional environmental variables (key and value) for the optiSLang server process. Defaults to None.

loggerAny, optional

Object for logging. If None, standard logging object is used. Defaults to None.

log_process_stdoutbool, optional

Determines whether the process STDOUT is supposed to be logged. Defaults to True.

log_process_stderrbool, optional

Determines whether the process STDERR is supposed to be logged. Defaults to True.

import_project_properties_fileOptional[Union[str, pathlib.Path]], optional

Optional path to a project properties file to import. Defaults to None.

export_project_properties_fileOptional[Union[str, pathlib.Path]], optional

Optional path to a project properties file to export. Defaults to None.

Note

Only supported in batch mode.

import_placeholders_fileOptional[Union[str, pathlib.Path]], optional

Optional path to a placeholders file to import. Defaults to None.

export_placeholders_fileOptional[[str, pathlib.Path]], optional

Optional path to a placeholders file to export. Defaults to None.

Note

Only supported in batch mode.

output_fileOptional[Union[str, pathlib.Path]], optional

Optional path to an output file for writing project run results to. Defaults to None.

Note

Only supported in batch mode.

dump_project_stateOptional[Union[str, pathlib.Path]], optional

Optional path to a project state dump file to export. If a relative path is provided, it is considered to be relative to the project working directory. Defaults to None.

Note

Only supported in batch mode.

opx_project_definition_fileOptional[Union[str, pathlib.Path]], optional

Optional path to an OPX project definition file. Defaults to None.

Note

Only supported in batch mode.

additional_argsOptional[Iterable[str]], optional

Additional command line arguments used for execution of the optiSLang server process. Defaults to None.

Raises:
TypeError

Raised when the optiSLang executable is None.

FileNotFoundError

Raised when the optiSLang executable cannot be found.

ValueError

Raised when the path to the optiSLang project file is invalid.

Examples

Start optiSLang server process in batch with specified path to the optiSLang project. File paths are defined in Windows operating system.

>>> from ansys.optislang.core import OslServerProcess
>>> executable = r"C:\Program Files\ANSYS Inc\v221\optiSLang\optislang.com"
>>> project_path = r"C:\osl_project\project.opf"
>>> osl_process = OslServerProcess(executable, project_path)
>>> osl_process.start()

Methods

OslServerProcess.is_running()

Determine whether the optiSLang server process is running.

OslServerProcess.start([remove_ini_files])

Start new optiSLang server process.

OslServerProcess.terminate()

Terminate optiSLang server process.

OslServerProcess.wait_for_finished()

Wait for the process to finish.

Attributes

OslServerProcess.DEFAULT_PROJECT_FILE

OslServerProcess.additional_args

Additional command line arguments used for optiSLang server process execution.

OslServerProcess.auto_relocate

Get whether to automatically relocate missing file paths.

OslServerProcess.batch

Get whether the optiSLang server is supposed to be started in batch mode.

OslServerProcess.dump_project_state

Path to a project state dump file to export.

OslServerProcess.enable_tcp_server

Get whether to enable optiSLang TCP server.

OslServerProcess.env_vars

Additional environmental variables for the optiSLang server process.

OslServerProcess.executable

Path to the optiSLang executable file.

OslServerProcess.export_placeholders_file

Path to the placeholders export file.

OslServerProcess.export_project_properties_file

Path to the project properties export file.

OslServerProcess.import_placeholders_file

Path to the placeholders import file.

OslServerProcess.import_project_properties_file

Path to the project properties import file.

OslServerProcess.listener

Host and port of the remote listener.

OslServerProcess.listener_id

Specific unique ID for the TCP listener.

OslServerProcess.log_commands

Get whether to display server events in the Message log pane.

OslServerProcess.log_process_stderr

Get whether the STDERR of the optiSLang server process is to be logged.

OslServerProcess.log_process_stdout

Get whether the STDOUT of the optiSLang server process is to be logged.

OslServerProcess.logger

Object used for logging.

OslServerProcess.multi_listener

Multi remote listener definitions.

OslServerProcess.no_run

Get whether not to run the specified project when started in batch mode .

OslServerProcess.no_save

Get whether not to save the specified project after all other actions are completed.

OslServerProcess.notifications

Notifications which are sent to the listener.

OslServerProcess.opx_project_definition_file

Path to the OPX project definition file.

OslServerProcess.output_file

Path to the output file for writing project run results to.

OslServerProcess.password

Server password.

OslServerProcess.pid

Process ID.

OslServerProcess.port_range

Port range for optiSLang server execution.

OslServerProcess.project_path

Path to the optiSLang project file.

OslServerProcess.reset

Get whether to reset specified project after load.

OslServerProcess.server_info

Path to the server information file.

OslServerProcess.shutdown_on_finished

Whether to shut down when execution is finished.