Skip to content
16 changes: 16 additions & 0 deletions src/ansys/dpf/core/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import platform
import glob
import os
import re

import packaging.version
import pkg_resources
import importlib
from pkgutil import iter_modules
from ansys.dpf.core import errors
from ansys.dpf.gate._version import __ansys_version__
from ansys.dpf.gate import load_api

Expand Down Expand Up @@ -97,6 +99,20 @@ def get_ansys_path(ansys_path=None):
'- when starting the server with "start_local_server(ansys_path=*/vXXX)"\n'
'- or by setting it by default with the environment variable "ANSYS_DPF_PATH"'
)
# parse the version to an int and check for supported
ansys_folder_name = str(ansys_path).split(os.sep)[-1]
reobj_vXYZ = re.compile(
"^v[0123456789]{3}$"
)
if reobj_vXYZ.match(ansys_folder_name):
# vXYZ Unified Install folder
ver = int(str(ansys_path)[-3:])
else:
ver = 222
if ver < 211:
raise errors.InvalidANSYSVersionError(f"Ansys v{ver} does not support DPF")
if ver == 211 and is_ubuntu():
raise OSError("DPF on v211 does not support Ubuntu")
return ansys_path


Expand Down
9 changes: 0 additions & 9 deletions src/ansys/dpf/core/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,15 +190,6 @@ def start_local_server(
use_pypim = use_pypim_by_default and is_pypim_configured()
if not use_docker and not use_pypim:
ansys_path = get_ansys_path(ansys_path)
# parse the version to an int and check for supported
try:
ver = int(str(ansys_path)[-3:])
if ver < 211:
raise errors.InvalidANSYSVersionError(f"Ansys v{ver} does not support DPF")
if ver == 211 and is_ubuntu():
raise OSError("DPF on v211 does not support Ubuntu")
except ValueError:
pass

# avoid using any ports in use from existing servers
used_ports = []
Expand Down
8 changes: 5 additions & 3 deletions src/ansys/dpf/core/server_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,10 +427,12 @@ def info(self):
-------
info : dictionary
Dictionary with server information, including ``"server_ip"``,
``"server_port"``, ``"server_process_id"``, and
``"server_version"`` keys.
``"server_port"``, ``"server_process_id"``, ``"server_version"`` , ``"os"``
and ``"path"`` keys.
"""
return self._base_service.server_info
server_info = self._base_service.server_info
server_info["path"] = self.ansys_path
return server_info

def _del_session(self):
if self._session_instance:
Expand Down