X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=bin%2FsalomeContextUtils.py.in;h=71192305de34aaf0b1ec1d1330cf2097ebcf3791;hb=17f89acccd51b2d2c86d44e70a1c053c10da0b3d;hp=4835bcd25fd4a899c7f83b9306013b2b8ae36d39;hpb=1315fd971e7333a532456a346fce4c181487aaa3;p=modules%2Fkernel.git diff --git a/bin/salomeContextUtils.py.in b/bin/salomeContextUtils.py.in index 4835bcd25..71192305d 100644 --- a/bin/salomeContextUtils.py.in +++ b/bin/salomeContextUtils.py.in @@ -1,6 +1,4 @@ -#! /usr/bin/env python3 - -# Copyright (C) 2013-2016 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2013-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 @@ -263,9 +261,10 @@ def getScriptsAndArgs(args=None, searchPathList=None): ispython = True break pass - fn.close() - except: + except Exception: pass + finally: + fn.close() if not ispython and script_extension == ".py": currentKey = "@PYTHONBIN@ "+currentScript else: @@ -288,12 +287,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 -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 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) @@ -310,9 +315,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 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 ; this 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. +# This 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(): @@ -331,12 +336,14 @@ def setOmniOrbUserPath(): if not os.access(temp_dir, os.W_OK): raise Exception("Unable to get write access to directory: %s"%temp_dir) os.environ["OMNIORB_USER_PATH"] = temp_dir - except: + except Exception: 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") + 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 #