-import sys, os, string, glob, time, pickle
-import orbmodule
-
-process_id = {}
-
-# -----------------------------------------------------------------------------
-
-def add_path(directory, variable_name):
- """Function helper to add environment variables"""
- if not os.environ.has_key(variable_name):
- os.environ[variable_name] = ""
- pass
- if os.path.exists(directory):
- newpath=[]
- for _dir in os.environ[variable_name].split(":"):
- if os.path.exists(_dir):
- if not os.path.samefile(_dir, directory):
- newpath.append(_dir)
- else:
- if os.path.abspath(_dir) != os.path.abspath(directory):
- newpath.append(_dir)
- pass
- import string
- newpath[:0] = [ directory ]
- newpath = string.join(newpath,":")
- os.environ[variable_name] = newpath
- if variable_name == "PYTHONPATH":
- sys.path[:0] = [directory]
-
-# -----------------------------------------------------------------------------
-
-def get_config():
- """
- Get list of modules, paths.
-
- Read args from launch configure xml file and command line options.
- Check variables <module>_ROOT_DIR and set list of used modules.
- Return args, modules_list, modules_root_dir
- """
-
- # read args from launch configure xml file and command line options
-
- import launchConfigureParser
- args = launchConfigureParser.args
-
- # Check variables <module>_ROOT_DIR
- # and set list of used modules (without KERNEL)
-
- modules_list = []
- if args.has_key("modules"):
- modules_list += args["modules"]
- # KERNEL must be last in the list to locate it at the first place in PATH
- modules_list[:0] = ["KERNEL"]
- modules_list.reverse()
-
- modules_root_dir = {}
-
- to_remove_list=[]
- for module in modules_list :
- module_variable=module.upper()+"_ROOT_DIR"
- if not os.environ.has_key(module_variable):
- print "*******************************************************"
- print "*"
- print "* Environment variable",module_variable,"must be set"
- print "* Module", module, "will be not available"
- print "*"
- print "********************************************************"
- to_remove_list.append(module)
- continue
- pass
- module_root_dir = os.environ[module_variable]
- modules_root_dir[module]=module_root_dir
-
- for to_remove in to_remove_list:
- modules_list.remove(to_remove)
-
- while "KERNEL" in modules_list:
- modules_list.remove("KERNEL")
- pass
-
- if "SUPERV" in modules_list and not 'superv' in args['standalone']:
- args['standalone'].append("superv")
- pass
-
- return args, modules_list, modules_root_dir
-
-# -----------------------------------------------------------------------------
-
-def set_env(args, modules_list, modules_root_dir):
- """Add to the PATH-variables modules specific paths"""
-
- python_version="python%d.%d" % sys.version_info[0:2]
- modules_root_dir_list = []
- modules_list = modules_list[:] + ["KERNEL"]
- for module in modules_list :
- module_root_dir = modules_root_dir[module]
- modules_root_dir_list[:0] = [module_root_dir]
- add_path(os.path.join(module_root_dir,"lib",args['appname']),
- "LD_LIBRARY_PATH")
- add_path(os.path.join(module_root_dir,"bin",args['appname']),
- "PATH")
- if os.path.exists(module_root_dir + "/examples") :
- add_path(os.path.join(module_root_dir,"examples"),
- "PYTHONPATH")
- add_path(os.path.join(module_root_dir,"bin",args['appname']),
- "PYTHONPATH")
- add_path(os.path.join(module_root_dir,"lib",
- python_version,"site-packages",args['appname']),
- "PYTHONPATH")
- add_path(os.path.join(module_root_dir,"lib",args['appname']),
- "PYTHONPATH")
- add_path(os.path.join(module_root_dir,"lib",
- python_version,"site-packages",args['appname'],
- "shared_modules"),
- "PYTHONPATH")
-
- os.environ["SALOMEPATH"]=":".join(modules_root_dir_list)
-
- # special path for logger lib if needeed
-
- os.environ["SALOME_trace"]="local"
- if args['file']:
- os.environ["SALOME_trace"]=args['file'][0]
- if args['logger']:
- os.environ["SALOME_trace"]="with_logger"
- locdir=os.environ['PWD']
- libtracedir=os.path.join(locdir,"libSalomeTrace")
- libtrace = os.path.join(modules_root_dir["KERNEL"],"lib",
- args['appname'],
- "libSALOMELoggerClient.so.0.0.0")
- libtraceln = os.path.join(libtracedir,"libSALOMELocalTrace.so")
- aCommand = 'rm -rf ' + libtracedir + "; "
- aCommand += 'mkdir ' + libtracedir + "; "
- aCommand += 'ln -s ' + libtrace + " " + libtraceln + "; "
- aCommand += 'ln -s ' + libtrace + " " + libtraceln + ".0; "
- aCommand += 'ln -s ' + libtrace + " " + libtraceln + ".0.0.0; "
- os.system(aCommand)
- add_path(libtracedir, "LD_LIBRARY_PATH")
-
- # set environment for SMESH plugins
-
- if "SMESH" in modules_list:
- os.environ["SMESH_MeshersList"]="StdMeshers"
- if not os.environ.has_key("SALOME_StdMeshersResources"):
- os.environ["SALOME_StdMeshersResources"] \
- = modules_root_dir["SMESH"]+"/share/"+args["appname"]+"/resources"
- pass
- if args.has_key("SMESH_plugins"):
- for plugin in args["SMESH_plugins"]:
- if os.environ.has_key(plugin.upper()+"_ROOT_DIR"):
- os.environ["SMESH_MeshersList"] \
- = os.environ["SMESH_MeshersList"]+":"+plugin
- plugin_root = os.environ[plugin.upper()+"_ROOT_DIR"]
- if not os.environ.has_key("SALOME_"+plugin+"Resources"):
- os.environ["SALOME_"+plugin+"Resources"] \
- = plugin_root+"/share/"+args["appname"]+"/resources"
- add_path(os.path.join(plugin_root,"lib",python_version,
- "site-packages",args['appname']),
- "PYTHONPATH")
- add_path(os.path.join(plugin_root,"lib",args['appname']),
- "PYTHONPATH")
- add_path(os.path.join(plugin_root,"lib",args['appname']),
- "LD_LIBRARY_PATH")
- add_path(os.path.join(plugin_root,"bin",args['appname']),
- "PYTHONPATH")
- add_path(os.path.join(plugin_root,"bin",args['appname']),
- "PATH")
- pass
- pass