From: Cédric Aguerre Date: Fri, 23 Jan 2015 14:29:04 +0000 (+0100) Subject: use realpath to follow symbolic links X-Git-Tag: V7_5_1rc2~2 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2Fagr%2Ffix_realpath;p=modules%2Fkernel.git use realpath to follow symbolic links --- diff --git a/bin/appliskel/salome b/bin/appliskel/salome index 31f0da6bb..1bcae77fa 100755 --- a/bin/appliskel/salome +++ b/bin/appliskel/salome @@ -1,6 +1,6 @@ #! /usr/bin/env python -# Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2013-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 @@ -24,7 +24,7 @@ import sys def main(args): # Identify application path then locate configuration files - currentPath = os.path.dirname( os.path.abspath( __file__ ) ) + currentPath = os.path.realpath(os.path.dirname(os.path.abspath(__file__))) launcherFile = os.path.basename(__file__) from salome_starter import initialize initialize(currentPath, launcherFile) diff --git a/bin/appliskel/salome_starter.py b/bin/appliskel/salome_starter.py index 7eb0a7e5c..41dde839e 100644 --- a/bin/appliskel/salome_starter.py +++ b/bin/appliskel/salome_starter.py @@ -1,6 +1,6 @@ #! /usr/bin/env python -# Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2014, 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 @@ -61,7 +61,7 @@ def initialize(launcherPath, launcherFile): os.environ['APPLI'] = appliPath # needed to convert .sh environment files os.environ['ABSOLUTE_APPLI_PATH'] = absoluteAppliPath - sys.path[:0] = [os.path.join(absoluteAppliPath, "bin", "salome")] + sys.path[:0] = [os.path.realpath(os.path.join(absoluteAppliPath, "bin", "salome"))] # define folder to store omniorb config (initially in virtual application folder) try: diff --git a/bin/envSalome.py b/bin/envSalome.py index 3b7388f9f..14f7c9346 100755 --- a/bin/envSalome.py +++ b/bin/envSalome.py @@ -1,6 +1,6 @@ #! /usr/bin/env python # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -36,6 +36,7 @@ import sys import setenv kernel_root=os.getenv("KERNEL_ROOT_DIR") +kernel_root = os.path.realpath(kernel_root) sys.path[:0]=[os.path.join(kernel_root,"bin","salome")] argv = sys.argv[1:] diff --git a/bin/runSalome.py b/bin/runSalome.py index da1c56946..73a8b0df2 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -760,7 +760,7 @@ def useSalome(args, modules_list, modules_root_dir): def execScript(script_path): print 'executing', script_path - sys.path.insert(0, os.path.dirname(script_path)) + sys.path.insert(0, os.path.realpath(os.path.dirname(script_path))) execfile(script_path,globals()) del sys.path[0] diff --git a/bin/salomeContext.py b/bin/salomeContext.py index 51e0c51a9..954f86fd8 100644 --- a/bin/salomeContext.py +++ b/bin/salomeContext.py @@ -1,4 +1,4 @@ -# Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2013-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 @@ -221,7 +221,7 @@ class SalomeContext: import os absoluteAppliPath = os.getenv('ABSOLUTE_APPLI_PATH') import sys - path = os.path.join(absoluteAppliPath, "bin", "salome") + path = os.path.realpath(os.path.join(absoluteAppliPath, "bin", "salome")) if not path in sys.path: sys.path[:0] = [path] except: @@ -291,6 +291,7 @@ class SalomeContext: # set environment for reserved in reservedDict: a = filter(None, reservedDict[reserved]) # remove empty elements + a = [ os.path.realpath(x) for x in a ] reformattedVals = os.pathsep.join(a) self.addToVariable(reserved, reformattedVals) pass @@ -299,7 +300,9 @@ class SalomeContext: self.setVariable(key, val, overwrite=True) pass - sys.path[:0] = os.getenv('PYTHONPATH','').split(os.pathsep) + pythonpath = os.getenv('PYTHONPATH','').split(os.pathsep) + pythonpath = [ os.path.realpath(x) for x in pythonpath ] + sys.path[:0] = pythonpath # def _runAppli(self, args=None): diff --git a/bin/setenv.py b/bin/setenv.py index e302fd1dd..154829513 100755 --- a/bin/setenv.py +++ b/bin/setenv.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -*- coding: iso-8859-1 -*- -# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE # # Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS @@ -64,7 +64,7 @@ def add_path(directory, variable_name): newpath = string.join(newpath, splitsym) os.environ[variable_name] = newpath if variable_name == "PYTHONPATH": - sys.path[:0] = [directory] + sys.path[:0] = [os.path.realpath(directory)] # -----------------------------------------------------------------------------