|
30 | 30 | import importlib |
31 | 31 | import zmq |
32 | 32 | import pathlib |
| 33 | +import warnings |
33 | 34 |
|
34 | 35 |
|
35 | 36 | if sys.platform == 'darwin': |
@@ -268,19 +269,15 @@ def _set_omc_command(self, omc_path_and_args_list): |
268 | 269 | def _connect_to_omc(self, timeout): |
269 | 270 | pass |
270 | 271 |
|
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 | | - |
278 | 272 | def clearOMParserResult(self): |
279 | 273 | OMParser.result = {} |
280 | 274 |
|
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 | + |
284 | 281 | @abc.abstractmethod |
285 | 282 | def sendExpression(self, command, parsed=True): |
286 | 283 | """ |
@@ -312,10 +309,7 @@ def ask(self, question, opt=None, parsed=True): |
312 | 309 | logger.debug('OMC ask: {0} - parsed: {1}'.format(expression, parsed)) |
313 | 310 |
|
314 | 311 | 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) |
319 | 313 | except Exception as e: |
320 | 314 | logger.error("OMC failed: {0}, {1}, parsed={2}".format(question, opt, parsed)) |
321 | 315 | raise e |
@@ -601,10 +595,6 @@ def _connect_to_omc(self, timeout): |
601 | 595 | self._omc.setsockopt(zmq.IMMEDIATE, True) # Queue messages only to completed connections |
602 | 596 | self._omc.connect(self._port) |
603 | 597 |
|
604 | | - def execute(self, command): |
605 | | - # check for process is running |
606 | | - return self.sendExpression(command, parsed=False) |
607 | | - |
608 | 598 | def sendExpression(self, command, parsed=True): |
609 | 599 | # check for process is running |
610 | 600 | p = self._omc_process.poll() |
|
0 commit comments