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

feat: adding option to _ctrl command #3002

Merged
merged 6 commits into from
Apr 18, 2024
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: 10 additions & 9 deletions src/ansys/mapdl/core/mapdl_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1411,18 +1411,19 @@ def _download(targets: List[str]) -> None:
return os.path.join(path, jobname + "0." + preference)

@protect_grpc
def _ctrl(self, cmd):
"""Issue control command to the mapdl server
def _ctrl(self, cmd: str, opt1: str = ""):
"""Issue control command to the MAPDL server.

Available commands:
clatapie marked this conversation as resolved.
Show resolved Hide resolved

- 'EXIT'
- ``EXIT``
Calls exit(0) on the server.

- 'set_verb'
- ``set_verb``
Enables verbose mode on the server.
In this case, the verbosity level is set using ``opt1`` argument.

- 'VERSION'
- ``VERSION``
Returns version string in of the server in the form
"MAJOR.MINOR.PATCH". E.g. "0.3.0". Known versions
include:
Expand All @@ -1433,16 +1434,16 @@ def _ctrl(self, cmd):

Unavailable/Flaky:

- 'time_stats'
- ``time_stats``
Prints a table for time stats on the server.
This command appears to be disabled/broken.

- 'mem-stats'
- ``mem-stats``
To be added

"""
self._log.debug('Issuing CtrlRequest "%s"', cmd)
request = anskernel.CtrlRequest(ctrl=cmd)
self._log.debug(f'Issuing CtrlRequest "{cmd}" with option "{opt1}".')
request = anskernel.CtrlRequest(ctrl=str(cmd), opt1=str(opt1))

# handle socket closing upon exit
if cmd.lower() == "exit":
Expand Down
5 changes: 5 additions & 0 deletions tests/test_mapdl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2447,3 +2447,8 @@ def test_not_correct_et_element(mapdl):
mapdl.et(1, 227)
with pytest.warns(UserWarning, match="is normal behavior when a CDB file is used"):
mapdl.keyopt(1, 222)


def test_ctrl(mapdl):
mapdl._ctrl("set_verb", 5) # Setting verbosity on the server
mapdl._ctrl("set_verb", 0) # Returning to non-verbose
Loading