Skip to content

Commit

Permalink
Modelica in different dir management added
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreaBartolini committed Sep 20, 2024
1 parent 52d8a24 commit b9054e0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
11 changes: 10 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,15 @@
librariespath = os.path.normpath(os.path.join(os.environ.get('APPDATA'), '.openmodelica', 'libraries'))
else:
librariespath = os.path.normpath(os.path.join(os.environ.get('HOME'), '.openmodelica', 'libraries'))

# add openmodelica libraries path if the Modelica libraries are not found in the libraries path
modelicaLibpath = ''
if len(glob.glob('Modelica*', root_dir=librariespath)) == 0:
if isWin:
modelicaLibpath = ';' + os.path.normpath(os.path.join(os.environ.get('APPDATA'), '.openmodelica', 'libraries')).replace('\\','/')
else:
modelicaLibpath = ':' + os.path.normpath(os.path.join(os.environ.get('APPDATA'), '.openmodelica', 'libraries')).replace('\\','/')

overrideDefaults = [arg.split("=", 1) for arg in args.default]
execAllTests = args.execAllTests
msysEnvironment = args.msysEnvironment
Expand Down Expand Up @@ -256,7 +265,7 @@ def timeSeconds(f):
return html.escape("%.2f" % f)

if not docker:
omc.sendExpression('setModelicaPath("%s")' % librariespath.replace('\\','/'))
omc.sendExpression('setModelicaPath("%s")' % (librariespath.replace('\\','/') + modelicaLibpath,))
omc_exe=os.path.normpath(os.path.join(omhome,"bin","omc"))
dygraphs=os.path.normpath(os.path.join(ompython_omhome or omhome,"share","doc","omc","testmodels","dygraph-combined.js"))
print(omc_exe,omc_version,dygraphs)
Expand Down
14 changes: 11 additions & 3 deletions testmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import simplejson as json
from monotonic import monotonic
from OMPython import FindBestOMCSession, OMCSession, OMCSessionZMQ
import shared
import shared, glob

parser = argparse.ArgumentParser(description='OpenModelica library testing tool helper (single model)')
parser.add_argument('config')
Expand All @@ -28,6 +28,14 @@
isWin = args.win
msysEnvironment = args.msysEnvironment

# add openmodelica libraries path if the Modelica libraries are not found in the libraries path
modelicaLibpath = ''
if len(glob.glob('Modelica*', root_dir=libraries)) == 0:
if isWin:
modelicaLibpath = ';' + os.path.normpath(os.path.join(os.environ.get('APPDATA'), '.openmodelica', 'libraries')).replace('\\','/')
else:
modelicaLibpath = ':' + os.path.normpath(os.path.join(os.environ.get('APPDATA'), '.openmodelica', 'libraries')).replace('\\','/')

try:
os.mkdir("files")
except OSError:
Expand Down Expand Up @@ -260,7 +268,7 @@ def createOmcSessionNew():
cflags += " " + conf["optlevel"]
omc.sendExpression(str("setCFlags(\"%s\")" % cflags), parsed = False)

omc.sendExpression('setModelicaPath("%s")' % libraries, parsed = False)
omc.sendExpression('setModelicaPath("%s")' % (libraries+modelicaLibpath,), parsed = False)

if conf.get("ulimitMemory"):
# Use at most 80% of the vmem for the GC heap; some memory will be used for other purposes than the GC itself
Expand All @@ -284,7 +292,7 @@ def loadLibraryInNewOM():
newOMLoaded = True
# Broken/old getSimulationOptions; use new one (requires parsing again)
assert(ompython_omhome!="")
assert(omc_new.sendExpression('setModelicaPath("%s")' % libraries))
assert(omc_new.sendExpression('setModelicaPath("%s")' % (libraries+modelicaLibpath,)))
loadModels(omc_new, conf)

start=monotonic()
Expand Down

0 comments on commit b9054e0

Please sign in to comment.