]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
spns #34816: restore backward compatibility of SAT master since SalomeContext does...
authorNabil Ghodbane <nabil.ghodbane@cea.fr>
Mon, 1 May 2023 13:05:16 +0000 (15:05 +0200)
committerNabil Ghodbane <nabil.ghodbane@cea.fr>
Tue, 16 May 2023 16:03:18 +0000 (18:03 +0200)
src/fileEnviron.py

index e09924b2ba5135cdb01d0563dec6700ce834b32b..20cdc1a53390016443f8a079360189e52ee3f65b 100644 (file)
@@ -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')