-# Copyright (C) 2007-2015 CEA/DEN, EDF R&D
+# Copyright (C) 2015-2024 CEA, EDF, OPEN CASCADE
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
import socket
from time import sleep
import os
-from SALOME import SALOME_Exception
+import sys
+from SALOME import SALOME_Exception, ExceptionStruct, INTERNAL_ERROR
#from SALOME_utilities import MESSAGE
def MESSAGE(m):
raise Exception("PVSERVER_Impl.__init__ : \"import paraview\" failed !")
# deduce dynamically PARAVIEW_ROOT_DIR from the paraview module location
self.PARAVIEW_ROOT_DIR = None
- ZE_KEY_TO_FIND_PV_ROOT_DIR="lib"
+ if sys.platform == "win32":
+ ZE_KEY_TO_FIND_PV_ROOT_DIR=["Lib"]
+ upCount =2
+ else:
+ ZE_KEY_TO_FIND_PV_ROOT_DIR=["lib", "lib64"]
+ upCount =1
+ tmp = os.path.sep.join(tmp.split('/'))
li=tmp.split(os.path.sep) ; li.reverse()
- if ZE_KEY_TO_FIND_PV_ROOT_DIR not in li:
- raise SALOME_Exception(SALOME.ExceptionStruct(SALOME.INTERNAL_ERROR,
- "PVSERVER_Impl.__init__ : error during dynamic deduction of PARAVIEW_ROOT_DIR : Loc of paraview module is \"%s\" ! \"%s\" is supposed to be the key to deduce it !"%(tmp,ZE_KEY_TO_FIND_PV_ROOT_DIR),
- "PVSERVER.py", 0))
- li=li[li.index("lib")+1:] ; li.reverse()
- self.PARAVIEW_ROOT_DIR = os.path.sep.join(li)
+ for key_to_find in ZE_KEY_TO_FIND_PV_ROOT_DIR:
+ if key_to_find in li:
+ li=li[li.index(key_to_find)+upCount:] ; li.reverse()
+ self.PARAVIEW_ROOT_DIR = os.path.sep.join(li)
+ return
+ raise SALOME_Exception(ExceptionStruct(INTERNAL_ERROR,
+ "PVSERVER_Impl.__init__ : error during dynamic deduction of PARAVIEW_ROOT_DIR : Loc of paraview module is \"%s\" ! \"%s\" is supposed to be the key to deduce it !"%(tmp," or ".join(ZE_KEY_TO_FIND_PV_ROOT_DIR)),
+ "PVSERVER.py", 0))
"""
Private. Identify a free port to launch the PVServer.
cnt += 1
currPort += 1
pass
- raise SALOME_Exception(SALOME.ExceptionStruct(SALOME.INTERNAL_ERROR,
+ raise SALOME_Exception(ExceptionStruct(INTERNAL_ERROR,
"[PVSERVER] maximum number of tries to retrieve a free port for the PVServer",
"PVSERVER.py", 0))
opt = []
if port <= 0:
port = self.__getFreePort(self.PVSERVER_DEFAULT_PORT)
- self.pvserverPop = subp.Popen([pvServerPath, "--multi-clients", "--server-port=%d" % port, "--use-offscreen-rendering"])
+ self.pvserverPop = subp.Popen([pvServerPath, "--multi-clients", "--server-port=%d" % port, "--force-offscreen-rendering"])
sleep(3) # Give some time to the server to start up to avoid
# ugly messages on the client side saying that it cannot connect
# Is PID still alive? If yes, consider that the launch was successful
self.pvserverPort = port
MESSAGE("[PVSERVER] pvserver successfully launched on port %d" % port)
else:
- raise SALOME_Exception(SALOME.ExceptionStruct(SALOME.INTERNAL_ERROR,
+ raise SALOME_Exception(ExceptionStruct(INTERNAL_ERROR,
"[PVSERVER] Unable to start PVServer on port %d!" % port,
"PVSERVER.py", 0))
return "cs://%s:%d" % (host, self.pvserverPort)
return self.isGUIConnected
-
\ No newline at end of file