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:
- executable
Optional
[Union
[str
,pathlib.Path
]],optional
Path to the optiSLang executable file. Defaults to
None
.- project_path
Optional
[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 toFalse
. Defaults toFalse
...note:: Cannot be used in combination with batch mode.
- port_range
Tuple
[int
,int
],optional
Defines the port range for optiSLang server. Defaults to
None
.- password
Optional
[str
],optional
The server password. Use when communication with the server requires the request to contain a password entry. Defaults to
None
.- no_run
Optional
[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_info
Optional
[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 toNone
.- log_commandsbool,
optional
Determines whether to display server events in the Message log pane. Defaults to
False
.- listener
Optional
[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_id
Optional
[str
],optional
Specific unique ID for the TCP listener. Defaults to
None
.- multi_listener
Iterable
[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
.- notifications
Optional
[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_vars
Optional
[Mapping
[str
,str
]],optional
Additional environmental variables (key and value) for the optiSLang server process. Defaults to
None
.- logger
Any
,optional
Object for logging. If
None
, standard logging object is used. Defaults toNone
.- 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_file
Optional
[Union
[str
,pathlib.Path
]],optional
Optional path to a project properties file to import. Defaults to
None
.- export_project_properties_file
Optional
[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_file
Optional
[Union
[str
,pathlib.Path
]],optional
Optional path to a placeholders file to import. Defaults to
None
.- export_placeholders_file
Optional
[[str
,pathlib.Path
]],optional
Optional path to a placeholders file to export. Defaults to
None
.Note
Only supported in batch mode.
- output_file
Optional
[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_state
Optional
[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_file
Optional
[Union
[str
,pathlib.Path
]],optional
Optional path to an OPX project definition file. Defaults to
None
.Note
Only supported in batch mode.
- additional_args
Optional
[Iterable
[str
]],optional
Additional command line arguments used for execution of the optiSLang server process. Defaults to
None
.
- executable
- 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
Determine whether the optiSLang server process is running.
OslServerProcess.start
([remove_ini_files])Start new optiSLang server process.
Terminate optiSLang server process.
Wait for the process to finish.
Attributes
Additional command line arguments used for optiSLang server process execution.
Get whether to automatically relocate missing file paths.
Get whether the optiSLang server is supposed to be started in batch mode.
Path to a project state dump file to export.
Get whether to enable optiSLang TCP server.
Additional environmental variables for the optiSLang server process.
Path to the optiSLang executable file.
Path to the placeholders export file.
Path to the project properties export file.
Path to the placeholders import file.
Path to the project properties import file.
Host and port of the remote listener.
Specific unique ID for the TCP listener.
Get whether to display server events in the Message log pane.
Get whether the STDERR of the optiSLang server process is to be logged.
Get whether the STDOUT of the optiSLang server process is to be logged.
Object used for logging.
Multi remote listener definitions.
Get whether not to run the specified project when started in batch mode .
Get whether not to save the specified project after all other actions are completed.
Notifications which are sent to the listener.
Path to the OPX project definition file.
Path to the output file for writing project run results to.
Server password.
Process ID.
Port range for optiSLang server execution.
Path to the optiSLang project file.
Get whether to reset specified project after load.
Path to the server information file.
Whether to shut down when execution is finished.