From 0d313cc982ac3d9b39110bf2dffddd562cc68d88 Mon Sep 17 00:00:00 2001 From: syntron Date: Wed, 16 Apr 2025 21:24:15 +0200 Subject: [PATCH 1/3] cleanup old code for Python 2.x --- OMPython/__init__.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/OMPython/__init__.py b/OMPython/__init__.py index 7aa07fa13..0cbe86214 100644 --- a/OMPython/__init__.py +++ b/OMPython/__init__.py @@ -32,11 +32,6 @@ import warnings -if sys.platform == 'darwin': - # On Mac let's assume omc is installed here and there might be a broken omniORB installed in a bad place - sys.path.append('/opt/local/lib/python2.7/site-packages/') - sys.path.append('/opt/openmodelica/lib/python2.7/site-packages/') - # TODO: replace this with the new parser from OMPython import OMTypedParser, OMParser From b17b49fee39772cf2607a5e39497ea30d7c6ec7d Mon Sep 17 00:00:00 2001 From: syntron Date: Thu, 17 Apr 2025 19:04:47 +0200 Subject: [PATCH 2/3] fix OMCSessionBase - the variables self.readonly and self.omc_cache are needed here --- OMPython/__init__.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/OMPython/__init__.py b/OMPython/__init__.py index 0cbe86214..82de08f88 100644 --- a/OMPython/__init__.py +++ b/OMPython/__init__.py @@ -98,6 +98,10 @@ def wait(self, timeout): class OMCSessionBase(metaclass=abc.ABCMeta): + def __init__(self, readonly=False): + self._readonly = readonly + self._omc_cache = {} + def clearOMParserResult(self): OMParser.result = {} @@ -125,10 +129,10 @@ def sendExpression(self, command, parsed=True): def ask(self, question, opt=None, parsed=True): p = (question, opt, parsed) - if self.readonly and question != 'getErrorString': + if self._readonly and question != 'getErrorString': # can use cache if readonly - if p in self.omc_cache: - return self.omc_cache[p] + if p in self._omc_cache: + return self._omc_cache[p] if opt: expression = f'{question}({opt})' @@ -144,7 +148,7 @@ def ask(self, question, opt=None, parsed=True): raise # save response - self.omc_cache[p] = res + self._omc_cache[p] = res return res @@ -329,10 +333,10 @@ def __init__(self, readonly=False, timeout=10.00, if dockerExtraArgs is None: dockerExtraArgs = [] + super().__init__(readonly=readonly) + self.omhome = self._get_omhome(omhome=omhome) - self.readonly = readonly - self.omc_cache = {} self._omc_process = None self._omc_command = None self._omc = None From 27142cbb2c5365a8e357048915734a04e2c0436c Mon Sep 17 00:00:00 2001 From: syntron Date: Thu, 17 Apr 2025 18:58:18 +0200 Subject: [PATCH 3/3] [ModelicaSystem] fix True in docstring --- OMPython/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OMPython/__init__.py b/OMPython/__init__.py index 82de08f88..c5ad682e8 100644 --- a/OMPython/__init__.py +++ b/OMPython/__init__.py @@ -1465,7 +1465,7 @@ def convertMo2Fmu(self, version="2.0", fmuType="me_cs", fileNamePrefix=">> convertMo2Fmu() - >>> convertMo2Fmu(version="2.0", fmuType="me|cs|me_cs", fileNamePrefix="", includeResources=true) + >>> convertMo2Fmu(version="2.0", fmuType="me|cs|me_cs", fileNamePrefix="", includeResources=True) """ if fileNamePrefix == "":