Skip to content

Commit a1130ab

Browse files
committed
[OMCSession] align definition of sendExpression() - use expr (was: command)
1 parent 3c80549 commit a1130ab

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

OMPython/ModelicaSystem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ def buildModel(self, variableFilter: Optional[str] = None):
561561

562562
def sendExpression(self, expr: str, parsed: bool = True) -> Any:
563563
try:
564-
retval = self._session.sendExpression(command=expr, parsed=parsed)
564+
retval = self._session.sendExpression(expr=expr, parsed=parsed)
565565
except OMCSessionException as ex:
566566
raise ModelicaSystemError(f"Error executing {repr(expr)}: {ex}") from ex
567567

OMPython/OMCSession.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ def _omc_resolve(self, pathstr: str) -> str:
372372
'cd(omcpath_cwd)')
373373

374374
try:
375-
result = self._session.sendExpression(command=expression, parsed=False)
375+
result = self._session.sendExpression(expr=expression, parsed=False)
376376
result_parts = result.split('\n')
377377
pathstr_resolved = result_parts[1]
378378
pathstr_resolved = pathstr_resolved[1:-1] # remove quotes
@@ -573,7 +573,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
573573
The complete error handling of the OMC result is done within this method using '"getMessagesStringInternal()'.
574574
Caller should only check for OMCSessionException.
575575
"""
576-
return self.omc_process.sendExpression(command=command, parsed=parsed)
576+
return self.omc_process.sendExpression(expr=command, parsed=parsed)
577577

578578

579579
class PostInitCaller(type):
@@ -856,9 +856,9 @@ def execute(self, command: str):
856856
category=DeprecationWarning,
857857
stacklevel=2)
858858

859-
return self.sendExpression(command, parsed=False)
859+
return self.sendExpression(expr=command, parsed=False)
860860

861-
def sendExpression(self, command: str, parsed: bool = True) -> Any:
861+
def sendExpression(self, expr: str, parsed: bool = True) -> Any:
862862
"""
863863
Send an expression to the OMC server and return the result.
864864
@@ -869,12 +869,12 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
869869
if self._omc_zmq is None:
870870
raise OMCSessionException("No OMC running. Please create a new instance of OMCSession!")
871871

872-
logger.debug("sendExpression(%r, parsed=%r)", command, parsed)
872+
logger.debug("sendExpression(%r, parsed=%r)", expr, parsed)
873873

874874
loop = self._timeout_loop(timestep=0.05)
875875
while next(loop):
876876
try:
877-
self._omc_zmq.send_string(str(command), flags=zmq.NOBLOCK)
877+
self._omc_zmq.send_string(str(expr), flags=zmq.NOBLOCK)
878878
break
879879
except zmq.error.Again:
880880
pass
@@ -888,7 +888,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
888888
logger.error(f"Docker did not start. Log-file says:\n{log_content}")
889889
raise OMCSessionException(f"No connection with OMC (timeout={self._timeout}).")
890890

891-
if command == "quit()":
891+
if expr == "quit()":
892892
self._omc_zmq.close()
893893
self._omc_zmq = None
894894
return None
@@ -898,13 +898,13 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
898898
if result.startswith('Error occurred building AST'):
899899
raise OMCSessionException(f"OMC error: {result}")
900900

901-
if command == "getErrorString()":
901+
if expr == "getErrorString()":
902902
# no error handling if 'getErrorString()' is called
903903
if parsed:
904904
logger.warning("Result of 'getErrorString()' cannot be parsed!")
905905
return result
906906

907-
if command == "getMessagesStringInternal()":
907+
if expr == "getMessagesStringInternal()":
908908
# no error handling if 'getMessagesStringInternal()' is called
909909
if parsed:
910910
logger.warning("Result of 'getMessagesStringInternal()' cannot be parsed!")
@@ -958,7 +958,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
958958
log_level = log_raw[0][8]
959959
log_id = log_raw[0][9]
960960

961-
msg_short = (f"[OMC log for 'sendExpression({command}, {parsed})']: "
961+
msg_short = (f"[OMC log for 'sendExpression({expr}, {parsed})']: "
962962
f"[{log_kind}:{log_level}:{log_id}] {log_message}")
963963

964964
# response according to the used log level
@@ -980,7 +980,7 @@ def sendExpression(self, command: str, parsed: bool = True) -> Any:
980980
msg_long_list.append(msg_long)
981981
if has_error:
982982
msg_long_str = '\n'.join(f"{idx:02d}: {msg}" for idx, msg in enumerate(msg_long_list))
983-
raise OMCSessionException(f"OMC error occurred for 'sendExpression({command}, {parsed}):\n"
983+
raise OMCSessionException(f"OMC error occurred for 'sendExpression({expr}, {parsed}):\n"
984984
f"{msg_long_str}")
985985

986986
if not parsed:

0 commit comments

Comments
 (0)