Skip to content

Commit cddbc9b

Browse files
committed
[OMCSessionABC] remove execute(); still available in compatibility v4.0.0
1 parent 2f07130 commit cddbc9b

3 files changed

Lines changed: 11 additions & 17 deletions

File tree

OMPython/OMCSession.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import logging
99
from typing import Any, Optional
10+
import warnings
1011

1112
import pyparsing
1213

@@ -272,7 +273,13 @@ def omcpath_tempdir(self, tempdir_base: Optional[OMPathABC] = None) -> OMPathABC
272273
return self.omc_process.omcpath_tempdir(tempdir_base=tempdir_base)
273274

274275
def execute(self, command: str):
275-
return self.omc_process.execute(command=command)
276+
warnings.warn(
277+
message="This function is depreciated and will be removed in future versions; "
278+
"please use sendExpression() instead",
279+
category=DeprecationWarning,
280+
stacklevel=2,
281+
)
282+
return self.omc_process.sendExpression(expr=command, parsed=False)
276283

277284
def sendExpression(self, command: str, parsed: bool = True) -> Any: # pylint: disable=W0237
278285
"""

OMPython/om_session_omc.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import time
2222
from typing import Any, Optional, Tuple
2323
import uuid
24-
import warnings
2524

2625
import psutil
2726
import pyparsing
@@ -403,16 +402,6 @@ def omcpath_tempdir(self, tempdir_base: Optional[OMPathABC] = None) -> OMPathABC
403402

404403
return self._tempdir(tempdir_base=tempdir_base)
405404

406-
def execute(self, command: str):
407-
warnings.warn(
408-
message="This function is depreciated and will be removed in future versions; "
409-
"please use sendExpression() instead",
410-
category=DeprecationWarning,
411-
stacklevel=2,
412-
)
413-
414-
return self.sendExpression(command, parsed=False)
415-
416405
def sendExpression(self, expr: str, parsed: bool = True) -> Any:
417406
"""
418407
Send an expression to the OMC server and return the result.

tests/test_ZMQ.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,12 @@ def test_Simulate(omcs, model_time_str):
3838
assert omcs.sendExpression('res.resultFile')
3939

4040

41-
def test_execute(omcs):
42-
with pytest.deprecated_call():
43-
assert omcs.execute('"HelloWorld!"') == '"HelloWorld!"\n'
41+
def test_sendExpression(omcs):
4442
assert omcs.sendExpression('"HelloWorld!"', parsed=False) == '"HelloWorld!"\n'
4543
assert omcs.sendExpression('"HelloWorld!"', parsed=True) == 'HelloWorld!'
4644

4745

48-
def test_omcprocessport_execute(omcs):
46+
def test_sendExpression_port(omcs):
4947
port = omcs.get_port()
5048
omcs2 = OMPython.OMCSessionPort(omc_port=port)
5149

@@ -58,7 +56,7 @@ def test_omcprocessport_execute(omcs):
5856
del omcs2
5957

6058

61-
def test_omcprocessport_simulate(omcs, model_time_str):
59+
def test_Simulate_port(omcs, model_time_str):
6260
port = omcs.get_port()
6361
omcs2 = OMPython.OMCSessionPort(omc_port=port)
6462

0 commit comments

Comments
 (0)