From: vsr Date: Wed, 20 May 2009 12:12:09 +0000 (+0000) Subject: Fix problem with wrong permissions on the /tmp/logs folder X-Git-Tag: V5_1_2rc1~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7c153ca98701cd7ea03b9a3ce2e837108aa1be08;p=modules%2Fkernel.git Fix problem with wrong permissions on the /tmp/logs folder --- diff --git a/bin/salome_utils.py b/bin/salome_utils.py index 61d609273..f81107d3c 100644 --- a/bin/salome_utils.py +++ b/bin/salome_utils.py @@ -183,12 +183,12 @@ def getAppName(): # --- -def getPortNumber(): +def getPortNumber(use_default=True): """ Get current naming server port number: 1. try NSPORT environment variable 1. if fails, try to parse config file defined by OMNIORB_CONFIG environment variable - 2. if fails, return 2809 as default port number + 2. if fails, return 2809 as default port number (if use_default is True) or None (id use_default is False) """ import os try: @@ -197,7 +197,8 @@ def getPortNumber(): pass port = getPortFromORBcfg() if port is not None: return port - return 2809 # '2809' is default port number + if use_default: return 2809 # '2809' is default port number + return None # --- @@ -351,22 +352,34 @@ def generateFileName( dir, prefix = None, suffix = None, extension = None, # --- -def makeTmpDir( path ): +def makeTmpDir( path, mode=0777 ): """ Make temporary directory with the specified path. If the directory exists then clear its contents. Parameters: - path : absolute path to the directory to be created. + - mode : access mode """ import os - if os.path.exists( path ): os.system( "rm -rf " + path + "/*" ) pass else: - os.makedirs( path, 0777 ) - pass + dirs = path.split("/") + shift1 = shift2 = 0 + if not dirs[0]: shift1 = 1 + if dirs[-1]: shift2 = 1 + for i in range(1+shift1,len(dirs)+shift2): + p = "/".join(dirs[:i]) + try: + os.mkdir(p, mode) + os.chmod(p, mode) + except: + pass + pass + pass + pass # --- diff --git a/bin/setenv.py b/bin/setenv.py index cde2e1165..411148712 100755 --- a/bin/setenv.py +++ b/bin/setenv.py @@ -154,12 +154,15 @@ def set_env(args, modules_list, modules_root_dir, silent=False): """Add to the PATH-variables modules specific paths""" import os - from salome_utils import getTmpDir, generateFileName, makeTmpDir + from salome_utils import getTmpDir, generateFileName, makeTmpDir, getPortNumber # create temporary directory for environment files needed by modules from the list - tmp_dir = getTmpDir() - env_dir = generateFileName(tmp_dir, prefix="env", with_port=True) - makeTmpDir(env_dir) + port = getPortNumber(False) + if port: + tmp_dir = getTmpDir() + env_dir = generateFileName(tmp_dir, prefix="env", with_port=True) + makeTmpDir(env_dir) + pass python_version="python%d.%d" % sys.version_info[0:2] modules_root_dir_list = [] @@ -198,13 +201,15 @@ def set_env(args, modules_list, modules_root_dir, silent=False): salome_subdir, "shared_modules"), "PYTHONPATH") - + # set environment by modules from the list - try: - mod=__import__(module.lower()+"_setenv") - mod.set_env(args) - pass - except: + if port: + try: + mod=__import__(module.lower()+"_setenv") + mod.set_env(args) + pass + except: + pass pass pass pass