]> SALOME platform Git repositories - modules/yacs.git/commitdiff
Salome HOME
Porting Salome test system on Windows
authorana <ana@opencascade.com>
Tue, 3 Dec 2013 14:11:24 +0000 (14:11 +0000)
committerana <ana@opencascade.com>
Tue, 3 Dec 2013 14:11:24 +0000 (14:11 +0000)
bin/CMakeLists.txt
bin/killSalomeWithPort.py
bin/salomeLauncherUtils.py [deleted file]
bin/salomeLauncherUtils.py.in [new file with mode: 0644]
salome_adm/cmake_files/FindSalomePython.cmake

index b2847db74e8470a76c9feadad9a82fab0e6b0724..c17880a5b92f97cca4701aab1ad797a78ebc51fd 100755 (executable)
@@ -20,6 +20,7 @@
 ADD_SUBDIRECTORY(appliskel)
 
 SALOME_CONFIGURE_FILE(VERSION.in VERSION INSTALL ${SALOME_INSTALL_BINS})
+SALOME_CONFIGURE_FILE(salomeLauncherUtils.py.in salomeLauncherUtils.py)
 
 # ===============================================================
 # Files to be installed
@@ -48,7 +49,7 @@ SET(SCRIPTS
   runSession.py
   runConsole.py
   salomeConsole.py
-  salomeLauncherUtils.py
+  ${CMAKE_CURRENT_BINARY_DIR}/salomeLauncherUtils.py
   salomeRunner.py
   salome_session.py
   salome_utils.py
index 71dd451736d1ac088a003ae7f0a211eff0868b5c..23b70628f6b19e33517830e88010c1175b44af46 100755 (executable)
@@ -103,13 +103,20 @@ def appliCleanOmniOrbConfig(port):
                                                extension="cfg",
                                                hidden=True)
         if os.access(last_running_config,os.F_OK):
-            pointedPath = os.readlink(last_running_config)
-            if pointedPath[0] != '/':
-                pointedPath=os.path.join(os.path.dirname(last_running_config), pointedPath)
-            if pointedPath == omniorb_config:
-                os.unlink(last_running_config)
+            if not sys.platform == 'win32':
+                pointedPath = os.readlink(last_running_config)
+                if pointedPath[0] != '/':
+                    pointedPath=os.path.join(os.path.dirname(last_running_config), pointedPath)
+                    pass
+                if pointedPath == omniorb_config:
+                    os.unlink(last_running_config)
+                    pass
                 pass
-            pass
+            else:
+                os.remove(last_running_config)  
+                pass
+            pass  
+
         if os.access(omniorb_config,os.F_OK):
             os.remove(omniorb_config)
             pass
@@ -126,8 +133,14 @@ def appliCleanOmniOrbConfig(port):
             current=stat.st_atime
             current_config=f
         if current_config:
-          os.symlink(os.path.normpath(current_config), last_running_config)
-
+          if sys.platform == "win32":
+            import shutil
+            shutil.copyfile(os.path.normpath(current_config), last_running_config)
+            pass
+          else:
+            os.symlink(os.path.normpath(current_config), last_running_config)
+            pass
+          pass
         pass
     pass
 
diff --git a/bin/salomeLauncherUtils.py b/bin/salomeLauncherUtils.py
deleted file mode 100644 (file)
index 33d867d..0000000
+++ /dev/null
@@ -1,166 +0,0 @@
-#! /usr/bin/env python
-
-import os
-import sys
-import glob
-import subprocess
-import re
-
-"""
-Define a specific exception class to manage exceptions related to SalomeRunner
-"""
-class SalomeRunnerException(Exception):
-  """Report error messages to the user interface of SalomeRunner."""
-#
-
-def __listDirectory(path):
-  allFiles = []
-  for root, dirs, files in os.walk(path):
-    configFileNames = glob.glob(os.path.join(root,'*.cfg')) + glob.glob(os.path.join(root,'*.sh'))
-    allFiles += configFileNames
-  return allFiles
-#
-
-def __getConfigFileNamesDefault():
-  absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH','')
-  if not absoluteAppliPath:
-    return []
-
-  envdDir = absoluteAppliPath + '/env.d'
-  if not os.path.isdir(envdDir):
-    return []
-
-  return __listDirectory(envdDir)
-#
-
-def getConfigFileNames(args, checkExistence=False):
-  # special case: configuration files are provided by user
-  # Search for command-line argument(s) --config=file1,file2,..., filen
-  # Search for command-line argument(s) --config=dir1,dir2,..., dirn
-  configOptionPrefix = "--config="
-  configArgs = [ str(x) for x in args if str(x).startswith(configOptionPrefix) ]
-
-  if len(configArgs) == 0:
-    return __getConfigFileNamesDefault(), args, []
-
-  args = [ x for x in args if not x.startswith(configOptionPrefix) ]
-  allLists = [ x.replace(configOptionPrefix, '') for x in configArgs ]
-
-  configFileNames = []
-  unexisting = []
-  for currentList in allLists:
-    elements = currentList.split(',')
-    for elt in elements:
-      elt = os.path.realpath(os.path.expanduser(elt))
-      if os.path.isdir(elt):
-        configFileNames += __listDirectory(elt)
-      else:
-        if checkExistence and not os.path.isfile(elt):
-          unexisting += [elt]
-        else:
-          configFileNames += [elt]
-
-  return configFileNames, args, unexisting
-#
-
-# Return an array of dictionaries {script_name: [list_of_its_args]}
-def getScriptsAndArgs(args=[]):
-  # Syntax of args: script.py [args:a1,a2=val,an] ... script.py [args:a1,a2=val,an]
-  scriptArgs = []
-  currentKey = None
-  argsPrefix = "args:"
-  callPython = False
-  currentScript = None
-
-  for i in range(len(args)):
-    elt = args[i]
-
-    if elt.startswith(argsPrefix):
-      if not currentKey or callPython:
-        raise SalomeRunnerException("args list must follow corresponding script file in command line.")
-      elt = elt.replace(argsPrefix, '')
-      scriptArgs[len(scriptArgs)-1][currentKey] = elt.split(",")
-      currentKey = None
-      callPython = False
-    elif elt.startswith("python"):
-      callPython = True
-    elif os.path.isfile(elt) or os.path.isfile(elt+".py"):
-      if elt[-4:] != ".hdf":
-        if elt[-3:] == ".py":
-          currentScript = os.path.abspath(elt)
-        elif os.path.isfile(elt+".py"):
-          currentScript = os.path.abspath(elt+".py")
-        else:
-          currentScript = os.path.abspath(elt) # python script not necessary has .py extension
-        pass
-      if currentScript and callPython:
-        currentKey = "python "+currentScript
-        scriptArgs.append({currentKey:[]})
-        callPython = False
-      elif currentScript:
-        if not os.access(currentScript, os.X_OK):
-          currentKey = "python "+currentScript
-          scriptArgs.append({currentKey:[]})
-        else:
-          ispython = False
-          try:
-            fn = open(currentScript)
-            for i in xrange(10): # read only 10 first lines 
-              ln = fn.readline()
-              if re.search("#!.*python"): 
-                ispython = True
-                break
-              pass
-            fn.close()
-          except:
-            pass
-          if not ispython and currentScript[-3:] == ".py":
-            currentKey = "python "+currentScript
-          else:
-            currentKey = currentScript
-            pass
-          scriptArgs.append({currentKey:[]})
-  # end for loop
-  return scriptArgs
-#
-
-# Formatting scripts and args as a Bash-like command-line:
-# script1.py [args] ; script2.py [args] ; ...
-def formatScriptsAndArgs(scriptArgs=[]):
-    commands = []
-    for sc_dict in scriptArgs:
-      for script, sc_args in sc_dict.items(): # single entry
-        cmd = script
-        if sc_args:
-          cmd = cmd + " " + " ".join(sc_args)
-        commands.append(cmd)
-
-    command = "; ".join(["%s"%x for x in commands])
-    return command
-#
-
-# Ensure OMNIORB_USER_PATH is defined. This variable refers to a the folder in which
-# SALOME will write omniOrb configuration files.
-# If OMNIORB_USER_PATH is already set, only checks write access to associated directory ;
-# an exception is raised if check fails. It allows users for choosing a specific folder.
-# Else the function sets OMNIORB_USER_PATH this way:
-# - If APPLI environment variable is set, OMNIORB_USER_PATH is set to ${APPLI}/USERS.
-#   The function does not check USERS folder existence or wrute access. This folder
-#   must exist ; this is the case if SALOME virtual application has been create using
-#   appli_gen.py script.
-# - Else OMNIORB_USER_PATH is set to user home directory.
-def setOmniOrbUserPath():
-  omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
-  if omniorbUserPath:
-    if not os.access(omniorbUserPath, os.W_OK):
-      raise Exception("Unable to get write access to directory: %s"%omniorbUserPath)
-    pass
-  else:
-    homePath = os.path.realpath(os.path.expanduser('~'))
-    #defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
-    defaultOmniorbUserPath = homePath
-    if os.getenv("APPLI"):
-      defaultOmniorbUserPath = os.path.join(homePath, os.getenv("APPLI"), "USERS")
-      pass
-    os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
-#
diff --git a/bin/salomeLauncherUtils.py.in b/bin/salomeLauncherUtils.py.in
new file mode 100644 (file)
index 0000000..877bd8c
--- /dev/null
@@ -0,0 +1,166 @@
+#! /usr/bin/env python
+
+import os
+import sys
+import glob
+import subprocess
+import re
+
+"""
+Define a specific exception class to manage exceptions related to SalomeRunner
+"""
+class SalomeRunnerException(Exception):
+  """Report error messages to the user interface of SalomeRunner."""
+#
+
+def __listDirectory(path):
+  allFiles = []
+  for root, dirs, files in os.walk(path):
+    configFileNames = glob.glob(os.path.join(root,'*.cfg')) + glob.glob(os.path.join(root,'*.sh'))
+    allFiles += configFileNames
+  return allFiles
+#
+
+def __getConfigFileNamesDefault():
+  absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH','')
+  if not absoluteAppliPath:
+    return []
+
+  envdDir = absoluteAppliPath + '/env.d'
+  if not os.path.isdir(envdDir):
+    return []
+
+  return __listDirectory(envdDir)
+#
+
+def getConfigFileNames(args, checkExistence=False):
+  # special case: configuration files are provided by user
+  # Search for command-line argument(s) --config=file1,file2,..., filen
+  # Search for command-line argument(s) --config=dir1,dir2,..., dirn
+  configOptionPrefix = "--config="
+  configArgs = [ str(x) for x in args if str(x).startswith(configOptionPrefix) ]
+
+  if len(configArgs) == 0:
+    return __getConfigFileNamesDefault(), args, []
+
+  args = [ x for x in args if not x.startswith(configOptionPrefix) ]
+  allLists = [ x.replace(configOptionPrefix, '') for x in configArgs ]
+
+  configFileNames = []
+  unexisting = []
+  for currentList in allLists:
+    elements = currentList.split(',')
+    for elt in elements:
+      elt = os.path.realpath(os.path.expanduser(elt))
+      if os.path.isdir(elt):
+        configFileNames += __listDirectory(elt)
+      else:
+        if checkExistence and not os.path.isfile(elt):
+          unexisting += [elt]
+        else:
+          configFileNames += [elt]
+
+  return configFileNames, args, unexisting
+#
+
+# Return an array of dictionaries {script_name: [list_of_its_args]}
+def getScriptsAndArgs(args=[]):
+  # Syntax of args: script.py [args:a1,a2=val,an] ... script.py [args:a1,a2=val,an]
+  scriptArgs = []
+  currentKey = None
+  argsPrefix = "args:"
+  callPython = False
+  currentScript = None
+
+  for i in range(len(args)):
+    elt = args[i]
+
+    if elt.startswith(argsPrefix):
+      if not currentKey or callPython:
+        raise SalomeRunnerException("args list must follow corresponding script file in command line.")
+      elt = elt.replace(argsPrefix, '')
+      scriptArgs[len(scriptArgs)-1][currentKey] = elt.split(",")
+      currentKey = None
+      callPython = False
+    elif elt.startswith("python"):
+      callPython = True
+    elif os.path.isfile(elt) or os.path.isfile(elt+".py"):
+      if elt[-4:] != ".hdf":
+        if elt[-3:] == ".py":
+          currentScript = os.path.abspath(elt)
+        elif os.path.isfile(elt+".py"):
+          currentScript = os.path.abspath(elt+".py")
+        else:
+          currentScript = os.path.abspath(elt) # python script not necessary has .py extension
+        pass
+      if currentScript and callPython:
+        currentKey = "@PYTHONBIN@ "+currentScript
+        scriptArgs.append({currentKey:[]})
+        callPython = False
+      elif currentScript:
+        if not os.access(currentScript, os.X_OK):
+          currentKey = "@PYTHONBIN@ "+currentScript
+          scriptArgs.append({currentKey:[]})
+        else:
+          ispython = False
+          try:
+            fn = open(currentScript)
+            for i in xrange(10): # read only 10 first lines 
+              ln = fn.readline()
+              if re.search("#!.*python"): 
+                ispython = True
+                break
+              pass
+            fn.close()
+          except:
+            pass
+          if not ispython and currentScript[-3:] == ".py":
+            currentKey = "@PYTHONBIN@ "+currentScript
+          else:
+            currentKey = currentScript
+            pass
+          scriptArgs.append({currentKey:[]})
+  # end for loop
+  return scriptArgs
+#
+
+# Formatting scripts and args as a Bash-like command-line:
+# script1.py [args] ; script2.py [args] ; ...
+def formatScriptsAndArgs(scriptArgs=[]):
+    commands = []
+    for sc_dict in scriptArgs:
+      for script, sc_args in sc_dict.items(): # single entry
+        cmd = script
+        if sc_args:
+          cmd = cmd + " " + " ".join(sc_args)
+        commands.append(cmd)
+
+    command = "; ".join(["%s"%x for x in commands])
+    return command
+#
+
+# Ensure OMNIORB_USER_PATH is defined. This variable refers to a the folder in which
+# SALOME will write omniOrb configuration files.
+# If OMNIORB_USER_PATH is already set, only checks write access to associated directory ;
+# an exception is raised if check fails. It allows users for choosing a specific folder.
+# Else the function sets OMNIORB_USER_PATH this way:
+# - If APPLI environment variable is set, OMNIORB_USER_PATH is set to ${APPLI}/USERS.
+#   The function does not check USERS folder existence or wrute access. This folder
+#   must exist ; this is the case if SALOME virtual application has been create using
+#   appli_gen.py script.
+# - Else OMNIORB_USER_PATH is set to user home directory.
+def setOmniOrbUserPath():
+  omniorbUserPath = os.getenv("OMNIORB_USER_PATH")
+  if omniorbUserPath:
+    if not os.access(omniorbUserPath, os.W_OK):
+      raise Exception("Unable to get write access to directory: %s"%omniorbUserPath)
+    pass
+  else:
+    homePath = os.path.realpath(os.path.expanduser('~'))
+    #defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
+    defaultOmniorbUserPath = homePath
+    if os.getenv("APPLI"):
+      defaultOmniorbUserPath = os.path.join(homePath, os.getenv("APPLI"), "USERS")
+      pass
+    os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
+#
index 680f862a582704c0fd8923a80f8ec70600fe3ea7..9fa592048266be5e52432d58d08a8a613f0a9cd9 100644 (file)
@@ -74,6 +74,10 @@ SET(_found1 ${PYTHONINTERP_FOUND})
 IF (PYTHONINTERP_FOUND)
   # Now ensure we find the Python libraries matching the interpreter:
   # This uses the variable PYTHON_EXECUTABLE
+
+  GET_FILENAME_COMPONENT(_python_bin "${PYTHON_EXECUTABLE}" NAME )
+  SET(PYTHONBIN "${_python_bin}" CACHE STRING "Name of Python interpreter")
+
   GET_FILENAME_COMPONENT(_python_dir "${PYTHON_EXECUTABLE}" PATH)
   GET_FILENAME_COMPONENT(CMAKE_INCLUDE_PATH "${_python_dir}/../include/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}" ABSOLUTE)
   GET_FILENAME_COMPONENT(CMAKE_LIBRARY_PATH "${_python_dir}/../lib" ABSOLUTE)