The misc.py module#
Summary#
Check if the host machine is on Windows. |
|
Get the path for the Mechanical executable file based on the release version. |
|
Decorate a function with this decorator to call it using a thread. |
|
Decorate a function with this decorator to call it using a daemon thread. |
|
Check if the IP address is valid. |
|
Check if the port is valid. |
|
Check if the value obtained from the environmental variable is valid. |
|
Check if a string can be converted to a float. |
|
Check if the Mechanical version supports advanced gRPC security options. |
|
Get the required service pack message for a given version. |
|
Check if the host machine is Linux. |
|
Resolve the certificate directory for mTLS connections. |
Description#
Contain miscellaneous functions and methods at the module level.
Module detail#
- misc.is_windows()#
Check if the host machine is on Windows.
- Returns:
TrueifthehostmachineisonWindows,Falseotherwise.
- misc.get_mechanical_bin(release_version)#
Get the path for the Mechanical executable file based on the release version.
- Parameters:
- release_version: str
Mechanical version using the three-digit format. For example,
"252"for 2025 R2.
- misc.threaded(func)#
Decorate a function with this decorator to call it using a thread.
- misc.threaded_daemon(func)#
Decorate a function with this decorator to call it using a daemon thread.
- misc.check_valid_port(port, lower_bound=1000, high_bound=60000)#
Check if the port is valid.
- misc.check_valid_start_instance(start_instance)#
Check if the value obtained from the environmental variable is valid.
- misc.is_float(input_string)#
Check if a string can be converted to a float.
- misc.has_grpc_service_pack(version)#
Check if the Mechanical version supports advanced gRPC security options.
Advanced gRPC options (transport modes and host binding) require specific service packs: - 2024 R2 (242): requires SP05+ - 2025 R1 (251): requires SP04+ - 2025 R2 (252): requires SP03+ - 2026 R1 (261)+: all versions supported
- misc.get_service_pack_message(version)#
Get the required service pack message for a given version.
- misc.is_linux() bool#
Check if the host machine is Linux.
- Returns:
TrueifthehostmachineisLinux,Falseotherwise.
- misc.resolve_certs_dir(transport_mode, certs_dir=None)#
Resolve the certificate directory for mTLS connections.
Checks the ANSYS_GRPC_CERTIFICATES environment variable if: - transport_mode is “mtls” - certs_dir is None (not explicitly provided by user) - On Windows: only if the variable is set at user level - On Linux: at any level