SET(SCRIPTS
salome_test_driver.py
- salome_test_session.py
+ salome_instance.py
)
SALOME_INSTALL_SCRIPTS("${SCRIPTS}" ${SALOME_INSTALL_SCRIPT_SCRIPTS}/appliskel)
--- /dev/null
+# Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import sys
+import os
+
+# Example of args:
+# args=["--gui", "--show-desktop=1", "--splash=0"]
+# args=["--terminal","--modules=MED,PARAVIS,GUI"]
+class SalomeInstance(object):
+
+ def __init__(self):
+ self.port = None
+ #
+
+ def get_port(self):
+ return self.port
+ #
+
+ @staticmethod
+ def start(shutdown_servers=False):
+ import tempfile
+ log = tempfile.NamedTemporaryFile(suffix='_nsport.log', delete=False)
+ log.close()
+
+ instance_args = [
+ "--ns-port-log=%s"%log.name,
+ "--shutdown-servers=%d"%shutdown_servers
+ ]
+ salome_instance = SalomeInstance()
+ salome_instance.__run(args=instance_args)
+
+ with open(log.name) as f:
+ salome_instance.port = int(f.readline())
+
+ os.remove(log.name)
+ return salome_instance
+ #
+
+ def __run(self, args=[]):
+ sys.argv = ['runSalome'] + args
+
+ if "INGUI" in args:
+ # :WARNING: NOT TESTED YET
+ sys.argv += ["--gui"]
+ sys.argv += ["--show-desktop=1"]
+ sys.argv += ["--splash=0"]
+ #sys.argv += ["--standalone=study"]
+ #sys.argv += ["--embedded=SalomeAppEngine,cppContainer,registry,moduleCatalog"]
+ else:
+ sys.argv += ["--terminal"]
+ #sys.argv += ["--shutdown-servers=1"]
+ #sys.argv += ["--modules=MED,PARAVIS,GUI"]
+ pass
+
+ import setenv
+ setenv.main(True)
+ import runSalome
+ runSalome.runSalome()
+
+ import salome
+ salome.salome_init()
+ session_server = salome.naming_service.Resolve('/Kernel/Session')
+ if session_server:
+ session_server.emitMessage("connect_to_study")
+ session_server.emitMessage("activate_viewer/ParaView")
+ pass
+ #
+
+ def stop(self):
+ import killSalomeWithPort
+ killSalomeWithPort.killMyPort(self.port)
+ #
+
+#
+
+if __name__ == "__main__":
+ print "##### Start instance..."
+ salome_instance = SalomeInstance.start()
+ port = salome_instance.get_port()
+ print "##### ...instance started on port %s"%port
+
+ print "##### Terminate instance running on port %s"%port
+ salome_instance.stop()
+#
signal.alarm(abs(int(timeout_delay)-10))
signal.signal(signal.SIGALRM, timeoutHandler)
- # Run test in a new SALOME session
- from salome_test_session import startSession, terminateSession
+ # Run test in a new SALOME instance
+ from salome_instance import SalomeInstance
res = 1
try:
- port = startSession()
+ salome_instance = SalomeInstance.start(shutdown_servers=True)
+ port = salome_instance.get_port()
res, out, err = runTest(test_and_args)
#res = processResult(res, out, err)
res = processResultSpecialParavis(res, out, err)
traceback.print_exc()
pass
- terminateSession(port)
+ salome_instance.stop()
print "Exit test with status code:", res
exit(res)
#
+++ /dev/null
-# Copyright (C) 2015 CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# This library is free software; you can redistribute it and/or
-# modify it under the terms of the GNU Lesser General Public
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-import sys
-import os
-
-# Example of args:
-# args=["--gui", "--show-desktop=1", "--splash=0"]
-# args=["--terminal","--modules=MED,PARAVIS,GUI"]
-class SalomeSession(object):
- def __init__(self, args=[]):
- sys.argv = ['runSalome'] + args
-
- if "INGUI" in args:
- # :WARNING: NOT TESTED YET
- sys.argv += ["--gui"]
- sys.argv += ["--show-desktop=1"]
- sys.argv += ["--splash=0"]
- #sys.argv += ["--standalone=study"]
- #sys.argv += ["--embedded=SalomeAppEngine,cppContainer,registry,moduleCatalog"]
- else:
- sys.argv += ["--terminal"]
- sys.argv += ["--shutdown-servers=1"]
- #sys.argv += ["--modules=MED,PARAVIS,GUI"]
- pass
-
- import setenv
- setenv.main(True)
-
- import runSalome
- runSalome.runSalome()
- #
-#
-
-# Run SALOME
-def startSession():
- import tempfile
- log = tempfile.NamedTemporaryFile(suffix='_nsport.log', delete=False)
- log.close()
- import salome
- salome_session = SalomeSession(args=["--ns-port-log=%s"%log.name])
- salome.salome_init()
- session_server = salome.naming_service.Resolve('/Kernel/Session')
- if session_server:
- session_server.emitMessage("connect_to_study")
- session_server.emitMessage("activate_viewer/ParaView")
- pass
-
- with open(log.name) as f:
- port = int(f.readline())
-
- os.remove(log.name)
- return port
-#
-
-# Terminate SALOME
-def terminateSession(port):
- import killSalomeWithPort
- killSalomeWithPort.killMyPort(port)
-#
See usage for details on commands.
"""
def _startSalome(self, args):
+ import os
+ import sys
try:
- import os
+ from setenv import add_path
absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH')
- import sys
path = os.path.realpath(os.path.join(absoluteAppliPath, "bin", "salome"))
- if not path in sys.path:
- sys.path[:0] = [path]
+ add_path(path, "PYTHONPATH")
+ path = os.path.realpath(os.path.join(absoluteAppliPath, "bin", "salome", "appliskel"))
+ add_path(path, "PYTHONPATH")
+
except:
pass