Skip to content

Commit e16f3b7

Browse files
committed
define execute as depreciated
1 parent 28ce89b commit e16f3b7

1 file changed

Lines changed: 8 additions & 18 deletions

File tree

OMPython/__init__.py

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import importlib
3131
import zmq
3232
import pathlib
33+
import warnings
3334

3435

3536
if sys.platform == 'darwin':
@@ -268,19 +269,15 @@ def _set_omc_command(self, omc_path_and_args_list):
268269
def _connect_to_omc(self, timeout):
269270
pass
270271

271-
# FIXME: we should have one function which interacts with OMC. Either execute OR sendExpression.
272-
# Execute uses OMParser.check_for_values and sendExpression uses OMTypedParser.parseString.
273-
# We should have one parser. Then we can get rid of one of these functions.
274-
@abc.abstractmethod
275-
def execute(self, command):
276-
pass
277-
278272
def clearOMParserResult(self):
279273
OMParser.result = {}
280274

281-
# FIXME: we should have one function which interacts with OMC. Either execute OR sendExpression.
282-
# Execute uses OMParser.check_for_values and sendExpression uses OMTypedParser.parseString.
283-
# We should have one parser. Then we can get rid of one of these functions.
275+
def execute(self, command):
276+
warnings.warn("This function is depreciated and will be removed in future versions; "
277+
"please use sendExpression() instead", DeprecationWarning, stacklevel=1)
278+
279+
return self.sendExpression(command, parsed=False)
280+
284281
@abc.abstractmethod
285282
def sendExpression(self, command, parsed=True):
286283
"""
@@ -312,10 +309,7 @@ def ask(self, question, opt=None, parsed=True):
312309
logger.debug('OMC ask: {0} - parsed: {1}'.format(expression, parsed))
313310

314311
try:
315-
if parsed:
316-
res = self.execute(expression)
317-
else:
318-
res = self.sendExpression(expression, parsed=False)
312+
res = self.sendExpression(expression, parsed=parsed)
319313
except Exception as e:
320314
logger.error("OMC failed: {0}, {1}, parsed={2}".format(question, opt, parsed))
321315
raise e
@@ -601,10 +595,6 @@ def _connect_to_omc(self, timeout):
601595
self._omc.setsockopt(zmq.IMMEDIATE, True) # Queue messages only to completed connections
602596
self._omc.connect(self._port)
603597

604-
def execute(self, command):
605-
# check for process is running
606-
return self.sendExpression(command, parsed=False)
607-
608598
def sendExpression(self, command, parsed=True):
609599
# check for process is running
610600
p = self._omc_process.poll()

0 commit comments

Comments
 (0)