Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions OMPython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -103,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 = {}

Expand Down Expand Up @@ -130,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})'
Expand All @@ -149,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

Expand Down Expand Up @@ -334,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
Expand Down Expand Up @@ -1466,7 +1465,7 @@ def convertMo2Fmu(self, version="2.0", fmuType="me_cs", fileNamePrefix="<default
with arguments of https://build.openmodelica.org/Documentation/OpenModelica.Scripting.translateModelFMU.html
usage
>>> convertMo2Fmu()
>>> convertMo2Fmu(version="2.0", fmuType="me|cs|me_cs", fileNamePrefix="<default>", includeResources=true)
>>> convertMo2Fmu(version="2.0", fmuType="me|cs|me_cs", fileNamePrefix="<default>", includeResources=True)
"""

if fileNamePrefix == "<default>":
Expand Down
Loading