# ---
-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:
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
# ---
# ---
-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
# ---
"""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 = []
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