]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
PortManager info must be shared by applications; so they go to temporary folder
authorCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 5 Apr 2017 14:38:57 +0000 (16:38 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Wed, 5 Apr 2017 14:38:57 +0000 (16:38 +0200)
bin/PortManager.py
bin/salomeContextUtils.py.in

index 18350254d1bc1918315b5cc0ea32470b2c630f46..7e83d4696e5f6705b6db2e4329227693ce16ff5a 100644 (file)
@@ -49,6 +49,7 @@ logger = createLogger()
 #------------------------------------
 # A file locker
 def __acquire_lock(lock):
+  logger.debug("ACQUIRE LOCK")
   if sys.platform == "win32":
     import msvcrt
     # lock 1 byte: file is supposed to be zero-byte long
@@ -56,14 +57,17 @@ def __acquire_lock(lock):
   else:
     import fcntl
     fcntl.flock(lock, fcntl.LOCK_EX)
+  logger.debug("LOCK ACQUIRED")
 #
 def __release_lock(lock):
+  logger.debug("RELEASE LOCK")
   if sys.platform == "win32":
     import msvcrt
     msvcrt.locking(lock.fileno(), msvcrt.LK_UNLCK, 1)
   else:
     import fcntl
     fcntl.flock(lock, fcntl.LOCK_UN)
+  logger.debug("LOCK RELEASED")
 #
 #------------------------------------
 
index 7f9151bcfb1bc4d9f0d15e2215f0939d89ead85a..c078c96fe2ce564f593078eb07f12ee7e58bbf73 100644 (file)
@@ -320,13 +320,23 @@ def setOmniOrbUserPath():
       raise Exception("Unable to get write access to directory: %s"%omniorbUserPath)
     pass
   else:
-    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")
-      pass
-    os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
+    # Must be in /tmp (or equivalent) to handle application concurrency
+    try:
+      import tempfile
+      temp = tempfile.NamedTemporaryFile()
+      temp_dir = os.path.dirname(temp.name)
+      temp.close()
+      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:
+      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")
+        pass
+      os.environ["OMNIORB_USER_PATH"] = defaultOmniorbUserPath
 #
 
 def getHostname():