From b233c572b466a2f53f5deba734738246e199403b Mon Sep 17 00:00:00 2001 From: Nabil Ghodbane Date: Mon, 1 May 2023 15:05:16 +0200 Subject: [PATCH] spns #34816: restore backward compatibility of SAT master since SalomeContext does ot implement appendVariable method for KERNEL releases <= V_9_10 --- src/fileEnviron.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/fileEnviron.py b/src/fileEnviron.py index e09924b..20cdc1a 100644 --- a/src/fileEnviron.py +++ b/src/fileEnviron.py @@ -827,8 +827,22 @@ def main(args): # Create a SalomeContext which parses configFileNames to initialize environment try: from salomeContext import SalomeContext, SalomeContextException + if 'appendVariable' not in dir(SalomeContext): + # check whether the appendVariable method is implemented + def appendVariable(self, name, value, separator=os.pathsep): + if value == '': + return + value = os.path.expandvars(value) # expand environment variables + env = os.getenv(name, None) + if env is None: + os.environ[name] = value + else: + os.environ[name] = env + separator + value + return + SalomeContext.appendVariable = appendVariable + context = SalomeContext(None) - + # Here set specific variables, if needed # context.addToPath('mypath') # context.addToLdLibraryPath('myldlibrarypath') @@ -906,8 +920,21 @@ def main(args): # Create a SalomeContext which parses configFileNames to initialize environment try: from salomeContext import SalomeContext, SalomeContextException + if 'appendVariable' not in dir(SalomeContext): + # check whether the appendVariable method is implemented + def appendVariable(self, name, value, separator=os.pathsep): + if value == '': + return + value = os.path.expandvars(value) # expand environment variables + env = os.getenv(name, None) + if env is None: + os.environ[name] = value + else: + os.environ[name] = env + separator + value + return + SalomeContext.appendVariable = appendVariable + context = SalomeContext(None) - # Here set specific variables, if needed # context.addToPath('mypath') # context.addToLdLibraryPath('myldlibrarypath') -- 2.39.2