Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposing more internal properties. #2246

Merged
merged 2 commits into from
Aug 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/ansys/mapdl/core/mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,25 @@ def is_console(self):
"""Return true if using console to connect to the MAPDL instance."""
return self._mode == "console"

@property
def exited(self):
"""Return true if the MAPDL session exited"""
return self._exited

@property
def check_status(self):
"""Return MAPDL status.
* 'exited' if MAPDL is exited
* 'exiting' if MAPDL is exiting
* Otherwise returns 'OK'.
"""
if self.exited:
return "exited"
elif self.exiting:
return "exiting"
else:
return "OK"

@property
def file_type_for_plots(self):
"""Returns the current file type for plotting."""
Expand Down
17 changes: 16 additions & 1 deletion src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,9 +941,24 @@ def _run(self, cmd: str, verbose: bool = False, mute: Optional[bool] = None) ->

@property
def busy(self):
"""True when MAPDL gRPC server is executing a command"""
"""True when MAPDL gRPC server is executing a command."""
return self._busy

@property
def exiting(self):
"""Returns true if the MAPDL instance is exiting."""
return self._exiting

@property
def port(self):
"""Returns the MAPDL gRPC instance port."""
return self._port

@property
def ip(self):
"""Return the MAPDL gRPC instance IP."""
return self._ip

@protect_grpc
def _send_command(self, cmd: str, mute: bool = False) -> Optional[str]:
"""Send a MAPDL command and return the response as a string"""
Expand Down
34 changes: 34 additions & 0 deletions tests/test_mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2087,3 +2087,37 @@ def test_plots_no_vtk(mapdl):
mapdl.vplot(vtk=False)
mapdl.nplot(vtk=False)
mapdl.eplot(vtk=False)


def test_exited(mapdl):
assert mapdl.exited == mapdl._exited
assert isinstance(mapdl.exited, bool)


def test_exiting(mapdl):
assert mapdl.exiting == mapdl._exiting
assert isinstance(mapdl.exiting, bool)


def test_check_status(mapdl):
assert mapdl.check_status == "OK"

mapdl._exited = True
assert mapdl.exited
assert mapdl.check_status == "exited"
mapdl._exited = False

mapdl._exiting = True
assert mapdl.exiting
assert mapdl.check_status == "exiting"
mapdl._exiting = False


def test_ip(mapdl):
assert mapdl._ip == mapdl.ip
assert isinstance(mapdl.ip, str)


def test_port(mapdl):
assert mapdl.port == mapdl._port
assert isinstance(mapdl.port, int)