From: Nabil Ghodbane Date: Mon, 1 May 2023 13:05:16 +0000 (+0200) Subject: spns #34816: restore backward compatibility of SAT master since SalomeContext does... X-Git-Tag: V9_11_0~4^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b233c572b466a2f53f5deba734738246e199403b;p=tools%2Fsat.git spns #34816: restore backward compatibility of SAT master since SalomeContext does ot implement appendVariable method for KERNEL releases <= V_9_10 --- 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')