Skip to content

Commit 41a6ced

Browse files
authored
Catch loadModel errors (#246)
- omc.sendExpression now throws OMCSessionException
1 parent 3aa8a07 commit 41a6ced

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

test.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ def target():
259259
print("Error: Expected at least one configuration file to start the library test")
260260
sys.exit(1)
261261

262-
from OMPython import OMCSessionZMQ, OMCProcessDocker
262+
from OMPython import OMCSessionZMQ, OMCProcessDocker, OMCSessionException
263263

264264
# Try to make the processes a bit nicer...
265265
os.environ["GC_MARKERS"]="1"
@@ -663,7 +663,9 @@ def hashReferenceFiles(s):
663663
raise Exception("Library %s has both libraryVersionLatestInPackageManager:true and libraryVersionExactMatch:true! Make up your mind." % libName)
664664
exactMatch=', requireExactVersion=true'
665665

666-
if not omc.sendExpression('loadModel(%s,%s%s)' % (lib,versions,exactMatch)):
666+
try:
667+
omc.sendExpression('loadModel(%s,%s%s)' % (lib,versions,exactMatch))
668+
except OMCSessionException:
667669
try:
668670
print("Failed to load library %s %s: %s" % (library,versions,omc.sendExpression('OpenModelica.Scripting.getErrorString()')))
669671
except:
@@ -726,7 +728,7 @@ def hashReferenceFiles(s):
726728
if conf.get("fmi") and fmisimulatorversion:
727729
conf["libraryVersionRevision"] = conf["libraryVersionRevision"] + " " + fmisimulatorversion.decode("ascii")
728730
conf["libraryLastChange"] = conf["libraryLastChange"] + " " + fmisimulatorversion.decode("ascii")
729-
res=omc.sendExpression('{c for c guard isExperiment(c) and not regexBool(typeNameString(x), "^Modelica_Synchronous\\.WorkInProgress") in getClassNames(%s, recursive=true)}' % library)
731+
res=omc.sendExpression('{c for c guard isExperiment(c) and not regexBool(typeNameString(x), "^Modelica_Synchronous\\\\.WorkInProgress") in getClassNames(%s, recursive=true)}' % library)
730732
if conf.get("ignoreModelPrefix"):
731733
if isinstance(conf["ignoreModelPrefix"], list):
732734
prefixes = conf["ignoreModelPrefix"]

0 commit comments

Comments
 (0)