#------------------------------------
# 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
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")
#
#------------------------------------
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():