Salome HOME
projects
/
modules
/
kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Compilation under Windows: add missing header
[modules/kernel.git]
/
bin
/
salomeContextUtils.py.in
diff --git
a/bin/salomeContextUtils.py.in
b/bin/salomeContextUtils.py.in
index 43443e7d169b17fe184c58190951f27ef9157b3b..d9b33b50af2d7822179e0753f72973f3527fe899 100644
(file)
--- a/
bin/salomeContextUtils.py.in
+++ b/
bin/salomeContextUtils.py.in
@@
-1,6
+1,4
@@
-#! /usr/bin/env python
-
-# Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2013-2021 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
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@
-221,17
+219,18
@@
def getScriptsAndArgs(args=None, searchPathList=None):
callPython = True
afterArgs = False
else:
callPython = True
afterArgs = False
else:
+ file_extension = os.path.splitext(elt)[-1]
if not os.path.isfile(elt) and not os.path.isfile(elt+".py"):
eltInSearchPath = __getScriptPath(elt, searchPathList)
if eltInSearchPath is None or (not os.path.isfile(eltInSearchPath) and not os.path.isfile(eltInSearchPath+".py")):
if not os.path.isfile(elt) and not os.path.isfile(elt+".py"):
eltInSearchPath = __getScriptPath(elt, searchPathList)
if eltInSearchPath is None or (not os.path.isfile(eltInSearchPath) and not os.path.isfile(eltInSearchPath+".py")):
- if
elt[-3:]
== ".py":
+ if
file_extension
== ".py":
raise SalomeContextException("Script not found: %s"%elt)
scriptArgs.append(ScriptAndArgs(script=elt))
continue
elt = eltInSearchPath
raise SalomeContextException("Script not found: %s"%elt)
scriptArgs.append(ScriptAndArgs(script=elt))
continue
elt = eltInSearchPath
- if
elt[-4:]
!= ".hdf":
- if
elt[-3:]
== ".py" or isDriver:
+ if
file_extension
!= ".hdf":
+ if
file_extension
== ".py" or isDriver:
currentScript = os.path.abspath(elt)
elif os.path.isfile(elt+".py"):
currentScript = os.path.abspath(elt+".py")
currentScript = os.path.abspath(elt)
elif os.path.isfile(elt+".py"):
currentScript = os.path.abspath(elt+".py")
@@
-244,6
+243,7
@@
def getScriptsAndArgs(args=None, searchPathList=None):
scriptArgs.append(ScriptAndArgs(script=currentKey))
callPython = False
elif currentScript:
scriptArgs.append(ScriptAndArgs(script=currentKey))
callPython = False
elif currentScript:
+ script_extension = os.path.splitext(currentScript)[-1]
if isDriver:
currentKey = currentScript
scriptArgs.append(ScriptAndArgs(script=currentKey))
if isDriver:
currentKey = currentScript
scriptArgs.append(ScriptAndArgs(script=currentKey))
@@
-264,7
+264,7
@@
def getScriptsAndArgs(args=None, searchPathList=None):
fn.close()
except:
pass
fn.close()
except:
pass
- if not ispython and
currentScript[-3:]
== ".py":
+ if not ispython and
script_extension
== ".py":
currentKey = "@PYTHONBIN@ "+currentScript
else:
currentKey = currentScript
currentKey = "@PYTHONBIN@ "+currentScript
else:
currentKey = currentScript
@@
-286,12
+286,18
@@
def getScriptsAndArgs(args=None, searchPathList=None):
# Formatting scripts and args as a Bash-like command-line:
# script1.py [args] ; script2.py [args] ; ...
# scriptArgs is a list of ScriptAndArgs objects; their output parameters are omitted
# Formatting scripts and args as a Bash-like command-line:
# script1.py [args] ; script2.py [args] ; ...
# scriptArgs is a list of ScriptAndArgs objects; their output parameters are omitted
-def formatScriptsAndArgs(scriptArgs=None):
+def formatScriptsAndArgs(scriptArgs=None
, escapeSpaces=False
):
if scriptArgs is None:
return ""
commands = []
for sa_obj in scriptArgs:
cmd = sa_obj.script
if scriptArgs is None:
return ""
commands = []
for sa_obj in scriptArgs:
cmd = sa_obj.script
+ if escapeSpaces and cmd:
+ if sys.platform == "win32":
+ cmd = cmd.replace(' ', ' "', 1)
+ cmd = cmd + '"'
+ else:
+ cmd = cmd.replace(' ', '\ ').replace('\ ', ' ', 1)
if sa_obj.args:
cmd = " ".join([cmd]+sa_obj.args)
commands.append(cmd)
if sa_obj.args:
cmd = " ".join([cmd]+sa_obj.args)
commands.append(cmd)
@@
-308,9
+314,9
@@
def formatScriptsAndArgs(scriptArgs=None):
# 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 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 write access. This folder
-#
must exist ; t
his is the case if SALOME virtual application has been created using
+# - If APPLI environment variable is set,
and if ${APPLI}/USERS points at an existing
+#
folder with write access, then OMNIORB_USER_PATH is set to ${APPLI}/USERS.
+#
T
his is the case if SALOME virtual application has been created using
# appli_gen.py script.
# - Else OMNIORB_USER_PATH is set to user home directory.
def setOmniOrbUserPath():
# appli_gen.py script.
# - Else OMNIORB_USER_PATH is set to user home directory.
def setOmniOrbUserPath():
@@
-334,7
+340,9
@@
def setOmniOrbUserPath():
#defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
defaultOmniorbUserPath = homePath
if os.getenv("APPLI"):
#defaultOmniorbUserPath = os.path.join(homePath, ".salomeConfig/USERS")
defaultOmniorbUserPath = homePath
if os.getenv("APPLI"):
- defaultOmniorbUserPath = os.path.join(homePath, os.getenv("APPLI"), "USERS")
+ appli_users_path=os.path.join(homePath, os.getenv("APPLI"), "USERS")
+ if os.access(appli_users_path, os.W_OK):
+ defaultOmniorbUserPath = appli_users_path
pass
os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
#
pass
os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
#