88if (sys .version_info < (3 , 0 )):
99 raise Exception ("Python2 is no longer supported" )
1010
11- import html , shutil , os , re , glob , time , argparse , sqlite3 , datetime , math
11+ import html , shutil , os , re , glob , time , argparse , sqlite3 , datetime , math , platform
1212from joblib import Parallel , delayed
1313import simplejson as json
1414import psutil , subprocess , threading , hashlib
15+ from subprocess import call
1516from monotonic import monotonic
1617from omcommon import friendlyStr , multiple_replace
1718from natsort import natsorted
@@ -259,19 +260,14 @@ def target():
259260 print ("Error: Expected at least one configuration file to start the library test" )
260261 sys .exit (1 )
261262
262- from OMPython import OMCSessionZMQ , OMCProcessDocker , OMCSessionException
263+ from OMPython import OMCSession , OMCSessionZMQ
263264
264265# Try to make the processes a bit nicer...
265266os .environ ["GC_MARKERS" ]= "1"
266267
267268print ("Start OMC version" )
268269
269- if docker :
270- omc = OMCProcessDocker (docker = docker , dockerExtraArgs = dockerExtraArgs )
271- omhome = omc .sendExpression ('getInstallationDirectoryPath()' )
272- omc_version = omc .sendExpression ('getVersion()' )
273- ompython_omc_version = omc_version
274- elif ompython_omhome != "" :
270+ if ompython_omhome != "" :
275271 # Use a different OMC for running OMPython than for running the tests
276272 omhome = os .environ ["OPENMODELICAHOME" ]
277273 omc_version = check_output_log (omc_cmd + ["--version" ], stderr = subprocess .STDOUT ).decode ("ascii" ).strip ()
@@ -280,11 +276,10 @@ def target():
280276 ompython_omc_version = omc .sendExpression ('getVersion()' )
281277 os .environ ["OPENMODELICAHOME" ] = omhome
282278else :
283- omc = OMCSessionZMQ ()
279+ omc = OMCSessionZMQ (docker = docker , dockerExtraArgs = dockerExtraArgs )
284280 omhome = omc .sendExpression ('getInstallationDirectoryPath()' )
285281 omc_version = omc .sendExpression ('getVersion()' )
286282 ompython_omc_version = omc_version
287-
288283ompython_omc_version = ompython_omc_version .replace ("OMCompiler" ,"" ).strip ()
289284
290285def timeSeconds (f ):
@@ -663,12 +658,11 @@ def hashReferenceFiles(s):
663658 raise Exception ("Library %s has both libraryVersionLatestInPackageManager:true and libraryVersionExactMatch:true! Make up your mind." % libName )
664659 exactMatch = ', requireExactVersion=true'
665660
666- try :
667- omc .sendExpression ('loadModel(%s,%s%s)' % (lib ,versions ,exactMatch ))
668- except OMCSessionException as e :
669- print ("Failed to load library %s %s" % (library ,versions ))
670- print (e )
671-
661+ if not omc .sendExpression ('loadModel(%s,%s%s)' % (lib ,versions ,exactMatch )):
662+ try :
663+ print ("Failed to load library %s %s: %s" % (library ,versions ,omc .sendExpression ('OpenModelica.Scripting.getErrorString()' )))
664+ except :
665+ print ("Failed to load library %s %s. OpenModelica.Scripting.getErrorString() failed..." % (library ,conf ["libraryVersion" ]))
672666 # adrpo: do not sort the top level names as sometimes that loads a bad MSL version
673667 # conf["loadFiles"] = sorted(omc.sendExpression("{getSourceFile(cl) for cl in getClassNames()}"))
674668 conf ["loadFiles" ] = omc .sendExpression ("{getSourceFile(cl) for cl in getClassNames()}" )
@@ -727,13 +721,7 @@ def hashReferenceFiles(s):
727721 if conf .get ("fmi" ) and fmisimulatorversion :
728722 conf ["libraryVersionRevision" ] = conf ["libraryVersionRevision" ] + " " + fmisimulatorversion .decode ("ascii" )
729723 conf ["libraryLastChange" ] = conf ["libraryLastChange" ] + " " + fmisimulatorversion .decode ("ascii" )
730- res = []
731- try :
732- res = omc .sendExpression ('{c for c guard isExperiment(c) and not regexBool(typeNameString(x), "^Modelica_Synchronous\\ \\ .WorkInProgress") in getClassNames(%s, recursive=true)}' % library )
733- except OMCSessionException as e :
734- print ("Failed to get class names of library %s" , library )
735- print (e )
736-
724+ res = omc .sendExpression ('{c for c guard isExperiment(c) and not regexBool(typeNameString(x), "^Modelica_Synchronous\\ .WorkInProgress") in getClassNames(%s, recursive=true)}' % library )
737725 if conf .get ("ignoreModelPrefix" ):
738726 if isinstance (conf ["ignoreModelPrefix" ], list ):
739727 prefixes = conf ["ignoreModelPrefix" ]
0 commit comments