From ed37c79a00e610332317a9c1466965da9d92bb90 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 25 Nov 2010 11:43:21 +0000 Subject: [PATCH] Merge from V5_1_main branch 24/11/2010 --- Makefile.am | 4 +- bin/appli_gen.py | 6 + bin/appliskel/getAppliPath.py | 8 +- bin/appliskel/runSalomeScript | 228 ++++++++ bin/appliskel/runSession | 2 +- bin/appliskel/update_catalogs.py | 251 +++++++++ bin/envSalome.py | 15 +- bin/killSalomeWithPort.py | 7 +- bin/launchConfigureParser.py | 19 +- bin/runSalome.py | 198 +++---- bin/server.py | 10 +- bin/setenv.py | 7 + bin/virtual_salome.py | 15 + configure.ac | 43 +- doc/Makefile.am | 10 +- doc/docutils/Makefile.am | 94 ++++ doc/{ => docutils/archives}/INSTALL.txt | 0 .../archives}/KERNEL_Services.txt | 0 .../archives}/SALOME_Application.txt | 0 doc/{ => docutils/archives}/UnitTests.txt | 0 doc/{ => docutils/archives}/index.txt | 0 .../archives}/kernel_resources.txt | 0 doc/{ => docutils/archives}/rst.css | 0 doc/{ => docutils/archives}/txt2html.sh | 0 doc/{ => docutils/archives}/userguide.txt | 0 doc/docutils/conf.py | 200 +++++++ doc/docutils/docapi.rst | 46 ++ doc/docutils/index.rst | 22 + doc/docutils/overview.rst | 47 ++ doc/docutils/salomepypkg.rst | 270 ++++++++++ doc/salome/gui/doxyfile.in | 2 +- doc/salome/kernelpypkg.dox | 14 + doc/salome/main.dox | 1 + idl/Makefile.am | 13 +- idl/SALOMEDS_Attributes.idl | 10 +- idl/SALOME_ContainerManager.idl | 2 +- idl/SALOME_Parametric.idl | 82 +++ idl/SALOME_Types.idl | 31 ++ resources/KERNELCatalog.xml.in | 24 + salome_adm/cmake_files/FindKERNEL.cmake | 15 +- salome_adm/cmake_files/FindMPI.cmake | 17 + salome_adm/cmake_files/FindPLATFORM.cmake | 3 +- salome_adm/cmake_files/FindPYTHON.cmake | 21 + salome_adm/cmake_files/FindSWIG.cmake | 6 + salome_adm/cmake_files/Makefile.am | 1 + salome_adm/cmake_files/am2cmake.py | 442 ++++++++++++++-- salome_adm/cmake_files/copytree1.py | 91 ++++ salome_adm/unix/config_files/Makefile.am | 5 +- salome_adm/unix/config_files/check_boost.m4 | 47 +- salome_adm/unix/config_files/check_mpi.m4 | 9 + salome_adm/unix/config_files/check_omniorb.m4 | 2 +- salome_adm/unix/config_files/check_openmpi.m4 | 2 + salome_adm/unix/config_files/check_sphinx.m4 | 35 ++ salome_adm/unix/config_files/check_vtk.m4 | 388 ++++++++++++++ salome_adm/unix/config_files/hack_libtool.m4 | 41 ++ salome_adm/unix/config_files/python.m4 | 12 + salome_adm/unix/make_common_starter.am | 10 +- src/Container/SALOME_Container.py | 2 +- src/Container/SALOME_ContainerManager.cxx | 45 +- src/Container/SALOME_PyNode.py | 4 +- src/HDFPersist/HDFascii.cc | 29 +- src/HDFPersist/HDFdatasetRead.c | 4 +- src/KERNEL_PY/Makefile.am | 8 +- src/KERNEL_PY/__init__.py | 218 ++++++++ src/KERNEL_PY/import_hook.py | 24 +- src/KERNEL_PY/kernel/Makefile.am | 11 + src/KERNEL_PY/kernel/__init__.py | 2 + src/KERNEL_PY/kernel/deprecation.py | 115 +++++ src/KERNEL_PY/kernel/logconfig.py.in | 27 + src/KERNEL_PY/kernel/logger.py | 230 +++++++++ src/KERNEL_PY/kernel/studyedit.py | 487 ++++++++++++++++++ src/KERNEL_PY/kernel/termcolor.py | 150 ++++++ src/KERNEL_PY/salome.py | 10 +- src/Launcher/Launcher_Job_SALOME.cxx | 2 +- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx | 8 +- src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py | 17 +- .../Test/testcontainermanager.py | 30 +- .../Test/testresourcemanager.py | 42 +- src/MPIContainer/MPIContainer_i.cxx | 1 + src/NamingService/SALOME_NamingService.cxx | 8 +- src/ResourcesManager/ResourcesManager.cxx | 15 +- .../SALOME_ResourcesCatalog_Handler.cxx | 5 - src/SALOMEDS/SALOMEDS_Study_i.cxx | 7 +- .../SALOMEDSImpl_AttributeTarget.cxx | 25 +- .../SALOMEDSImpl_AttributeTarget.hxx | 5 +- .../SALOMEDSImpl_ScalarVariable.cxx | 10 +- .../SALOMEDSImpl_StudyManager.cxx | 36 +- src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx | 50 +- src/TOOLSDS/SALOMEDS_Tool.cxx | 7 + src/Utils/Utils_Identity.py | 2 +- 90 files changed, 4086 insertions(+), 378 deletions(-) create mode 100755 bin/appliskel/runSalomeScript create mode 100644 bin/appliskel/update_catalogs.py create mode 100644 doc/docutils/Makefile.am rename doc/{ => docutils/archives}/INSTALL.txt (100%) rename doc/{ => docutils/archives}/KERNEL_Services.txt (100%) rename doc/{ => docutils/archives}/SALOME_Application.txt (100%) rename doc/{ => docutils/archives}/UnitTests.txt (100%) rename doc/{ => docutils/archives}/index.txt (100%) rename doc/{ => docutils/archives}/kernel_resources.txt (100%) rename doc/{ => docutils/archives}/rst.css (100%) rename doc/{ => docutils/archives}/txt2html.sh (100%) rename doc/{ => docutils/archives}/userguide.txt (100%) create mode 100644 doc/docutils/conf.py create mode 100644 doc/docutils/docapi.rst create mode 100644 doc/docutils/index.rst create mode 100644 doc/docutils/overview.rst create mode 100644 doc/docutils/salomepypkg.rst create mode 100644 doc/salome/kernelpypkg.dox create mode 100644 idl/SALOME_Parametric.idl create mode 100644 idl/SALOME_Types.idl create mode 100755 salome_adm/cmake_files/copytree1.py create mode 100644 salome_adm/unix/config_files/check_sphinx.m4 create mode 100644 salome_adm/unix/config_files/check_vtk.m4 create mode 100644 salome_adm/unix/config_files/hack_libtool.m4 create mode 100644 src/KERNEL_PY/__init__.py create mode 100644 src/KERNEL_PY/kernel/Makefile.am create mode 100644 src/KERNEL_PY/kernel/__init__.py create mode 100644 src/KERNEL_PY/kernel/deprecation.py create mode 100755 src/KERNEL_PY/kernel/logconfig.py.in create mode 100644 src/KERNEL_PY/kernel/logger.py create mode 100644 src/KERNEL_PY/kernel/studyedit.py create mode 100644 src/KERNEL_PY/kernel/termcolor.py diff --git a/Makefile.am b/Makefile.am index 2dd472d1e..81e796864 100644 --- a/Makefile.am +++ b/Makefile.am @@ -26,7 +26,7 @@ # $Header$ # include $(top_srcdir)/salome_adm/unix/make_common_starter.am - +# if CORBA_GEN IDLDIR = idl endif @@ -36,7 +36,7 @@ ACLOCAL_AMFLAGS = -I salome_adm/unix/config_files if WITHONLYLAUNCHER SUBDIRS = src resources else - SUBDIRS = salome_adm $(IDLDIR) src doc bin resources + SUBDIRS = salome_adm $(IDLDIR) src bin doc resources endif DIST_SUBDIRS= salome_adm idl src doc bin resources diff --git a/bin/appli_gen.py b/bin/appli_gen.py index c4566a80b..f6e5bcc7e 100644 --- a/bin/appli_gen.py +++ b/bin/appli_gen.py @@ -190,7 +190,9 @@ def install(prefix,config_file,verbose=0): 'runAppli', 'runConsole', 'runSession', + 'runSalomeScript', 'runTests', + 'update_catalogs.py', '.bashrc', ): virtual_salome.symlink("./bin/salome/appliskel/"+fn,os.path.join(home_dir, fn)) @@ -300,6 +302,10 @@ def main(): default=0, help="Increase verbosity") options, args = parser.parse_args() + if not os.path.exists(options.config): + print "ERROR: config file %s does not exist. It is mandatory." % options.config + sys.exit(1) + install(prefix=options.prefix,config_file=options.config,verbose=options.verbose) pass diff --git a/bin/appliskel/getAppliPath.py b/bin/appliskel/getAppliPath.py index 63cea7e7b..4e90be665 100755 --- a/bin/appliskel/getAppliPath.py +++ b/bin/appliskel/getAppliPath.py @@ -49,9 +49,7 @@ def set_var(VAR, strpath): return "setenv %s %s" % (VAR, value) else: return "export %s=%s" % (VAR, value) - -applipath=relpath(os.path.realpath(os.path.dirname(__file__)),os.path.realpath(os.getenv('HOME'))) - -#print set_var('APPLI', applipath) -print applipath +if __name__ == "__main__": + applipath=relpath(os.path.realpath(os.path.dirname(__file__)),os.path.realpath(os.getenv('HOME'))) + print applipath diff --git a/bin/appliskel/runSalomeScript b/bin/appliskel/runSalomeScript new file mode 100755 index 000000000..752f42074 --- /dev/null +++ b/bin/appliskel/runSalomeScript @@ -0,0 +1,228 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +import os,sys,optparse +import socket,shutil +import re + +usage=""" + Connect to a SALOME session (local or remote) and execute a Python script with data files in argument (optional) + + Usage: %prog [ options ] script + + script : The Python script to execute in the SALOME session + + SALOME SESSION + -------------- + If PORT and MACHINE are not given, try to connect to the last active session on the local machine + If PORT and MACHINE are given, try to connect to the remote session associated with PORT on MACHINE + If MACHINE is not given, try to connect to the session associated to PORT on the local machine + If PORT is not given, try to connect to the remote session associated to port 2810 on MACHINE + + If MACHINE isn't localhost or hostname, USER is needed + + If Salome isn't installed on the local machine, use APPLI_DIST to execute a distant session + + + INPUTS AND OUPUTS + ----------------- + script is needed in all case + INPUT and OUTPUT are used only when Salome isn't on local machine. It defines a list of script (full path, blank separated) + Actions done with these two lists are : + - adjustment of path in a temporary script file + - copy of the input files and script file on the distant machine + +""" + +appli_local=os.path.realpath(os.path.dirname(__file__)) + +def get_hostname(): + return socket.gethostname().split('.')[0] + +def vararg_callback(option, opt_str, value, parser): + """optparse callback for variable length arguments""" + assert value is None + + done = 0 + value = [] + rargs = parser.rargs + while rargs: + arg = rargs[0] + + # Stop if we hit an arg like "--foo", "-a", "-fx", "--file=f", + # etc. Note that this also stops on "-3" or "-3.0", so if + # your option takes numeric values, you will need to handle this. + if ((arg[:2] == "--" and len(arg) > 2) or + (arg[:1] == "-" and len(arg) > 1 and arg[1] != "-")): + break + else: + value.append(arg) + del rargs[0] + + setattr(parser.values, option.dest, value) + +def parse_args(): + """parse arguments, check validity and set defaults""" + parser = optparse.OptionParser(usage=usage) + parser.add_option('-p','--port', dest="port", default='', help="The port to connect to") + parser.add_option('-m','--machine', dest="machine", default='', help="The computer to connect to") + parser.add_option('-d','--directory', dest="directory", help="[Distant Mode] The APPLI_HOME path on the distant machine (must be used if Salome isn't on the local machine)") + parser.add_option('-u','--user', dest="user", default='', help="[Distant Mode] The user on the computer to connect to") + parser.add_option('-i','--infiles', dest="infiles", default=[], action="callback", callback=vararg_callback, + help="[Distant Mode] The list of input files (blank separated) used in the Python script") + parser.add_option('-o','--outfiles', dest="outfiles", default=[], action="callback", callback=vararg_callback, + help="[Distant Mode] The list of output files (blank separated) generated by the Python script") + + args=sys.argv[1:] + + script="" + if args: + script=args.pop() + + options, args = parser.parse_args(args) + + #check the arguments + if not os.path.exists(script): + print "ERROR: the script file is mandatory" + sys.exit(1) + + machine=options.machine + port=options.port + user=options.user + infiles = options.infiles + outfiles = options.outfiles + directory=options.directory + + mode="local" + + if machine: + here=get_hostname() + if machine != here and machine != "localhost": + #SALOME server is on a remote computer + mode="remote" + + if not user: + print "ERROR: the remote execution needs -u user argument" + sys.exit(1) + + if not os.path.exists(os.path.join(appli_local,"runSession")): + if not directory: + print "ERROR: the remote execution without SALOME installation needs -d directory argument" + sys.exit(1) + + return mode,user,machine,port,directory,infiles,outfiles,script + +def copy_files(user,machine,script,infiles,outfiles,directory): + """modify script, copy files to remote computer and return lists of copied files""" + + namescript=os.path.basename(script) + logname=os.getenv("LOGNAME",user) + tmp_script="/tmp/%s_%s_%s" % (logname,os.getpid(),namescript) + fscript=open(script) + script_text=fscript.read() + fscript.close() + + list_infiles=[] + list_outfiles=[] + + n=0 + for infile in infiles: + # generate a temporary file name + namefile=os.path.basename(infile) + tmp_file="/tmp/%s_%s_i%s_%s" % (logname,os.getpid(),n,namefile) + + #modify the salome script + script_text = re.sub(infile,tmp_file,script_text) + + # copy the infile to the remote server (into /tmp) + cmd="scp %s %s@%s:%s" % (infile,user,machine,tmp_file) + print "[ SCP ]",cmd + os.system(cmd) + + list_infiles.append(tmp_file) + n=n+1 + + n=0 + for outfile in outfiles: + # generate a temporary file name + namefile=os.path.basename(outfile) + tmp_file="/tmp/%s_%s_o%s_%s" % (logname,os.getpid(),n,namefile) + + #modify the salome script + script_text = re.sub(outfile,tmp_file,script_text) + + list_outfiles.append(tmp_file) + n=n+1 + + fscript=open(tmp_script,'w') + fscript.write(script_text) + fscript.close() + + if directory: + #copy the salome script on the remote server + cmd="scp %s %s@%s:%s" % (tmp_script,user,machine,tmp_script) + print "[ SCP ]",cmd + os.system(cmd) + + return list_infiles, list_outfiles, tmp_script + +def main(): + + mode,user,machine,port,directory,infiles,outfiles,script = parse_args() + + tmp_script=script + + print "mode:",mode + + if mode == "remote": + list_infiles, list_outfiles, tmp_script = copy_files(user,machine,script,infiles,outfiles,directory) + + ################################################# + # Execution # + ################################################# + if directory: + print "[ REMOTE ]" + + # execute runSession from the remote SALOME application + cmd="ssh %s@%s %s/runSession " % (user,machine,directory) + if port: + cmd=cmd+"-p %s "%port + cmd = cmd +"python " + tmp_script + print '[ SSH ] ' + cmd + os.system(cmd) + + else: + print "[ LOCAL ]" + + # execute runSession from the local SALOME application + cmd="%s/runSession " % appli_local + if machine: + cmd=cmd+"-m %s "%machine + if port: + cmd=cmd+"-p %s "%port + cmd = cmd +"python " + tmp_script + print '[ SH ] ' + cmd + os.system(cmd) + + ################################################# + # Get remote files and clean # + ################################################# + if mode == "remote": + temp_files=list_infiles+list_outfiles + + #get the outfiles + for outfile in outfiles: + remote_outfile=list_outfiles.pop(0) + cmd="scp %s@%s:%s %s" %(user,machine,remote_outfile,outfile) + print "[ SCP ] "+cmd + os.system(cmd) + + #clean temporary files + cmd="ssh %s@%s \\rm -f %s" % (user,machine," ".join(temp_files)) + print '[ SSH ] ' + cmd + os.system(cmd) + os.remove(tmp_script) + +if __name__ == '__main__': + main() + diff --git a/bin/appliskel/runSession b/bin/appliskel/runSession index 885a7e5c8..2f792b3f2 100755 --- a/bin/appliskel/runSession +++ b/bin/appliskel/runSession @@ -114,7 +114,7 @@ fi # --- invoke shell with or without args if [ $# -ne 0 ] ; then - ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py $* + ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py -exec $* else ${KERNEL_ROOT_DIR}/bin/salome/envSalome.py /bin/bash --rcfile ${HOME}/${APPLI}/.bashrc diff --git a/bin/appliskel/update_catalogs.py b/bin/appliskel/update_catalogs.py new file mode 100644 index 000000000..eacd6e367 --- /dev/null +++ b/bin/appliskel/update_catalogs.py @@ -0,0 +1,251 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +""" +import sys,os,shutil,glob,socket +import optparse + +import getAppliPath +appli_local=os.path.realpath(os.path.dirname(__file__)) +APPLI=getAppliPath.relpath(appli_local,os.path.realpath(os.getenv('HOME'))) + +usage="""usage: %prog [options] +Typical use is: + python update_catalogs.py + +You need to have a well installed SALOME application with a CatalogResources.base.xml file. +This file is used (parsed) to collect all module catalogs from distant resources and +put them in the directory "remote_catalogs" with sub-directories with same name as the distant resource. +Distant resources are all the resources except the main SALOME application. +Module catalogs from distant resources are copied by the remote protocol declared in the catalog (rcp or rsh) +except for the user resources on the local machine (local copy: cp). + +In a second time, this procedure generates a ready to use CatalogResources.xml with all available components +for each resource. +""" + +try: + # cElementTree from Python 2.5+ + import xml.etree.cElementTree as etree_ +except ImportError: + try: + import xml.etree.ElementTree as etree_ + except ImportError: + try: + import cElementTree as etree_ + except ImportError: + try: + # normal ElementTree install + import elementtree.ElementTree as etree_ + except ImportError: + raise + +class ParseError(Exception): + pass + +catalog_file_base=os.path.join(appli_local,"CatalogResources.base.xml") +catalog_file=os.path.join(appli_local,"CatalogResources.xml") + +cata_dir=os.path.join(appli_local,"remote_catalogs") +cata_dir_bak=os.path.join(appli_local,"remote_catalogs.bak") + +SEP=":" +if sys.platform == "win32":SEP=";" + +def get_hostname(): + return socket.gethostname().split('.')[0] + +class Component: + """Define a SALOME component + - name : component name + - moduleName : module name + """ + def __init__(self,name,moduleName): + self.name=name + self.moduleName=moduleName + +class Resource: + """Define a SALOME resource + - components : the list of available components of the resource + """ + def __init__(self,node): + self.node=node + self.components=[] + self.resource_dir=None + self.build() + + def build(self): + self.attrs=self.node.attrib + #remove all children (components and modules) + for child in list(self.node): + self.node.remove(child) + + def update(self): + for compo in self.components: + child=etree_.Element("component",name=compo.name,moduleName=compo.moduleName) + child.tail="\n" + self.node.append(child) + + def get_rcp(self): + protocol= self.node.get("protocol") + if protocol and protocol[0]=='s':return "scp" + else:return "rcp" + + def get_user(self): + userName= self.node.get("userName") + if not userName: + userName=os.getenv('USER') + return userName + + def get_host(self): + hostname= self.node.get("hostname") + return hostname + + def get_name(self): + name= self.node.get("name") + if name:return name + return self.get_host() + + def get_appliPath(self): + appliPath= self.node.get("appliPath") + if appliPath is None: + appliPath=APPLI + return appliPath + + def get_catalogs(self): + """Get module catalogs file from the resource and copy them locally in remote_catalogs/""" + hostname=self.get_host() + appliPath= self.get_appliPath() + userName = self.get_user() + rcopy=self.get_rcp() + + resource_dir=os.path.join(cata_dir,self.get_name()) + + if hostname == "localhost" or hostname == get_hostname() and userName == os.getenv("USER"): + #local machine, use cp + if appliPath[0]!='/': + #relative path + appliPath=os.path.join(os.getenv("HOME"),appliPath) + + if appliPath == appli_local: + return + os.mkdir(resource_dir) + cata_path=os.path.join(appliPath,"share","salome","resources","*Catalog.xml") + cmd="cp %s %s" % (cata_path,resource_dir) + print cmd + os.system(cmd) + cata_path=os.path.join(appliPath,"share","salome","resources","*","*Catalog.xml") + cmd="cp %s %s" % (cata_path,resource_dir) + print cmd + os.system(cmd) + else: + #remote machine, use rcopy + os.mkdir(resource_dir) + cata_path=os.path.join(appliPath,"share","salome","resources","*Catalog.xml") + cmd="%s %s@%s:%s %s" + cmd= cmd%(rcopy,userName,hostname,cata_path,resource_dir) + print cmd + os.system(cmd) + cata_path=os.path.join(appliPath,"share","salome","resources","*","*Catalog.xml") + cmd="%s %s@%s:%s %s" + cmd= cmd%(rcopy,userName,hostname,cata_path,resource_dir) + print cmd + os.system(cmd) + + schema_cata=os.path.join(resource_dir,"*SchemaCatalog.xml") + os.system("rm %s"% schema_cata) + + self.resource_dir=os.path.abspath(resource_dir) + + def get_components(self): + """Retrieve all components declared in module catalogs of the resource""" + appliPath= self.get_appliPath() + userName = self.get_user() + hostname=self.get_host() + resource_dir=os.path.join(cata_dir,self.get_name()) + catalogs_list=glob.glob(os.path.join(resource_dir,"*Catalog.xml")) + + if hostname == "localhost" or hostname == get_hostname() and userName == os.getenv("USER"): + #user local resource + if appliPath[0]!='/': + appliPath=os.path.join(os.getenv("HOME"),appliPath) + if appliPath == appli_local: + #main local resource: get catalogs in share/salome/resources + catalogs_list=glob.glob(os.path.join(appliPath,"share","salome","resources","*","*Catalog.xml")) + catalogs_list=catalogs_list + glob.glob(os.path.join(appliPath,"share","salome","resources","*Catalog.xml")) + + for cata in catalogs_list: + moduleName= os.path.basename(cata)[:-11] + #Parse module catalog + doc = etree_.parse(cata) + rootNode = doc.getroot() + for componentName in rootNode.findall("component-list/component/component-name"): + self.components.append(Component(componentName.text,moduleName)) + + +def main(): + parser = optparse.OptionParser(usage=usage) + + options, args = parser.parse_args() + + if not os.path.exists(catalog_file_base): + print "ERROR: the base catalog file %s is mandatory" % catalog_file_base + sys.exit(1) + + #Parse CatalogResource.xml + doc = etree_.parse(catalog_file_base) + + rootNode = doc.getroot() + if rootNode.tag != "resources": + raise ParseError("First level tag must be resources not %s" % rootNode.tag) + + resources=[] + + #Extract resources + for child in rootNode: + if child.tag != "machine": + raise ParseError("Second level tag must be machine not %s" % child.tag) + resources.append(Resource(child)) + + # Remove remote_catalogs directory and create a new empty one + if os.path.exists(cata_dir): + if os.path.exists(cata_dir_bak): + shutil.rmtree(cata_dir_bak) + os.rename(cata_dir,cata_dir_bak) + + os.mkdir(cata_dir) + + #Get catalogs from remote resources and copy them in remote_catalogs + for mach in resources: + mach.get_catalogs() + + #Get the list of SALOME components that are defined in catalogs + for mach in resources: + mach.get_components() + + #Update the resource catalog dom object for further dump + for mach in resources: + mach.update() + + #dump new CatalogResources.xml + f=open(catalog_file,'w') + f.write('\n') + doc.write(f) + f.write('\n') + f.close() + print "%s updated" % catalog_file + + #update configRemote.sh in env.d directory (environment variable SALOME_CATALOGS_PATH) + path=[] + for mach in resources: + if mach.resource_dir: + path.append(mach.resource_dir) + + f=open(os.path.join(appli_local,"env.d","configRemote.sh"),'w') + f.write("export SALOME_CATALOGS_PATH=%s\n" % SEP.join(path)) + f.close() + + +if __name__ == '__main__': + main() + diff --git a/bin/envSalome.py b/bin/envSalome.py index 4ef0b8aaa..d4fb61bd7 100755 --- a/bin/envSalome.py +++ b/bin/envSalome.py @@ -29,19 +29,14 @@ import setenv kernel_root=os.getenv("KERNEL_ROOT_DIR") sys.path[:0]=[kernel_root+"/bin/salome"] -#import runSalome - argv = sys.argv[1:] sys.argv = argv[1:] -#sys.argv = [sys.argv[0]] -#if len(argv) > 3: -# sys.argv += argv[3:] -#if len(argv) > 2: -# sys.argv = argv[2:] - -#args, modules_list, modules_root_dir = setenv.get_config() -#runSalome.set_env(args, modules_list, modules_root_dir) +if argv[0] == "-exec": + #keep options only for execution + del argv[0] + sys.argv = [] + setenv.main(True); if sys.platform == "win32": diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index 4e1cbbd4f..38e0cf710 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -146,7 +146,12 @@ def killMyPort(port): fpid = open(filedict, 'r') # from salome_utils import generateFileName - fpidomniNames = generateFileName(os.path.join('/tmp/logs', os.getenv('USER')), + if sys.platform == "win32": + username = os.getenv( "USERNAME" ) + else: + username = os.getenv('USER') + path = os.path.join('/tmp/logs', username) + fpidomniNames = generateFileName(path, prefix="", suffix="Pid_omniNames", extension="log", diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 7fde55b79..07973f56b 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -59,6 +59,7 @@ test_nam = "test" play_nam = "play" gdb_session_nam = "gdb_session" ddd_session_nam = "ddd_session" +valgrind_session_nam = "valgrind_session" shutdown_servers_nam = "shutdown_servers" # values in XML configuration file giving specific module parameters ( section) @@ -638,6 +639,14 @@ def CreateOptionParser (theAdditionalOptions=[]): dest="ddd_session", default=False, help=help_str) + + # valgrind session + help_str = "Launch session with valgrind $VALGRIND_OPTIONS" + o_valgrind = optparse.Option("--valgrind-session", + action="store_true", + dest="valgrind_session", default=False, + help=help_str) + # shutdown-servers. Default: False. help_str = "1 to shutdown standalone servers when leaving python interpreter, " help_str += "0 to keep the standalone servers as daemon [default]. " @@ -675,6 +684,7 @@ def CreateOptionParser (theAdditionalOptions=[]): o_play, # Reproducing test script with help of TestRecorder o_gdb, o_ddd, + o_valgrind, o_shutdown, ] @@ -900,7 +910,10 @@ def get_env(theAdditionalOptions=[], appname="SalomeApp"): if cmd_opts.py_scripts is not None: listlist = cmd_opts.py_scripts for listi in listlist: - args[script_nam] += re.split( "[:;,]", listi) + if os.sys.platform == 'win32': + args[script_nam] += re.split( "[;,]", listi) + else: + args[script_nam] += re.split( "[:;,]", listi) for arg in cmd_args: if arg[-3:] == ".py": args[script_nam].append(arg) @@ -969,6 +982,10 @@ def get_env(theAdditionalOptions=[], appname="SalomeApp"): if cmd_opts.ddd_session is not None: args[ddd_session_nam] = cmd_opts.ddd_session + # valgrind session + if cmd_opts.valgrind_session is not None: + args[valgrind_session_nam] = cmd_opts.valgrind_session + # Shutdown servers if cmd_opts.shutdown_servers is None: args[shutdown_servers_nam] = 0 diff --git a/bin/runSalome.py b/bin/runSalome.py index d03a67d6e..75b3cff49 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -33,6 +33,11 @@ from server import * from launchConfigureParser import verbose from server import process_id +if sys.platform == "win32": + SEP = ";" +else: + SEP = ":" + # ----------------------------------------------------------------------------- from killSalome import killAllPorts @@ -87,8 +92,11 @@ def kill_salome(args): class InterpServer(Server): def __init__(self,args): self.args=args - env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")] - self.CMD=['xterm', '-e']+ env_ld_library_path + ['python'] + if sys.platform != "win32": + env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + os.getenv("LD_LIBRARY_PATH")] + self.CMD=['xterm', '-e']+ env_ld_library_path + ['python'] + else: + self.CMD=['cmd', '/c', 'start cmd.exe', '/K', 'python'] def run(self): global process_id @@ -104,13 +112,43 @@ class InterpServer(Server): # --- +def get_cata_path(list_modules,modules_root_dir): + """Build a list of catalog paths (cata_path) to initialize the ModuleCatalog server + """ + modules_cata={} + cata_path=[] + + for module in list_modules: + if modules_root_dir.has_key(module): + module_root_dir=modules_root_dir[module] + module_cata=module+"Catalog.xml" + cata_file=os.path.join(module_root_dir, "share",setenv.salome_subdir, "resources",module.lower(), module_cata) + + if os.path.exists(cata_file): + cata_path.append(cata_file) + modules_cata[module]=cata_file + else: + cata_file=os.path.join(module_root_dir, "share",setenv.salome_subdir, "resources", module_cata) + if os.path.exists(cata_file): + cata_path.append(cata_file) + modules_cata[module]=cata_file + + for path in os.getenv("SALOME_CATALOGS_PATH","").split(SEP): + if os.path.exists(path): + for cata_file in glob.glob(os.path.join(path,"*Catalog.xml")): + module_name= os.path.basename(cata_file)[:-11] + if not modules_cata.has_key(module_name): + cata_path.append(cata_file) + modules_cata[module_name]=cata_file + + return cata_path + + + class CatalogServer(Server): def __init__(self,args): self.args=args self.initArgs() - #if sys.platform == "win32": - # self.SCMD1=[os.environ["KERNEL_ROOT_DIR"] + "/win32/" + os.environ["BIN_ENV"] + "/" + 'SALOME_ModuleCatalog_Server' + ".exe",'-common'] - #else: self.SCMD1=['SALOME_ModuleCatalog_Server','-common'] self.SCMD2=[] home_dir=os.getenv('HOME') @@ -118,37 +156,16 @@ class CatalogServer(Server): self.SCMD2=['-personal',os.path.join(home_dir,'Salome/resources/CatalogModulePersonnel.xml')] def setpath(self,modules_list,modules_root_dir): - cata_path=[] list_modules = modules_list[:] list_modules.reverse() if self.args["gui"] : list_modules = ["KERNEL", "GUI"] + list_modules else : list_modules = ["KERNEL"] + list_modules - for module in list_modules: - if modules_root_dir.has_key(module): - module_root_dir=modules_root_dir[module] - module_cata=module+"Catalog.xml" - #print " ", module_cata - if os.path.exists(os.path.join(module_root_dir, - "share",setenv.salome_subdir, - "resources",module.lower(), - module_cata)): - cata_path.extend( - glob.glob(os.path.join(module_root_dir, - "share",setenv.salome_subdir, - "resources",module.lower(), - module_cata))) - else: - cata_path.extend( - glob.glob(os.path.join(module_root_dir, - "share",setenv.salome_subdir, - "resources", - module_cata))) - pass - pass - #self.CMD=self.SCMD1 + ['\"']+[string.join(cata_path,'\"::\"')] + ['\"'] + self.SCMD2 - self.CMD=self.SCMD1 + ['\"' + string.join(cata_path,'\"::\"') + '\"'] + self.SCMD2 + + cata_path=get_cata_path(list_modules,modules_root_dir) + + self.CMD=self.SCMD1 + ['"' + string.join(cata_path,'"::"') + '"'] + self.SCMD2 # --- @@ -271,35 +288,18 @@ class SessionServer(Server): self.SCMD2+=['--pyscript=%s'%(",".join(self.args['pyscript']))] def setpath(self,modules_list,modules_root_dir): - cata_path=[] list_modules = modules_list[:] list_modules.reverse() if self.args["gui"] : list_modules = ["KERNEL", "GUI"] + list_modules else : list_modules = ["KERNEL"] + list_modules - for module in list_modules: - module_root_dir=modules_root_dir[module] - module_cata=module+"Catalog.xml" - #print " ", module_cata - if os.path.exists(os.path.join(module_root_dir, - "share",setenv.salome_subdir, - "resources",module.lower(), - module_cata)): - cata_path.extend( - glob.glob(os.path.join(module_root_dir,"share", - setenv.salome_subdir,"resources", - module.lower(),module_cata))) - else: - cata_path.extend( - glob.glob(os.path.join(module_root_dir,"share", - setenv.salome_subdir,"resources", - module_cata))) - pass + + cata_path=get_cata_path(list_modules,modules_root_dir) + if (self.args["gui"]) & ('moduleCatalog' in self.args['embedded']): #Use '::' instead ":" because drive path with "D:\" is invalid on windows platform - #self.CMD=self.SCMD1 + ['\"']+[string.join(cata_path,'\"::\"')] + ['\"'] + self.SCMD2 - self.CMD=self.SCMD1 + ['\"' + string.join(cata_path,'\"::\"') + '\"'] + self.SCMD2 + self.CMD=self.SCMD1 + ['"' + string.join(cata_path,'"::"') + '"'] + self.SCMD2 else: self.CMD=self.SCMD1 + self.SCMD2 if self.args.has_key('test'): @@ -323,6 +323,15 @@ class SessionServer(Server): pass pass + if self.args["valgrind_session"]: + l = ["valgrind"] + val = os.getenv("VALGRIND_OPTIONS") + if val: + l += val.split() + pass + self.CMD = l + self.CMD + pass + # --- class LauncherServer(Server): @@ -343,35 +352,20 @@ class LauncherServer(Server): self.SCMD2+=['--with','SALOMEDS','(',')'] if 'cppContainer' in self.args['embedded']: self.SCMD2+=['--with','Container','(','FactoryServer',')'] - + def setpath(self,modules_list,modules_root_dir): - cata_path=[] list_modules = modules_list[:] list_modules.reverse() if self.args["gui"] : - list_modules = ["GUI"] + list_modules - for module in ["KERNEL"] + list_modules: - if modules_root_dir.has_key(module): - module_root_dir=modules_root_dir[module] - module_cata=module+"Catalog.xml" - #print " ", module_cata - if os.path.exists(os.path.join(module_root_dir, - "share",setenv.salome_subdir, - "resources",module.lower(), - module_cata)): - cata_path.extend( - glob.glob(os.path.join(module_root_dir,"share", - setenv.salome_subdir,"resources", - module.lower(),module_cata))) - else: - cata_path.extend( - glob.glob(os.path.join(module_root_dir,"share", - setenv.salome_subdir,"resources", - module_cata))) - pass - pass + list_modules = ["KERNEL", "GUI"] + list_modules + else : + list_modules = ["KERNEL"] + list_modules + + cata_path=get_cata_path(list_modules,modules_root_dir) + if (self.args["gui"]) & ('moduleCatalog' in self.args['embedded']): - self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2 + #Use '::' instead ":" because drive path with "D:\" is invalid on windows platform + self.CMD=self.SCMD1 + ['"' + string.join(cata_path,'"::"') + '"'] + self.SCMD2 else: self.CMD=self.SCMD1 + self.SCMD2 @@ -598,7 +592,10 @@ def startSalome(args, modules_list, modules_root_dir): # set PYTHONINSPECT variable (python interpreter in interactive mode) if args['pinter']: os.environ["PYTHONINSPECT"]="1" - import readline + try: + import readline + except ImportError: + pass return clt @@ -679,26 +676,47 @@ def useSalome(args, modules_list, modules_root_dir): if args.has_key('gui') and args.has_key('session_gui'): if not args['gui'] or not args['session_gui']: toimport = args['pyscript'] - i = 0 - while i < len( toimport ) : - if toimport[ i ] == 'killall': + + for srcname in toimport : + if srcname == 'killall': clt.showNS() killAllPorts() sys.exit(0) else: - scrname = toimport[ i ] - if len(scrname) > 2 and (len(scrname) - string.rfind(scrname, ".py") == 3): - print 'executing',scrname - sys.path.insert( 0, os.path.dirname(scrname)) - execfile(scrname,globals()) - del sys.path[0] + if os.path.isabs(srcname): + if os.path.exists(srcname): + execScript(srcname) + elif os.path.exists(srcname+".py"): + execScript(srcname+".py") + else: + print "Can't execute file %s" % srcname + pass else: - print 'importing',scrname - doimport = 'import ' + scrname - exec doimport - i = i + 1 - + found = False + for path in [os.getcwd()] + sys.path: + if os.path.exists(os.path.join(path,srcname)): + execScript(os.path.join(path,srcname)) + found = True + break + elif os.path.exists(os.path.join(path,srcname+".py")): + execScript(os.path.join(path,srcname+".py")) + found = True + break + pass + if not found: + print "Can't execute file %s" % srcname + pass + pass + pass + pass + pass return clt + +def execScript(script_path): + print 'executing', script_path + sys.path.insert(0, os.path.dirname(script_path)) + execfile(script_path,globals()) + del sys.path[0] # ----------------------------------------------------------------------------- diff --git a/bin/server.py b/bin/server.py index cb5451c62..47f061d89 100755 --- a/bin/server.py +++ b/bin/server.py @@ -38,7 +38,10 @@ class Server: self.CMD=[] self.ARGS=[] if self.args.get('xterm'): + if sys.platform != "win32": self.ARGS=['xterm', '-iconic', '-sb', '-sl', '500', '-hold'] + else: + self.ARGS=['cmd', '/c', 'start cmd.exe', '/K'] def __init__(self,args): self.args=args @@ -50,9 +53,10 @@ class Server: myargs=self.ARGS if self.args.get('xterm'): # (Debian) send LD_LIBRARY_PATH to children shells (xterm) - env_ld_library_path=['env', 'LD_LIBRARY_PATH=' - + os.getenv("LD_LIBRARY_PATH")] - myargs = myargs +['-T']+self.CMD[:1]+['-e'] + env_ld_library_path + if sys.platform != "win32": + env_ld_library_path=['env', 'LD_LIBRARY_PATH=' + + os.getenv("LD_LIBRARY_PATH")] + myargs = myargs +['-T']+self.CMD[:1]+['-e'] + env_ld_library_path command = myargs + self.CMD #print "command = ", command if sys.platform == "win32": diff --git a/bin/setenv.py b/bin/setenv.py index 493bd0b4f..59fa58528 100755 --- a/bin/setenv.py +++ b/bin/setenv.py @@ -194,6 +194,13 @@ def set_env(args, modules_list, modules_root_dir, silent=False): python_version,"site-packages", salome_subdir), "PYTHONPATH") + import platform + if platform.machine() == "x86_64": + add_path(os.path.join(module_root_dir,"lib64", + python_version,"site-packages", + salome_subdir), + "PYTHONPATH") + pass add_path(os.path.join(module_root_dir,get_lib_dir(), python_version,"site-packages", salome_subdir, diff --git a/bin/virtual_salome.py b/bin/virtual_salome.py index dfe2d5948..f20685a43 100644 --- a/bin/virtual_salome.py +++ b/bin/virtual_salome.py @@ -205,9 +205,17 @@ def link_module(options): if not os.path.exists(module_lib_py_dir): print "Python directory %s does not exist" % module_lib_py_dir else: + # __GBO__ specific action for the package salome + module_lib_pypkg_dir=os.path.join(module_lib_py_dir,"salome") + lib_pypkg_dir=os.path.join(lib_py_dir,"salome") + mkdir(lib_pypkg_dir) + # __GBO__ mkdir(lib_py_shared_dir) for fn in os.listdir(module_lib_py_dir): if fn == "shared_modules": continue + # __GBO__ + if fn == "salome": continue + # __GBO__ symlink(os.path.join(module_lib_py_dir, fn), os.path.join(lib_py_dir, fn)) pass if os.path.exists(module_lib_py_shared_dir): @@ -215,6 +223,13 @@ def link_module(options): symlink(os.path.join(module_lib_py_shared_dir, fn), os.path.join(lib_py_shared_dir, fn)) pass pass + # __GBO__ + if os.path.exists(module_lib_pypkg_dir): + for fn in os.listdir(module_lib_pypkg_dir): + symlink(os.path.join(module_lib_pypkg_dir, fn), os.path.join(lib_pypkg_dir, fn)) + pass + pass + # __GBO__ else: if verbose: print module_lib_py_shared_dir, " doesn't exist" diff --git a/configure.ac b/configure.ac index 744fc4915..d0a11fc2e 100644 --- a/configure.ac +++ b/configure.ac @@ -25,7 +25,7 @@ # ================================================================ #AC_PREREQ(2.59) # -AC_INIT([Salome2 Project], [6.1.0], [paul.rascle@edf.fr], [SalomeKERNEL]) +AC_INIT([Salome2 Project], [6.2.0], [paul.rascle@edf.fr], [SalomeKERNEL]) # AC_CONFIG_AUX_DIR defines an alternative directory where to find the auxiliary # scripts such as config.guess, install-sh, ... @@ -134,6 +134,14 @@ AC_ENABLE_DEBUG(no) AC_ENABLE_PRODUCTION(no) AC_ENABLE_MPI_SEQ_CONTAINER(no) +# _GBO_SALOME_PYTHON_PACKAGING_ +if test "X$enable_debug" = "Xyes"; then + PYLOGLEVEL=DEBUG +else + PYLOGLEVEL=WARNING +fi +AC_SUBST(PYLOGLEVEL) + echo echo --------------------------------------------- echo testing libtool @@ -171,8 +179,6 @@ AC_CHECK_LIB(rt,nanosleep) dnl add library libm : AC_CHECK_LIB(m,ceil) -# _CS_gbo We should add all dependent libraries - AC_CXX_USE_STD_IOSTREAM AC_CXX_HAVE_SSTREAM @@ -210,8 +216,9 @@ echo testing swig echo --------------------------------------------- echo -dnl _CS_gbo We should use here a variable given from the CHECK_PYTHON -AM_PATH_PYTHON(2.3) +# _GBO_ This definition is required. Without this definition, the pythondir +# would not be defined. The version doesn't matter. +AM_PATH_PYTHON(2.4) CHECK_SWIG echo @@ -384,6 +391,13 @@ CHECK_HTML_GENERATORS # Additional conditional to avoid compilation of non-portable code AM_CONDITIONAL(WINDOWS, [ test ]) +echo +echo --------------------------------------------- +echo testing sphinx +echo --------------------------------------------- +echo +CHECK_SPHINX + echo echo ============================================================ echo Summary @@ -464,7 +478,7 @@ if test x$libbatch_ok = xno; then echo fi -htmldoc_products="doxygen_ok graphviz_ok rst2html_ok" +htmldoc_products="doxygen_ok graphviz_ok rst2html_ok sphinx_ok" echo --- Html documentation products: only required for doc production summary $htmldoc_products @@ -499,6 +513,19 @@ echo generating Makefiles and configure files echo --------------------------------------------- echo +AC_CONFIG_COMMANDS([hack_libtool],[ +sed -i "s%^CC=\"\(.*\)\"%hack_libtool (){ \n\ + if test \"\$(echo \$[@] | grep -E '\\\-L/usr/lib(/../lib)?(64)? ')\" == \"\" \n\ + then\n\ + cmd=\"\1 \$[@]\"\n\ + else\n\ + cmd=\"\1 \"\`echo \$[@] | sed -r -e 's|(.*)-L/usr/lib(/../lib)?(64)? (.*)|\\\1\\\4 -L/usr/lib\\\3|g'\`\n\ + fi\n\ + \$cmd\n\ +}\n\ +CC=\"hack_libtool\"%g" libtool +],[]) + # This list is initiated using autoscan and must be updated manually # when adding a new file .in to manage. When you execute # autoscan, the Makefile list is generated in the output file configure.scan. @@ -521,6 +548,7 @@ AC_OUTPUT([ \ doc/salome/gui/Makefile \ doc/salome/gui/doxyfile \ doc/salome/gui/static/header.html \ + doc/docutils/Makefile \ idl/Makefile \ idl/Calcium_Ports.idl \ resources/Makefile \ @@ -549,6 +577,8 @@ AC_OUTPUT([ \ src/GenericObj/Makefile \ src/HDFPersist/Makefile \ src/KERNEL_PY/Makefile \ + src/KERNEL_PY/kernel/Makefile \ + src/KERNEL_PY/kernel/logconfig.py \ src/Launcher/Makefile \ src/LifeCycleCORBA/Makefile \ src/LifeCycleCORBA/Test/Makefile \ @@ -582,4 +612,3 @@ AC_OUTPUT([ \ src/Utils/Makefile \ src/Utils/Test/Makefile \ ]) - diff --git a/doc/Makefile.am b/doc/Makefile.am index fbcc8b5ed..6946e7718 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -23,11 +23,13 @@ # -* Makefile *- # Author : Paul RASCLE (EDF) # Date : 06/02/2006 -# $Header$ # + include $(top_srcdir)/salome_adm/unix/make_common_starter.am -SUBDIRS = salome +SUBDIRS = salome docutils + +EXTRA_DIST = configuration_examples docs: usr_docs @@ -36,7 +38,3 @@ usr_docs: dev_docs: (cd salome && $(MAKE) $(AM_MAKEFLAGS) dev_docs) - -dist-hook: - cp -Rp $(srcdir)/configuration_examples $(distdir) - rm -rf $(distdir)/configuration_examples/CVS diff --git a/doc/docutils/Makefile.am b/doc/docutils/Makefile.am new file mode 100644 index 000000000..5db2edb5a --- /dev/null +++ b/doc/docutils/Makefile.am @@ -0,0 +1,94 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com + +include $(top_srcdir)/salome_adm/unix/make_common_starter.am + +pydocdir = $(docdir)/tui/KERNEL/docutils + +.PHONY : latex + +if SPHINX_IS_OK + +html/index.html:$(RSTFILES) + make htm + +endif + +EXTRA_DIST = archives + +SPHINXOPTS = +SOURCEDIR = $(srcdir) +SPHINXBUILD = sphinx-build +PAPEROPT_a4 = -D latex_paper_size=a4 +ALLSPHINXOPTS = -d doctrees $(PAPEROPT_a4) $(SPHINXOPTS) $(SOURCEDIR) + +SPHINX_PYTHONPATH = $(prefix)/lib/python$(PYTHON_VERSION)/site-packages/salome:$(prefix)/lib64/python$(PYTHON_VERSION)/site-packages/salome:$(prefix)/bin/salome:$(OMNIORB_ROOT)/lib/python$(PYTHON_VERSION)/site-packages:$(OMNIORB_ROOT)/lib64/python$(PYTHON_VERSION)/site-packages + +SPHINX_LD_LIBRARY_PATH = $(OMNIORB_ROOT)/lib + +htm: + mkdir -p html doctrees + PYTHONPATH=$(SPHINX_PYTHONPATH):${PYTHONPATH}; \ + LD_LIBRARY_PATH=$(SPHINX_LD_LIBRARY_PATH):${LD_LIBRARY_PATH}; \ + $(SPHINXBUILD) -W -b html $(ALLSPHINXOPTS) html + @echo + @echo "Build finished. The HTML pages are in html." + +latex: + mkdir -p latex doctrees + PYTHONPATH=$(SPHINX_PYTHONPATH):${PYTHONPATH}; \ + LD_LIBRARY_PATH=$(SPHINX_LD_LIBRARY_PATH):${LD_LIBRARY_PATH}; \ + $(SPHINXBUILD) -W -b latex $(ALLSPHINXOPTS) latex + @echo + @echo "Build finished; the LaTeX files are in latex." + @echo "Run \`make all-pdf' or \`make all-ps' in that directory to" \ + "run these through (pdf)latex." + +html: + mkdir -p $@ + +RSTFILES= \ + index.rst \ + overview.rst \ + docapi.rst \ + salomepypkg.rst + +EXTRA_DIST+= $(RSTFILES) + +EXTRA_DIST+= \ + conf.py + +install-data-local: html/index.html + test -z $(pydocdir) || mkdir -p $(DESTDIR)$(pydocdir) + if test -d "html"; then b=; else b="$(srcdir)/"; fi; \ + cp -rf $$b"html"/* $(pydocdir) ; \ + if test -f $$b"latex"/kernelpy.pdf; then cp -f $$b"latex"/kernelpy.pdf $(pydocdir) ; fi; + +uninstall-local: + -test -d $(pydocdir) && chmod -R +w $(pydocdir) && rm -rf $(pydocdir)/* + +clean-local: + -rm -rf html latex doctrees + if test -d "html"; then rm -rf html ; fi + +disthook : + -test -d html && cp -Rp html $(distdir) diff --git a/doc/INSTALL.txt b/doc/docutils/archives/INSTALL.txt similarity index 100% rename from doc/INSTALL.txt rename to doc/docutils/archives/INSTALL.txt diff --git a/doc/KERNEL_Services.txt b/doc/docutils/archives/KERNEL_Services.txt similarity index 100% rename from doc/KERNEL_Services.txt rename to doc/docutils/archives/KERNEL_Services.txt diff --git a/doc/SALOME_Application.txt b/doc/docutils/archives/SALOME_Application.txt similarity index 100% rename from doc/SALOME_Application.txt rename to doc/docutils/archives/SALOME_Application.txt diff --git a/doc/UnitTests.txt b/doc/docutils/archives/UnitTests.txt similarity index 100% rename from doc/UnitTests.txt rename to doc/docutils/archives/UnitTests.txt diff --git a/doc/index.txt b/doc/docutils/archives/index.txt similarity index 100% rename from doc/index.txt rename to doc/docutils/archives/index.txt diff --git a/doc/kernel_resources.txt b/doc/docutils/archives/kernel_resources.txt similarity index 100% rename from doc/kernel_resources.txt rename to doc/docutils/archives/kernel_resources.txt diff --git a/doc/rst.css b/doc/docutils/archives/rst.css similarity index 100% rename from doc/rst.css rename to doc/docutils/archives/rst.css diff --git a/doc/txt2html.sh b/doc/docutils/archives/txt2html.sh similarity index 100% rename from doc/txt2html.sh rename to doc/docutils/archives/txt2html.sh diff --git a/doc/userguide.txt b/doc/docutils/archives/userguide.txt similarity index 100% rename from doc/userguide.txt rename to doc/docutils/archives/userguide.txt diff --git a/doc/docutils/conf.py b/doc/docutils/conf.py new file mode 100644 index 000000000..a193dd95e --- /dev/null +++ b/doc/docutils/conf.py @@ -0,0 +1,200 @@ +# -*- coding: iso-8859-1 -*- +# +# yacs documentation build configuration file, created by +# sphinx-quickstart on Fri Aug 29 09:57:25 2008. +# +# This file is execfile()d with the current directory set to its containing dir. +# +# The contents of this file are pickled, so don't put values in the namespace +# that aren't pickleable (module imports are okay, they're removed automatically). +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys, os + +# If your extensions are in another directory, add it here. If the directory +# is relative to the documentation root, use os.path.abspath to make it +# absolute, like shown here. +#sys.path.append(os.path.abspath('.')) + +# General configuration +# --------------------- + +# Add any Sphinx extension module names here, as strings. They can be extensions +# coming with Sphinx (named 'sphinx.ext.*') or your custom ones. +extensions = ['sphinx.ext.autodoc'] + +# Uncomment the following line to build the links with Python documentation +# (you might need to set http_proxy environment variable for this to work) +#extensions += ['sphinx.ext.intersphinx'] + +# Intersphinx mapping to add links to modules and objects in the Python +# standard library documentation +intersphinx_mapping = {'http://docs.python.org': None} + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# The suffix of source filenames. +source_suffix = '.rst' + +# The encoding of source files. +source_encoding = 'utf-8' + +# The master toctree document. +master_doc = 'index' + +# General information about the project. +project = 'KERNEL python packages' +copyright = '2010 EDF R&D' + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. +# +# The short X.Y version. +version = '5.1.4' +# The full version, including alpha/beta/rc tags. +release = '5.1.4' + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +language = 'en' + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +#today = '' +# Else, today_fmt is used as the format for a strftime call. +#today_fmt = '%B %d, %Y' + +# List of documents that shouldn't be included in the build. +#unused_docs = [] + +# List of directories, relative to source directory, that shouldn't be searched +# for source files. +exclude_trees = ['.build','ref','images','CVS','.svn'] + +# The reST default role (used for this markup: `text`) to use for all documents. +#default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +#add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +#add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +#show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = 'sphinx' + + +# Options for HTML output +# ----------------------- + +# The theme to use for HTML and HTML Help pages. Major themes that come with +# Sphinx are currently 'default' and 'sphinxdoc'. +html_theme = 'default' +#html_theme = 'nature' +#html_theme = 'agogo' +#html_theme = 'sphinxdoc' +#html_theme = 'omadoc' + +# Add any paths that contain custom themes here, relative to this directory. +#html_theme_path = ['themes'] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +#html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +#html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +#html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +#html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +#html_static_path = ['_static'] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +#html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +#html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +#html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +#html_additional_pages = {} + +# If false, no module index is generated. +html_use_modindex = False + +# If false, no index is generated. +#html_use_index = True + +# If true, the index is split into individual pages for each letter. +#html_split_index = False + +# If true, the reST sources are included in the HTML build as _sources/. +html_copy_source = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +#html_use_opensearch = '' + +# If nonempty, this is the file name suffix for HTML files (e.g. ".xhtml"). +#html_file_suffix = '' + +# Output file base name for HTML help builder. +htmlhelp_basename = 'kernelpydoc' + + +# Options for LaTeX output +# ------------------------ + +# The paper size ('letter' or 'a4'). +latex_paper_size = 'a4' + +# The font size ('10pt', '11pt' or '12pt'). +latex_font_size = '10pt' + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, author, document class [howto/manual]). +latex_documents = [ + ('index', 'kernelpy.tex', 'Documentation of the KERNEL python packages', 'EDF R\&D', 'manual') +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +latex_logo = '../salome/tui/images/head.png' + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +#latex_use_parts = True + +# Additional stuff for the LaTeX preamble. +#latex_preamble = '' + +# Documents to append as an appendix to all manuals. +#latex_appendices = [] + +# If false, no module index is generated. +latex_use_modindex = False diff --git a/doc/docutils/docapi.rst b/doc/docutils/docapi.rst new file mode 100644 index 000000000..9634eb428 --- /dev/null +++ b/doc/docutils/docapi.rst @@ -0,0 +1,46 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + Documentation of the programming interface (API) +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +This section describes the python modules of the +``salome.kernel`` python package. The main part is generated from the +code documentation included in source python files. + +:mod:`salome.kernel` -- Package containing the KERNEL python utilities +====================================================================== + +:mod:`deprecation` -- Indication of deprecated modules and functions +-------------------------------------------------------------------- + +.. automodule:: salome.kernel.deprecation + :members: + + +:mod:`termcolor` -- Display colored text in terminal +---------------------------------------------------- + +.. automodule:: salome.kernel.termcolor + :members: + :exclude-members: TEST_termcolor + + +:mod:`logger` -- Logging utility +-------------------------------- + +.. automodule:: salome.kernel.logger + +.. autoclass:: Logger + :members: + :show-inheritance: + +.. autoclass:: ExtLogger + :members: + :show-inheritance: + + +:mod:`studyedit` -- Study editor +-------------------------------- + +.. automodule:: salome.kernel.studyedit + :members: diff --git a/doc/docutils/index.rst b/doc/docutils/index.rst new file mode 100644 index 000000000..a0b8c3a32 --- /dev/null +++ b/doc/docutils/index.rst @@ -0,0 +1,22 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + Documentation of the KERNEL python packages +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +Main documentation +================== + +.. toctree:: + :maxdepth: 3 + + overview.rst + docapi.rst + + +Additional documentation +======================== + +.. toctree:: + :maxdepth: 3 + + salomepypkg.rst diff --git a/doc/docutils/overview.rst b/doc/docutils/overview.rst new file mode 100644 index 000000000..950792907 --- /dev/null +++ b/doc/docutils/overview.rst @@ -0,0 +1,47 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +General presentation of the KERNEL python package +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +The KERNEL python package essentially contains: + +* Helper functions to manipulate KERNEL objects from python. For + example, the ``studyedit.py`` module facilitates the + manipulation of components and items in SALOME study. +* General purpose functions for logging and other recurrent + stuff in python programming. + +Note that these functions either encapsulate the python programming +interface of KERNEL core (the CORBA or SWIG interfaces for example) or +extend existing utilities as the ``salome*.py`` modules. + +The functions are distributed in the python package +``salome.kernel``. For example, the usage of the study editor to +manipulate some objects can be done with a set of instructions as: + +.. code-block:: python + + from salome.kernel.studyedit import getStudyEditor + + studyEditor = getStudyEditor() # Get an editor for the current study + + myStudyComponent = studyEditor.findOrCreateComponent( + moduleName, + componentName, + componentIcon) + + myStudyItem = studyEditor.createItem( + myStudyComponent, + itemName, + comment = itemComment, + icon = itemIcon) + +The specification of the programming interface of this package is +detailed in the part :doc:`Documentation of the programming interface +(API)` of this documentation. + +.. note:: + The main package ``salome`` contains other sub-packages that are + distributed with the other SALOME modules. For example, the GEOM + module provides the python package ``salome.geom`` and SMESH the + package ``salome.smesh``. diff --git a/doc/docutils/salomepypkg.rst b/doc/docutils/salomepypkg.rst new file mode 100644 index 000000000..c46063eb2 --- /dev/null +++ b/doc/docutils/salomepypkg.rst @@ -0,0 +1,270 @@ + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +Complement A: Organizing the SALOME python functions in a packaged structure +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +This chapter contains the instruction notes to organise the python +files of SALOME in a packaged python structure. This is the first step +of the development process, whose goal is to validate the principles +and show a possible way. + +:Contacts: Guillaume Boulant, Christian Caremoli, Renaud Barate + +Objectives +========== + +The main idea is to import SALOME python functions by doing: + +.. code-block:: python + + from salome.kernel. import + +instead of: + +.. code-block:: python + + from import + +as it must be done up to now because of the flat organisation of +python files in the installation folders of SALOME modules. + +To reach this target, the files ``.py`` have to be +organised in a packaged python structure where the main package is +named ``salome``, and then sub-packages could be created for each +SALOME module: + +* ``salome.kernel``: for kernel python functions, embedded in the + KERNEL module +* ``salome.gui``: for gui python functions, embedded in the GUI module +* ``salome.geom``: for geom python functions, embedded in the GEOM + module +* and so on ... + +The motivations of this objective are twice: + +* Definitively prevent the risk of naming conflict between python + modules coming from different SALOME modules. Today, the developper + of a module has to take care of the names used in other modules to + choose a name. +* Integrate in SALOME some python modules initialy developed in the + context of domain specific SALOME applications (SALOME-MECA, + SALOME-CFD, OPENTURN, PANTHERE) and whose source files are organized + in a packaged python structure. + +The starting point then is a python library named ``nepal`` that +provides SALOME helper functions classified by modules +(KERNEL,GEOM,...) and organized in a packaged python structure: + +* ``salome.kernel``: helper functions for manipulating the SALOME + study and its components (SComponents and SObject). This provides + also general purpose utilities for logging and threading. +* ``salome.gui``: helper functions to manipulate the graphical + representation of studies and the general behavior of the graphical + interface. This provides also generic templates for implementing + dialog box with the MVC pattern. +* ``salome.geom``: essentially contains a function called + "visualization of structural elements". This is used by mechanical + ingeneers to create the 3D geometrical object corresponding to the + numerical model of a given structural element. +* ``salome.smesh``: to manipulated smesh data handled from the SObject + in the SALOME study. + +The target point is to have the ``salome.kernel`` part in the KERNEL +module, the ``salome.geom`` part in the GEOM module, and so on. And +with **no impact on SALOME scripts** that already exists (import salome, +and all other stuff should be imported and work as before). + + +Problems +======== + +To reach this target, we have to face two problems: + +* A naming conflict with the instruction ``import salome``. The result + is unpredictible because of the existance in the ``sys.path`` of + both a file ``salome.py`` and a package ``salome``. +* The dispatching of ``salome.*`` sub-packages in the different SALOME + modules. + +Naming conflict between ``salome.py`` module and ``salome`` package +------------------------------------------------------------------- + +The problem is solved by installing the ``salome.py`` file under the +name ``__init__.py`` in a folder named ``${salomepythondir}/salome``. + +By this operation, the ``${salomepythondir}/salome`` directory is +transformed in a python package and the instruction ``import salome`` +do the same things as before this modification, without any +modification of the ``sys.path``. + +Dispatching of ``salome.*`` sub-packages in different SALOME modules +-------------------------------------------------------------------- + +When we use a SALOME virtual application, the problem is naturally +solved by the fact that every sub-packages are virtually installed in +the same directory, the directory ``${salomepythondir}/salome`` +containing the file ``__init__.py``. + +Nevertheless, some people doesn't use the virtual application. To get +a robust configuration in any case, one can use the python namespace +pattern. This consists in creating a virtual python package that +aggregates all the sub-packages. + +Technically speaking, this consists in implementing in the file +``${salomepythondir}/salome/__init__.py`` (new version of +``salome.py``) a function that automatically extend the ``__path__`` +variable with sub-packages that can be found in SALOME modules +installation paths. The code looks something like that: + +.. code-block:: python + + import os, sys + + MATCH_ENDING_PATTERN="site-packages/salome" + + def extend_path(pname): + for dir in sys.path: + if not isinstance(dir, basestring) or not os.path.isdir(dir) or not dir.endswith(MATCH_ENDING_PATTERN): + continue + subdir = os.path.join(dir, pname) + # WARN: This may still add duplicate entries to path on + # case-insensitive filesystems + if os.path.isdir(subdir) and subdir not in __path__: + print "INFO - The directory %s is appended to sys.path" % subdir + __path__.append(subdir) + + extend_path(ROOT_PYTHONPACKAGE_NAME) + + +Adaptation of the ``apply_gen`` utility +---------------------------------------- + +Due to the specific above choices, the ``apply_gen`` utility must be +modified so that the sub-folder ``salome`` in ``${salomepythondir}`` +is not generated as a symbolic link any longer but as a real folder +containing symbolic links towards the module specific python +sub-packages (``kernel``, ``geom``, ``smesh``, ...) and to the single +file ``__init__.py`` provided by the KERNEL module. + +This adaptation can be done in the ``virtual_salome.py`` script. + + +What to do with already existing python files? +---------------------------------------------- + +Do nothing at this step, it works fine because the files are installed +in a path included in the ``sys.path``. + +In a future version, it should be nice to reverse all the python files +of the KERNEL library in this packaged structure. But this can't be +done without impact on existing python user scripts. + +Instructions +============ + +Instructions for creating the python packages +--------------------------------------------- + +Considering the elements described above, a procedure that works to +get the packaged python structure is: + +* Rename the file ``salome.py`` in ``__init__.py`` (and adapt the + Makefile.am). This is located in the source directory + ``src/KERNEL_PY``. +* Copy the sources files of the kernel part in the source directory + ``src/KERNEL_PY`` starting with a stage named ``kernel`` including + its own packaged structure (only python files and a file + ``__init__.py`` for now) +* Copy the sources files of the geom part in the source directory + ``src/GEOM_PY`` (to be created) of the GEOM module. In this case, we + copy the python files directly in the directory (no stage named + ``geom``, it's not required for source organisation, and will be + created only for installation by makefile). +* Apply the same procedure for every other SALOME modules (it concerns + only SMESH up to now). +* Apply the "namespace pattern" by implementing and invoking the + ``extend_path`` function in the newly created file ``__init__.py`` +* Adapt the ``apply_gen`` utility to take into account the finer + folder hierarchy in ``site-packages``. + +The naming convention for source folder is here the convention in +place in the KERNEL module: the source code of the python packages of +a SALOME module is located in the source directory +``/src/_PY``. + +Note also that all python files that were existing in the KERNEL +module are leaft untouched but the file ``salome.py``. + +Instructions for the associated documentation +--------------------------------------------- + +One special point for the documentation: + +* The documentation of the python package API is writen in rst + (restructured text) and generated form the source code with sphinx. +* The rst source files are located in the directory + ``/doc/docutils``. +* The html generated files are installed in the directory + ``/share/doc/salome/docutils`` but are not connected to + the in-line documentation of the SALOME associated module (menu help + of the SALOME application). + +Any suggestion on this point would be appreciated. + +TODO (by someone): + +* Move all files ``*.txt`` from the ``/doc`` folder to the + ``/doc/docutils`` folder and analyse what is still to date + and usefull. +* Integrate in this part the reference documentation of the ``salome`` + utility and all documentation associated to the launching process + (in particular virtual application) +* Connect this part of the documentation to the main part (doxygen + part). + + +Synthesis +--------- + +Finaly, here is a synthesis of modifications in source files. + +Files modified: + +* See the CVS patch files KERNEL.patch, GEOM.patch and SMESH.patch + (the only SALOME modules modified today). + +Files to be added: + +* KERNEL: file ``src/KERNEL_PY/__init__.py`` (``salome.py`` renamed) +* KERNEL: directory ``src/KERNEL_PY/kernel`` +* KERNEL: directory ``doc/docutils`` +* KERNEL: file ``salome_adm/unix/config_files/check_sphinx.m4`` +* GEOM : directory ``src/GEOM_PY`` +* GEOM : directory ``doc/docutils`` +* SMESH : directory ``src/SMESH_PY`` +* SMESH : directory ``doc/docutils`` + +Files to be delete: + +* file ``src/KERNEL_PY/salome.py`` + + +Tests and usage +=============== + +The instructions above provides you with a SALOME application whose +modules embed there dedicated python packages. This installation can +can be tested using some test use cases. For example, the +visualisation of structural elements (provided by the package +``salome.geom`` can be tested by: + +.. code-block:: python + + from salome.geom.structelem import TEST_StructuralElement + TEST_StructuralElement() + +This can be enter in the GUI python console or in a python interpreter +executed in a SALOME session. + +For more details, read the API documentation in +``/share/doc/salome/docutils``. diff --git a/doc/salome/gui/doxyfile.in b/doc/salome/gui/doxyfile.in index e44cb36de..982691a60 100644 --- a/doc/salome/gui/doxyfile.in +++ b/doc/salome/gui/doxyfile.in @@ -249,4 +249,4 @@ DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- -SEARCHENGINE = NO +SEARCHENGINE = YES diff --git a/doc/salome/kernelpypkg.dox b/doc/salome/kernelpypkg.dox new file mode 100644 index 000000000..0b38f0445 --- /dev/null +++ b/doc/salome/kernelpypkg.dox @@ -0,0 +1,14 @@ +/*! + +\page kernelpypkg_page Programming Interface of the KERNEL python package + +Sorry, but the documentation is not available yet in doxygen format. + +Fortunately, a documentation exists in restructured format and then +can be generated here using sphinx, in the expectative of the doxygen +version. + +Please refer to this +documentation of the KERNEL python packages. + +*/ diff --git a/doc/salome/main.dox b/doc/salome/main.dox index 34311ed4f..34774389d 100644 --- a/doc/salome/main.dox +++ b/doc/salome/main.dox @@ -55,6 +55,7 @@ - \subpage kernel_salome - \subpage dsc_page : DSC documentation page. - \subpage salome_file_page : Salome_file documentation page. + - \subpage kernelpypkg_page : Documentation of the KERNEL python packages */ diff --git a/idl/Makefile.am b/idl/Makefile.am index 6ab7e6076..f6ecf89b1 100644 --- a/idl/Makefile.am +++ b/idl/Makefile.am @@ -42,6 +42,7 @@ BASEIDL_FILES = \ SALOME_Registry.idl \ Logger.idl \ SALOME_GenericObj.idl \ + SALOME_Types.idl \ SALOME_Session.idl \ SALOME_TestModuleCatalog.idl \ nstest.idl \ @@ -50,7 +51,8 @@ BASEIDL_FILES = \ SALOME_PyNode.idl \ Palm_Ports.idl \ SALOME_PACOExtension.idl \ - SALOME_ParamPorts.idl + SALOME_ParamPorts.idl \ + SALOME_Parametric.idl MPIIDL_FILES = \ SALOME_MPIObject.idl \ @@ -92,6 +94,7 @@ BASEIDL_SOURCES =\ SALOME_RegistrySK.cc \ LoggerSK.cc \ SALOME_GenericObjSK.cc \ + SALOME_TypesSK.cc \ SALOME_SessionSK.cc \ SALOME_TestModuleCatalogSK.cc \ nstestSK.cc \ @@ -101,15 +104,17 @@ BASEIDL_SOURCES =\ Calcium_PortsSK.cc \ Palm_PortsSK.cc \ SALOME_PACOExtensionSK.cc \ - SALOME_ParamPortsSK.cc + SALOME_ParamPortsSK.cc \ + SALOME_ParametricSK.cc DYNIDL_SRCS = \ SALOME_PortsDynSK.cc Calcium_PortsDynSK.cc SALOME_ContainerManagerDynSK.cc \ SALOME_CommDynSK.cc SALOME_RegistryDynSK.cc SALOME_ModuleCatalogDynSK.cc \ SALOMEDSDynSK.cc SALOME_SessionDynSK.cc SALOME_RessourcesCatalogDynSK.cc \ - DSC_EnginesDynSK.cc SALOME_ComponentDynSK.cc SALOME_GenericObjDynSK.cc \ + DSC_EnginesDynSK.cc SALOME_ComponentDynSK.cc SALOME_GenericObjDynSK.cc SALOME_TypesDynSK.cc \ Palm_PortsDynSK.cc SALOME_ExceptionDynSK.cc SALOMEDS_AttributesDynSK.cc \ - LoggerDynSK.cc SALOME_PACOExtensionDynSK.cc SALOME_ParamPortsDynSK.cc SALOME_PyNodeDynSK.cc + LoggerDynSK.cc SALOME_PACOExtensionDynSK.cc SALOME_ParamPortsDynSK.cc SALOME_PyNodeDynSK.cc \ + SALOME_ParametricDynSK.cc MPIIDL_SOURCES = \ SALOME_MPIObjectSK.cc \ diff --git a/idl/SALOMEDS_Attributes.idl b/idl/SALOMEDS_Attributes.idl index 39130e2c3..bd40d4277 100644 --- a/idl/SALOMEDS_Attributes.idl +++ b/idl/SALOMEDS_Attributes.idl @@ -238,8 +238,14 @@ module SALOMEDS /*! \brief Comment attribute - The attribute stores a string value containing supplementary information about - the SObject. In particular it contains the data type of the %SComponent. + The attribute stores arbitrary string value containing supplementary information about + the SObject. This is common-usage attribute that can be used for any purpose. + + There is only one explicit limitation: for the SComponent %object representing + the root item of the SALOME component tree, the AttributeComment is used to store + component data type value. This attribute is automatically set with NewComponent() + function of StudyBuilder. Also, the value of this attribute is returned by the + ComponentDataType() function of SComponent interface. See \ref example6 for an example of this attribute usage in batchmode of %SALOME application. diff --git a/idl/SALOME_ContainerManager.idl b/idl/SALOME_ContainerManager.idl index 69e10274c..6b44687ab 100644 --- a/idl/SALOME_ContainerManager.idl +++ b/idl/SALOME_ContainerManager.idl @@ -240,7 +240,7 @@ interface ContainerManager //! GiveContainer - use mode parameter of ContainerParameters to configure //! how this method works //! Currently: get, start, getorstart, findorstart, find - Container GiveContainer(in ContainerParameters params); + Container GiveContainer(in ContainerParameters params) raises (SALOME::SALOME_Exception); //! Shutdown all containers that have been launched by the container manager void ShutdownContainers(); diff --git a/idl/SALOME_Parametric.idl b/idl/SALOME_Parametric.idl new file mode 100644 index 000000000..093fcfc3c --- /dev/null +++ b/idl/SALOME_Parametric.idl @@ -0,0 +1,82 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +// File : SALOME_Parametric.idl +// Author : Renaud BARATE, EDF R&D +// + +#ifndef _SALOME_Parametric_IDL_ +#define _SALOME_Parametric_IDL_ + +/*! \brief + This module contains type definitions for the communication between + supervision codes and computation codes in parametric studies. +*/ +module SALOME_TYPES +{ +/*! \brief Structure describing a parameter that can be used for specific + information exchange between the codes. +*/ + struct Parameter { + string name; + string value; + }; + +/*! \brief List of parameters. +*/ + typedef sequence ParameterList; + +/*! \brief Type representing the value of a variable exchanged between the + codes. As the variables may be matrices, a value is a 2D object + represented as a sequence of sequences of real numbers. +*/ + typedef sequence > Value; + +/*! \brief List of variable names. +*/ + typedef sequence VarList; + +/*! \brief List of variable values. +*/ + typedef sequence ValueList; + +/*! \brief Structure describing the input of a computation code. +*/ + struct ParametricInput { + VarList inputVarList; + VarList outputVarList; + ValueList inputValues; + ParameterList specificParameters; + }; + +/*! \brief Structure describing the output of a computation code. +*/ + struct ParametricOutput { + ValueList outputValues; + ParameterList specificOutputInfos; + long returnCode; + string errorMessage; + }; + +}; + +#endif diff --git a/idl/SALOME_Types.idl b/idl/SALOME_Types.idl new file mode 100644 index 000000000..c0b8a05ac --- /dev/null +++ b/idl/SALOME_Types.idl @@ -0,0 +1,31 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// + +#ifndef __SALOME_TYPES_IDL__ +#define __SALOME_TYPES_IDL__ + +module SALOME_TYPES +{ + typedef sequence ListOfLong; + typedef sequence ListOfDouble; + typedef sequence ListOfString; + typedef sequence ListOfDouble2; +}; + +#endif diff --git a/resources/KERNELCatalog.xml.in b/resources/KERNELCatalog.xml.in index c60881e17..4a7f33661 100644 --- a/resources/KERNELCatalog.xml.in +++ b/resources/KERNELCatalog.xml.in @@ -41,6 +41,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/salome_adm/cmake_files/FindKERNEL.cmake b/salome_adm/cmake_files/FindKERNEL.cmake index ebbf458ee..5ad2994fa 100644 --- a/salome_adm/cmake_files/FindKERNEL.cmake +++ b/salome_adm/cmake_files/FindKERNEL.cmake @@ -22,29 +22,42 @@ SET(KERNEL_CXXFLAGS -I${KERNEL_ROOT_DIR}/include/salome) +FIND_LIBRARY(CalciumC CalciumC ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(DF DF ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(Launcher Launcher ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(LifeCycleCORBATest LifeCycleCORBATest ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(NamingServiceTest NamingServiceTest ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(OpUtil OpUtil ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(Registry Registry ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(ResourcesManager ResourcesManager ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SALOMEBasics SALOMEBasics ${KERNEL_ROOT_DIR}/lib/salome) -FIND_LIBRARY(SalomeBatch SalomeBatch ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeCatalog SalomeCatalog ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeCommunication SalomeCommunication ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeContainer SalomeContainer ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeDatastream SalomeDatastream ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeDSCContainer SalomeDSCContainer ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeDSClient SalomeDSClient ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeDSCSupervBasic SalomeDSCSupervBasic ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeDSCSuperv SalomeDSCSuperv ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeDSImpl SalomeDSImpl ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SALOMEDSImplTest SALOMEDSImplTest ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeDS SalomeDS ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SALOMEDSTest SALOMEDSTest ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeGenericObj SalomeGenericObj ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeHDFPersist SalomeHDFPersist ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeIDLKernel SalomeIDLKernel ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeLauncher SalomeLauncher ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeLifeCycleCORBA SalomeLifeCycleCORBA ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SALOMELocalTrace SALOMELocalTrace ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SALOMELocalTraceTest SALOMELocalTraceTest ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeLoggerServer SalomeLoggerServer ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeMPIContainer SalomeMPIContainer ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeNotification SalomeNotification ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeNS SalomeNS ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(SalomeResourcesManager SalomeResourcesManager ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeTestComponentEngine SalomeTestComponentEngine ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SalomeTestMPIComponentEngine SalomeTestMPIComponentEngine ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(SALOMETraceCollectorTest SALOMETraceCollectorTest ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(TOOLSDS TOOLSDS ${KERNEL_ROOT_DIR}/lib/salome) +FIND_LIBRARY(UtilsTest UtilsTest ${KERNEL_ROOT_DIR}/lib/salome) FIND_LIBRARY(with_loggerTraceCollector with_loggerTraceCollector ${KERNEL_ROOT_DIR}/lib/salome) diff --git a/salome_adm/cmake_files/FindMPI.cmake b/salome_adm/cmake_files/FindMPI.cmake index 548b01b77..29155aab6 100644 --- a/salome_adm/cmake_files/FindMPI.cmake +++ b/salome_adm/cmake_files/FindMPI.cmake @@ -80,6 +80,7 @@ IF(MPI_STATUS) MESSAGE(STATUS "MPI include ${MPI_INCLUDE_TO_FIND} found in ${MPI_INCLUDES}") + SET(MPI_INCLUDE_DIR ${MPI_INCLUDES}) SET(MPI_INCLUDES -I${MPI_INCLUDES}) # ------ @@ -91,9 +92,13 @@ IF(MPI_STATUS) FOREACH(lib mpi_cxx mpi mpich) FIND_LIBRARY(MPI_LIB ${lib} ${MPI_ROOT}/lib) IF(MPI_LIB) + IF(lib STREQUAL mpi_cxx) + SET(MPI_INCLUDES ${MPI_INCLUDES} -DOMPI_IGNORE_CXX_SEEK) + ENDIF(lib STREQUAL mpi_cxx) IF(lib STREQUAL mpich) SET(MPI_INCLUDES ${MPI_INCLUDES} -DMPICH_IGNORE_CXX_SEEK) ENDIF(lib STREQUAL mpich) + BREAK() ENDIF(MPI_LIB) ENDFOREACH(lib mpi_cxx mpi mpich) IF(NOT MPI_LIB) @@ -110,6 +115,18 @@ ENDIF(MPI_STATUS) # ------ +IF(MPI_STATUS) + include(CheckSymbolExists) + SET(CMAKE_REQUIRED_LIBRARIES ${MPI_LIBS}) + CHECK_SYMBOL_EXISTS(MPI_Publish_name ${MPI_INCLUDE_DIR}/mpi.h MPI2_IS_OK) + IF(MPI2_IS_OK) + MESSAGE(STATUS "Your mpi implemtentation is compatible with mpi2 ... adding -DHAVE_MPI2") + SET(MPI_INCLUDES ${MPI_INCLUDES} -DHAVE_MPI2) + ENDIF(MPI2_IS_OK) +ENDIF(MPI_STATUS) + +# ------ + IF(MPI_STATUS) SET(MPI_IS_OK ON) ELSE(MPI_STATUS) diff --git a/salome_adm/cmake_files/FindPLATFORM.cmake b/salome_adm/cmake_files/FindPLATFORM.cmake index 01f1e1512..5feb823ad 100644 --- a/salome_adm/cmake_files/FindPLATFORM.cmake +++ b/salome_adm/cmake_files/FindPLATFORM.cmake @@ -66,10 +66,11 @@ IF(WINDOWS) SET(PLATFORM_LIBADD ${PLATFORM_LIBADD} Ws2_32.lib) SET(PLATFORM_LIBADD ${PLATFORM_LIBADD} Userenv.lib) # At least for GEOM suit ELSE(WINDOWS) + SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -Wall) SET(PLATFORM_LIBADD ${PLATFORM_LIBADD} -ldl) ENDIF(WINDOWS) -SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DSIZEOF_FORTRAN_INTEGER=4 -DSIZEOF_LONG=4 -DSIZEOF_INT=4) +SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DSIZEOF_FORTRAN_INTEGER=4 -DSIZEOF_LONG=${CMAKE_SIZEOF_VOID_P} -DSIZEOF_INT=4) # SET(PLATFORM_CPPFLAGS) # # # SET(PLATFORM_CPPFLAGS ${PLATFORM_CPPFLAGS} -DWNT -D_CRT_SECURE_NO_WARNINGS) diff --git a/salome_adm/cmake_files/FindPYTHON.cmake b/salome_adm/cmake_files/FindPYTHON.cmake index 9c4bfeb4e..1748b93c3 100644 --- a/salome_adm/cmake_files/FindPYTHON.cmake +++ b/salome_adm/cmake_files/FindPYTHON.cmake @@ -199,8 +199,29 @@ ENDIF(PYTHON_STATUS) # ---- +SET(NUMPY_STATUS 0) +IF(PYTHON_STATUS) + EXECUTE_PROCESS( + COMMAND ${PYTHON_EXECUTABLE} -c "import numpy ; import sys ; sys.stdout.write(numpy.get_include())" + OUTPUT_VARIABLE NUMPY_INCLUDE_DIR + ERROR_QUIET + ) + IF(NUMPY_INCLUDE_DIR) + SET(NUMPY_STATUS 1) + ENDIF(NUMPY_INCLUDE_DIR) + IF(NUMPY_STATUS) + SET(PYTHON_INCLUDES ${PYTHON_INCLUDES} -I${NUMPY_INCLUDE_DIR}) + MESSAGE(STATUS "numpy found : ${NUMPY_INCLUDE_DIR}") + ELSE(NUMPY_STATUS) + MESSAGE(STATUS "numpy not found") + ENDIF(NUMPY_STATUS) +ENDIF(PYTHON_STATUS) + +# ---- + IF(PYTHON_STATUS) SET(PYTHON_CPPFLAGS ${PYTHON_INCLUDES}) + SET(PYLOGLEVEL WARNING) ELSE(PYTHON_STATUS) IF(PYTHON_IS_MANDATORY) MESSAGE(FATAL_ERROR "python not found ... mandatory ... abort") diff --git a/salome_adm/cmake_files/FindSWIG.cmake b/salome_adm/cmake_files/FindSWIG.cmake index 8f06c4e47..ed19d078f 100644 --- a/salome_adm/cmake_files/FindSWIG.cmake +++ b/salome_adm/cmake_files/FindSWIG.cmake @@ -91,3 +91,9 @@ ELSE(SWIG_STATUS) ENDIF(SWIG_STATUS) # ---- + +IF(NUMPY_STATUS) + SET(SWIG_FLAGS ${SWIG_FLAGS} -DWITH_NUMPY=WITH_NUMPY) +ENDIF(NUMPY_STATUS) + +# ---- diff --git a/salome_adm/cmake_files/Makefile.am b/salome_adm/cmake_files/Makefile.am index 2c2772d47..b08680ccb 100644 --- a/salome_adm/cmake_files/Makefile.am +++ b/salome_adm/cmake_files/Makefile.am @@ -24,6 +24,7 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am dist_salome_cmake_DATA = \ am2cmake.py \ +copytree1.py \ FindBOOST.cmake \ FindCPPUNIT.cmake \ FindDOXYGEN.cmake \ diff --git a/salome_adm/cmake_files/am2cmake.py b/salome_adm/cmake_files/am2cmake.py index 8e0774b15..9fb8632dc 100644 --- a/salome_adm/cmake_files/am2cmake.py +++ b/salome_adm/cmake_files/am2cmake.py @@ -205,31 +205,44 @@ class CMakeFile(object): "vtkImagingPythonD", ] kernel_list = [ + "CalciumC", "DF", "Launcher", + "LifeCycleCORBATest", + "NamingServiceTest", "OpUtil", "Registry", "ResourcesManager", "SALOMEBasics", - "SalomeBatch", "SalomeCatalog", "SalomeCommunication", "SalomeContainer", + "SalomeDatastream", "SalomeDSCContainer", "SalomeDSClient", + "SalomeDSCSupervBasic", + "SalomeDSCSuperv", "SalomeDSImpl", + "SALOMEDSImplTest", "SalomeDS", + "SALOMEDSTest", "SalomeGenericObj", "SalomeHDFPersist", "SalomeIDLKernel", "SalomeLauncher", "SalomeLifeCycleCORBA", "SALOMELocalTrace", + "SALOMELocalTraceTest", "SalomeLoggerServer", + "SalomeMPIContainer", "SalomeNotification", "SalomeNS", "SalomeResourcesManager", + "SalomeTestComponentEngine", + "SalomeTestMPIComponentEngine", + "SALOMETraceCollectorTest", "TOOLSDS", + "UtilsTest", "with_loggerTraceCollector", ] gui_list = [ @@ -243,6 +256,7 @@ class CMakeFile(object): "LogWindow", "ObjBrowser", "OCCViewer", + "OpenGLUtils", "Plot2d", "PyConsole", "PyInterp", @@ -250,9 +264,14 @@ class CMakeFile(object): "qtx", "QxScene", "SalomeApp", + "SalomeAppTest", "SalomeIDLGUI", "SalomeObject", "SalomePrs", + "SalomePyQtGUILight", + "SalomePyQtGUI", + "SalomePyQt", + "SalomePy", "SalomeSession", "SalomeStyle", "SOCC", @@ -263,9 +282,11 @@ class CMakeFile(object): "SUPERVGraph", "SVTK", "ToolsGUI", + "ViewerTools", "VTKViewer", ] geom_list = [ + "AdvancedGUI", "BasicGUI", "BlocksGUI", "BooleanGUI", @@ -295,6 +316,7 @@ class CMakeFile(object): "MeasureGUI", "NMTDS", "NMTTools", + "OCC2VTK", "OperationGUI", "PrimitiveGUI", "RepairGUI", @@ -304,23 +326,36 @@ class CMakeFile(object): "STEPImport", "STLExport", "TransformationGUI", + "VTKExport", ] med_list = [ - "InterpGeometric2DAlg", - "interpkernelbases", "interpkernel", + "InterpKernelTest", "MEDClientcmodule", + "medcouplingclient", + "medcouplingcorba", + "medcouplingremapper", "medcoupling", "MEDEngine", + "medloader", + "MEDMEMCppTest", "MEDMEMImpl", "medmem", "MED", + "medsplitter", + "MEDSPLITTERTest", "med_V2_1", "MEDWrapperBase", "MEDWrapper", "MEDWrapper_V2_1", "MEDWrapper_V2_2", + "paramedcouplingcorba", + "paramedloader", + "paramedmemcompo", + "paramedmem", + "ParaMEDMEMTest", "SalomeIDLMED", + "SalomeIDLMEDTests", ] smesh_list = [ "GeomSelectionTools", @@ -427,6 +462,10 @@ class CMakeFile(object): ENDIF(COMMAND cmake_policy) """) # -- + newlines.append(""" + ENABLE_TESTING() + """) + # -- if self.module == "kernel": newlines.append(""" INCLUDE(${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/FindPLATFORM.cmake) @@ -575,6 +614,13 @@ class CMakeFile(object): INCLUDE(${CMAKE_SOURCE_DIR}/adm/cmake/FindGRAPHVIZ.cmake) """) pass + if self.module == "hxx2salome": + newlines.append(""" + SET(MED_ROOT_DIR $ENV{MED_ROOT_DIR}) + INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMEDFILE.cmake) + INCLUDE(${MED_ROOT_DIR}/adm_local/cmake_files/FindMED.cmake) + """) + pass pass pass # -- @@ -593,8 +639,6 @@ class CMakeFile(object): newlines.append(""" SET(WITH_LOCAL 1) SET(WITH_BATCH 1) - set(VERSION 5.1.4) - set(XVERSION 0x050104) SET(CALCIUM_IDL_INT_F77 long) SET(CALCIUM_CORBA_INT_F77 CORBA::Long) SET(LONG_OR_INT int) @@ -610,8 +654,6 @@ class CMakeFile(object): SET(ENABLE_PYCONSOLE ON) SET(ENABLE_SUPERVGRAPHVIEWER ON) SET(ENABLE_QXGRAPHVIEWER ON) - set(VERSION 5.1.4) - set(XVERSION 0x050104) """) pass elif self.module == "geom": @@ -652,6 +694,15 @@ class CMakeFile(object): ENDIF(GUI_ROOT_DIR) """) pass + elif self.module == "netgen": + newlines.append(""" + SET(OCCFLAGS ${CAS_CPPFLAGS}) + SET(OCCLIBS ${CAS_LDPATH}) + SET(OCCLIBS ${OCCLIBS} ${TKernel} ${TKGeomBase} ${TKMath} ${TKG2d} ${TKG3d} ${TKXSBase} ${TKOffset} ${TKFillet} ${TKShHealing}) + SET(OCCLIBS ${OCCLIBS} ${TKMesh} ${TKMeshVS} ${TKTopAlgo} ${TKGeomAlgo} ${TKBool} ${TKPrim} ${TKBO} ${TKIGES} ${TKBRep}) + SET(OCCLIBS ${OCCLIBS} ${TKSTEPBase} ${TKSTEP} ${TKSTL} ${TKSTEPAttr} ${TKSTEP209} ${TKXDESTEP} ${TKXDEIGES} ${TKXCAF} ${TKLCAF} ${FWOSPlugin}) + """) + pass elif self.module == "netgenplugin": newlines.append(""" IF(GUI_ROOT_DIR) @@ -695,6 +746,10 @@ class CMakeFile(object): """) pass # -- + newlines.append(""" + set(VERSION 5.1.5) + set(XVERSION 0x050105) + """) pass # -- newlines.append(""" @@ -704,8 +759,15 @@ class CMakeFile(object): SET(AM_CPPFLAGS) SET(AM_CXXFLAGS) SET(LDADD) + SET(pythondir lib/python${PYTHON_VERSION}/site-packages) + SET(salomepythondir ${pythondir}/salome) + SET(salomepypkgdir ${salomepythondir}/salome) """) - if self.module == "kernel": + if self.module == "netgen": + newlines.append(r''' + SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DNO_PARALLEL_THREADS -DOCCGEOMETRY -I${CMAKE_BINARY_DIR} -I${CMAKE_CURRENT_SOURCE_DIR}) + ''') + elif self.module == "kernel": newlines.append(r''' SET(AM_CPPFLAGS ${AM_CPPFLAGS} -DHAVE_SALOME_CONFIG -I${CMAKE_BINARY_DIR}/salome_adm/unix -include SALOMEconfig.h) SET(AM_CXXFLAGS ${AM_CXXFLAGS} -DHAVE_SALOME_CONFIG -I${CMAKE_BINARY_DIR}/salome_adm/unix -include SALOMEconfig.h) @@ -719,6 +781,23 @@ class CMakeFile(object): ENDIF(KERNEL_ROOT_DIR) ''') pass + if self.module == "hxx2salome": + key = "_SRC" + if self.the_root[-len(key):] != key: + msg = "Source dir must finished with %s !"%(key) + raise Exception(msg) + hxxmodule = self.the_root[:-len(key)] + from os.path import basename + hxxmodule = basename(hxxmodule) + hxxmodule = hxxmodule.lower() + self.hxxmodule = hxxmodule + newlines.append(r''' + SET(HXXCPP_ROOT_DIR $ENV{%sCPP_ROOT_DIR}) + SET(AM_CPPFLAGS ${AM_CPPFLAGS} -I${HXXCPP_ROOT_DIR}/include) + SET(AM_CXXFLAGS ${AM_CXXFLAGS} -I${HXXCPP_ROOT_DIR}/include) + SET(LDADD ${LDADD} -L${HXXCPP_ROOT_DIR}/lib) + '''%(hxxmodule.upper())) + pass pass # -- return @@ -906,10 +985,57 @@ class CMakeFile(object): return def finalize(self, newlines): - + # -- # Convert the .in files in build dir # -- + + import operator + mod = self.module + if mod in ['kernel', 'gui'] and self.root[-len('gui'):] == 'gui' or mod == 'med' and operator.contains(self.root, 'doxygen'): + newlines.append(r''' + SET(top_builddir + ${CMAKE_BINARY_DIR} + ) + SET(top_srcdir + ${CMAKE_SOURCE_DIR} + ) + SET(srcdir + ${CMAKE_CURRENT_SOURCE_DIR} + ) + SET(builddir + ${CMAKE_CURRENT_BINARY_DIR} + ) + SET(datadir + ${CMAKE_INSTALL_PREFIX}/share + ) + SET(docdir + ${datadir}/doc/salome + ) + ''') + self.files.append("static/header.html.in") + elif self.root[-len(mod):] == mod.upper() and operator.contains(self.root, 'doc') or mod in ['kernel', 'gui', 'geom', 'med', 'smesh', 'visu'] and self.root[-len('tui'):] == 'tui': + newlines.append(r''' + SET(top_builddir + ${CMAKE_BINARY_DIR} + ) + SET(top_srcdir + ${CMAKE_SOURCE_DIR} + ) + SET(srcdir + ${CMAKE_CURRENT_SOURCE_DIR} + ) + SET(builddir + ${CMAKE_CURRENT_BINARY_DIR} + ) + SET(datadir + ${CMAKE_INSTALL_PREFIX}/share + ) + SET(docdir + ${datadir}/doc/salome + ) + ''') + self.files.append("static/header.html.in") if self.module == "yacs": key = "salomegui" if self.root[-len(key):] == key: @@ -918,6 +1044,8 @@ class CMakeFile(object): pass for f in self.files: if f[-3:] == ".in": + if self.module == 'yacs' and f == "Doxyfile.in": + continue if f == "sstream.in": continue if f in ["runContainer.in", "stopContainer.in"]: @@ -943,7 +1071,104 @@ class CMakeFile(object): ''') pass pass - + + # -- + # add commands for generating of user's documentation + # -- + + upmod = self.module.upper() + doc_gui_destination = "${CMAKE_INSTALL_PREFIX}/share/doc/salome/gui/%s"%(upmod) + doc_tui_destination = "${CMAKE_INSTALL_PREFIX}/share/doc/salome/tui/%s"%(upmod) + doc_destination = "${CMAKE_INSTALL_PREFIX}/share/doc/salome" + head_source = "${CMAKE_CURRENT_SOURCE_DIR}/images/head.png" + if mod == 'kernel': + copytree_src = "${CMAKE_SOURCE_DIR}/salome_adm/cmake_files" + else: + copytree_src = "$ENV{KERNEL_ROOT_DIR}/salome_adm/cmake_files" + str = "import re \nimport sys \noutfile = open(sys.argv[1], 'wb') \nfor line in open(sys.argv[2], 'rb').readlines():" + str += "\n if re.match('class '+sys.argv[3]+'DC', line): \n continue \n line = re.sub(r'^\s+\#', '#', line) \n line = re.sub(r'^\s+def', 'def', line) \n line = re.sub(sys.argv[3]+'DC', sys.argv[3], line)" + str += "\n outfile.write(line) \noutfile.close()" + + if mod in ['kernel', 'gui'] and self.root[-len('gui'):] == 'gui' or mod == 'med' and operator.contains(self.root, 'doxygen'): + if mod == 'med': + doc_source = "${CMAKE_CURRENT_BINARY_DIR}/doc_ref_user/html" + input = "Doxyfile_med_user" + else: + doc_source = "${CMAKE_CURRENT_BINARY_DIR}/%s"%(upmod) + input = "" + newlines.append("""\t ADD_CUSTOM_TARGET(usr_docs ${DOXYGEN_EXECUTABLE} %s + COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''', True); import copytree1; copytree1.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s''')" + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + )"""%(input, copytree_src, doc_gui_destination, doc_source, doc_gui_destination, head_source, doc_gui_destination)) + + if mod in ['geom', 'smesh', 'visu'] and self.root[-len(mod):] == upmod and operator.contains(self.root, 'doc'): + ign = r"""'tempfile', '*usr_docs*', '*CMakeFiles*', '*.cmake', 'doxyfile*', '*.vcproj', 'static', 'Makefile*'""" + if mod in ['geom', 'smesh']: + if mod == 'geom': + tmp = 'geompy' + input = "COMMAND ${DOXYGEN_EXECUTABLE} doxyfile_tui \n\t\t" + else: + tmp = 'smesh' + input = '' + newlines.append(r""" + FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tempfile "%s") + ADD_CUSTOM_TARGET(usr_docs ${PYTHON_EXECUTABLE} tempfile ${CMAKE_BINARY_DIR}/src/%s_SWIG/%s.py ${CMAKE_SOURCE_DIR}/src/%s_SWIG/%sDC.py %s + %sCOMMAND ${DOXYGEN_EXECUTABLE} doxyfile_py + COMMAND ${DOXYGEN_EXECUTABLE} doxyfile + COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.remove(r'''${CMAKE_BINARY_DIR}/src/%s_SWIG/%s.py''')" + COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''', True); import copytree1; copytree1.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}''', r'''%s''', ignore=copytree1.ignore_patterns(%s)); shutil.copy(r'''%s''', r'''%s''')" + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + )"""%(str, upmod, tmp, upmod, tmp, tmp, input, upmod, tmp, copytree_src, doc_gui_destination, doc_gui_destination, ign, head_source, doc_gui_destination)) + else: + newlines.append("""\t ADD_CUSTOM_TARGET(usr_docs ${DOXYGEN_EXECUTABLE} doxyfile_idl + COMMAND ${DOXYGEN_EXECUTABLE} doxyfile + COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''',True); import copytree1; copytree1.copytree(r'''${CMAKE_CURRENT_BINARY_DIR}''',r'''%s''', ignore=copytree1.ignore_patterns(%s)); shutil.copy(r'''%s''',r'''%s''')" + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + )"""%(copytree_src, doc_gui_destination, doc_gui_destination, ign, head_source, doc_gui_destination)) + + # -- + # add commands for generating of developer's documentation + # -- + + upmod = self.module.upper() + if mod in ['kernel', 'gui', 'med', 'smesh', 'visu'] and self.root[-len('tui'):] == 'tui': + if mod == 'kernel': + tmp = """\tADD_CUSTOM_TARGET(dev_docs ${DOXYGEN_EXECUTABLE} -u + COMMAND ${DOXYGEN_EXECUTABLE} + COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.remove(r'''${CMAKE_CURRENT_BINARY_DIR}/doxyfile.bak''')" """ + tmp1="" + else: + tmp = """\tADD_CUSTOM_TARGET(dev_docs ${DOXYGEN_EXECUTABLE}""" + if mod == 'visu': + tmp1= r"""\n COMMAND ${PYTHON_EXECUTABLE} -c "from shutil import copy; copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/visuscreen.png''', r'''%s''')" """%(doc_tui_destination) + elif mod == 'smesh': + extra_srcdir = "${CMAKE_CURRENT_SOURCE_DIR}/extra" + tmp1= """\n COMMAND ${PYTHON_EXECUTABLE} -c "from shutil import copy; copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/smeshscreen.png''', r'''%s'''); copy(r'''%s/AddNetgenInSalome2.pdf''', r'''%s'''); copy(r'''%s/PluginMeshers.html''', r'''%s''')" + COMMAND ${PYTHON_EXECUTABLE} -c "from shutil import copy; copy(r'''%s/AddNetgenInSalome2.ps''', r'''%s'''); copy(r'''%s/AddNetgenInSalome2.sxw''', r'''%s''')" """%(doc_tui_destination, extra_srcdir,doc_destination, extra_srcdir,doc_destination, extra_srcdir,doc_destination,extra_srcdir,doc_destination) + else: + tmp1="" + doc_source = "${CMAKE_CURRENT_BINARY_DIR}/%s"%(upmod) + newlines.append(tmp + """ + COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''', True); import copytree1; copytree1.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s''')" """%(copytree_src, doc_tui_destination, doc_source, doc_tui_destination, head_source, doc_tui_destination) + tmp1 + """ + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + )""") + if mod == 'geom' and self.root[-len('tui'):] == 'tui': + tmp = 'geompy' + doc_source = "${CMAKE_CURRENT_BINARY_DIR}/%s"%(upmod) + newlines.append(r""" + FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/tempfile "%s") + ADD_CUSTOM_TARGET(dev_docs ${PYTHON_EXECUTABLE} tempfile ${CMAKE_BINARY_DIR}/src/%s_SWIG/%s.py ${CMAKE_SOURCE_DIR}/src/%s_SWIG/%sDC.py %s + COMMAND ${DOXYGEN_EXECUTABLE} doxyfile + COMMAND ${PYTHON_EXECUTABLE} -c "import os; os.remove(r'''${CMAKE_BINARY_DIR}/src/%s_SWIG/%s.py''')" + COMMAND ${PYTHON_EXECUTABLE} -c "import shutil, sys; sys.path.append(r'''%s'''); shutil.rmtree(r'''%s''', True); import copytree1; copytree1.copytree(r'''%s''', r'''%s'''); shutil.copy(r'''%s''', r'''%s'''); shutil.copy(r'''${CMAKE_CURRENT_SOURCE_DIR}/images/geomscreen.png''', r'''%s''')" + VERBATIM + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + )"""%(str, upmod, tmp, upmod, tmp, tmp, upmod, tmp, copytree_src, doc_tui_destination, doc_source, doc_tui_destination, head_source, doc_tui_destination, doc_tui_destination)) + # -- # convert the SUBDIRS in cmake grammar # -- @@ -1030,7 +1255,10 @@ class CMakeFile(object): pass newlines.append(''' INSTALL(CODE "SET(IDL_FILE ${input})") - INSTALL(CODE "SET(DIR lib/python${PYTHON_VERSION}/site-packages/salome)") + INSTALL(CODE "SET(DIR ${salomepythondir})") + IF(WINDOWS) + INSTALL(CODE "SET(DIR bin/salome)") + ENDIF(WINDOWS) INSTALL(CODE "SET(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})") INSTALL(CODE "SET(OMNIORB_IDL_PYTHON ${OMNIORB_IDL_PYTHON})") # -- @@ -1207,31 +1435,75 @@ class CMakeFile(object): ENDFOREACH(input ${SIP_FILES}) ''') pass + + # -- + # For make check + # -- + for key in ["TESTS"]: + if self.__thedict__.has_key(key): + newlines.append(''' + SET(UNIT_TEST_PROG ${%s}) + '''%(key)) + self.__thedict__["UNIT_TEST_PROG"] = self.__thedict__[key] + pass + pass + key = "UNIT_TEST_PROG" + if self.__thedict__.has_key(key): + newlines.append(''' + FOREACH(input ${UNIT_TEST_PROG}) + GET_FILENAME_COMPONENT(ext ${input} EXT) + IF(ext STREQUAL .py) + SET(test ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${input}) + ELSE(ext STREQUAL .py) + IF(WINDOWS) + SET(test ${CMAKE_CURRENT_BINARY_DIR}/${input}_exe.exe) + ELSE() + SET(test ${CMAKE_CURRENT_BINARY_DIR}/${input}_exe) + ENDIF() + ENDIF(ext STREQUAL .py) + ADD_TEST(${input} ${test}) + SET(fail_regex "KO") + SET_PROPERTY(TEST ${input} PROPERTY FAIL_REGULAR_EXPRESSION "${fail_regex}") + # IF(NOT WINDOWS) + # ADD_TEST(${input}_valgrind valgrind ${test}) + # SET_PROPERTY(TEST ${input}_valgrind PROPERTY FAIL_REGULAR_EXPRESSION "${fail_regex}") + # SET_PROPERTY(TEST ${input}_valgrind PROPERTY PASS_REGULAR_EXPRESSION "no leaks are possible") + # ENDIF() + ENDFOREACH(input ${UNIT_TEST_PROG}) + ''') + pass # -- # Treat the install targets # -- + resdir = self.module + if resdir == "hxx2salome": + resdir = self.hxxmodule + pass d = { - "salomeadmux_DATA" : "salome_adm/unix", - "dist_salomeadmux_DATA" : "salome_adm/unix", - "dist_salome_cmake_DATA" : "salome_adm/cmake_files", - "dist_salomem4_DATA" : "salome_adm/unix/config_files", - "dist_salome4depr_DATA" : "salome_adm/unix/config_files/DEPRECATED", - "dist_admlocalm4_DATA" : "adm_local/unix/config_files", - "dist_admlocal_cmake_DATA" : "adm_local/cmake_files", - "salomeinclude_DATA" : "include/salome", - "salomeinclude_HEADERS" : "include/salome", - "dist_salomeres_DATA" : "share/salome/resources/%s"%(self.module), - "nodist_salomeres_DATA" : "share/salome/resources/%s"%(self.module), - "nodist_salomeres_SCRIPTS" : "share/salome/resources/%s"%(self.module), - "dist_salomescript_SCRIPTS" : "bin/salome", - "dist_salomescript_DATA" : "bin/salome", - "dist_salomescript_PYTHON" : "bin/salome", - "nodist_salomescript_DATA" : "bin/salome", - "salomepython_PYTHON" : "lib/python${PYTHON_VERSION}/site-packages/salome", - "nodist_salomepython_PYTHON" : "lib/python${PYTHON_VERSION}/site-packages/salome", - "dist_salomepython_DATA" : "lib/python${PYTHON_VERSION}/site-packages/salome", - "sharedpkgpython_PYTHON" : "lib/python${PYTHON_VERSION}/site-packages/salome/shared_modules", + "salomeadmux_DATA" : "salome_adm/unix", + "dist_salomeadmux_DATA" : "salome_adm/unix", + "dist_salome_cmake_DATA" : "salome_adm/cmake_files", + "dist_salomem4_DATA" : "salome_adm/unix/config_files", + "dist_salome4depr_DATA" : "salome_adm/unix/config_files/DEPRECATED", + "dist_admlocalm4_DATA" : "adm_local/unix/config_files", + "dist_admlocal_cmake_DATA" : "adm_local/cmake_files", + "salomeinclude_DATA" : "include/salome", + "salomeinclude_HEADERS" : "include/salome", + "nodist_salomeinclude_HEADERS" : "include/salome", + "dist_salomeres_DATA" : "share/salome/resources/%s"%(resdir), + "nodist_salomeres_DATA" : "share/salome/resources/%s"%(resdir), + "nodist_salomeres_SCRIPTS" : "share/salome/resources/%s"%(resdir), + "dist_salomescript_SCRIPTS" : "bin/salome", + "dist_salomescript_DATA" : "bin/salome", + "dist_salomescript_PYTHON" : "bin/salome", + "nodist_salomescript_DATA" : "bin/salome", + "salomepython_PYTHON" : "${salomepythondir}", + "nodist_salomepython_PYTHON" : "${salomepythondir}", + "dist_salomepython_DATA" : "${salomepythondir}", + "sharedpkgpython_PYTHON" : "${salomepythondir}/shared_modules", + "salomepypkg_PYTHON" : "${salomepypkgdir}", + "mypkgpython_PYTHON" : "${mypkgpythondir}", } if self.module == "medfile": d = { @@ -1241,6 +1513,14 @@ class CMakeFile(object): "doc_DATA" : "${docdir}", } pass + if self.module == "netgen": + d = { + "include_HEADERS" : "include", + "noinst_HEADERS" : "share/netgen/include", + "dist_pkgdata_DATA" : "share/netgen", + "dist_doc_DATA" : "share/doc/netgen", + } + pass for key, value in d.items(): if self.__thedict__.has_key(key): self.addInstallTarget(key, value, newlines) @@ -1272,18 +1552,13 @@ class CMakeFile(object): ''') # -- newlines.append(r''' - SET(libs ${PLATFORM_LIBADD} ${PLATFORM_LDFLAGS} ${${amname}_LIBADD} ${${amname}_LDADD} ${${amname}_LDFLAGS}) + SET(libs ${PLATFORM_LIBADD} ${PLATFORM_LDFLAGS} ${LDADD} ${${amname}_LIBADD} ${${amname}_LDADD} ${${amname}_LDFLAGS}) FOREACH(lib SALOMEBasics SalomeBatch) IF(name STREQUAL lib) SET(libs ${libs} ${PTHREAD_LIBS}) ENDIF(name STREQUAL lib) ENDFOREACH(lib SALOMEBasics SalomeBatch) ''') - if key == "bin_PROGRAMS": - newlines.append(r''' - SET(libs ${libs} ${LDADD}) - ''') - pass # -- newlines.append(r''' FOREACH(lib ${libs}) @@ -1386,6 +1661,13 @@ class CMakeFile(object): SET(var ${var} ${AM_CPPFLAGS}) SET(var ${var} ${AM_CXXFLAGS}) ''') + # -- + newlines.append(r''' + IF(type STREQUAL STATIC) + SET(var ${var} -fPIC) + ENDIF(type STREQUAL STATIC) + ''') + # -- if self.module == "yacs": newlines.append(r''' SET(var ${var} -DYACS_PTHREAD) @@ -1415,7 +1697,24 @@ class CMakeFile(object): SET(f) ENDIF(f STREQUAL v) ENDFOREACH(v ${vars}) + IF(f) + string(REGEX MATCH "^-I" test_include ${f}) + if(test_include) + string(REGEX REPLACE "^-I" "" include_dir ${f}) + if(include_dir) + if(include_dir STREQUAL /usr/include) + else(include_dir STREQUAL /usr/include) + string(REGEX MATCH "^\\." test_dot ${include_dir}) + if(test_dot) + set(include_dir ${CMAKE_CURRENT_BINARY_DIR}/${include_dir}) + endif(test_dot) + include_directories(${include_dir}) + endif(include_dir STREQUAL /usr/include) + endif(include_dir) + else(test_include) SET(flags "${flags} ${f}") + endif(test_include) + ENDIF(f) ENDFOREACH(f ${var}) SET_TARGET_PROPERTIES(${name} PROPERTIES COMPILE_FLAGS "${flags}") ''') @@ -1493,9 +1792,15 @@ class CMakeFile(object): STRING(REPLACE ".f" ".c" src ${src}) SET(src ${CMAKE_CURRENT_BINARY_DIR}/${src}) SET(output ${src}) + SET(cmd f2c) + IF(NOT WINDOWS) + IF(CMAKE_SIZEOF_VOID_P STREQUAL 8) + SET(cmd valgrind f2c) # f2c seems to be buggy on 64 bits ... but with valgrind, it works :) + ENDIF() + ENDIF(NOT WINDOWS) ADD_CUSTOM_COMMAND( OUTPUT ${output} - COMMAND f2c ${input} + COMMAND ${cmd} ${input} MAIN_DEPENDENCY ${input} ) ELSE(src STREQUAL trte.f) @@ -1553,8 +1858,29 @@ class CMakeFile(object): # -- self.setLibAdd(key, newlines) # -- - if key != "noinst_LTLIBRARIES": - if self.module == "medfile": + if 1: # key != "noinst_LTLIBRARIES": + newlines.append(r''' + SET(key %s) + '''%(key)) + newlines.append(r''' + SET(test ON) + IF(${key} STREQUAL noinst_LTLIBRARIES) + SET(test OFF) + ENDIF(${key} STREQUAL noinst_LTLIBRARIES) + ''') + if self.module == "netgen" : + newlines.append(r''' + IF(${key} STREQUAL noinst_LTLIBRARIES) + IF(WINDOWS) + SET(test ON) + ENDIF(WINDOWS) + ENDIF(${key} STREQUAL noinst_LTLIBRARIES) + ''') + pass + newlines.append(r''' + IF(test) + ''') + if self.module in ["medfile", "netgen"]: newlines.append(r''' SET(DEST lib) ''') @@ -1614,23 +1940,26 @@ class CMakeFile(object): ''') newlines.append(r''' IF(WINDOWS) - INSTALL(TARGETS ${name} DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome) + INSTALL(TARGETS ${name} DESTINATION ${salomepythondir}) IF(CMAKE_BUILD_TYPE STREQUAL Release) - INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/salome/${name}.dll DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome RENAME ${name}.pyd) + INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${salomepythondir}/${name}.dll DESTINATION ${salomepythondir} RENAME ${name}.pyd) ELSE(CMAKE_BUILD_TYPE STREQUAL Release) - INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/salome/${name}.dll DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome RENAME ${name}_d.pyd) + INSTALL(FILES ${CMAKE_INSTALL_PREFIX}/${salomepythondir}/${name}.dll DESTINATION ${salomepythondir} RENAME ${name}_d.pyd) ENDIF(CMAKE_BUILD_TYPE STREQUAL Release) ELSE(WINDOWS) GET_TARGET_PROPERTY(version ${name} VERSION) GET_TARGET_PROPERTY(soversion ${name} SOVERSION) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome RENAME ${name}.so.${version}) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome RENAME ${name}.so.${soversion}) - INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION lib/python${PYTHON_VERSION}/site-packages/salome RENAME ${name}.so) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION ${salomepythondir} RENAME ${name}.so.${version}) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION ${salomepythondir} RENAME ${name}.so.${soversion}) + INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/lib${name}.so.${version} DESTINATION ${salomepythondir} RENAME ${name}.so) ENDIF(WINDOWS) ''') newlines.append(r''' ENDIF(BEGIN_WITH_lib) ''') + newlines.append(r''' + ENDIF(test) + ''') pass # -- newlines.append(r''' @@ -1679,7 +2008,7 @@ class CMakeFile(object): # -- self.setLibAdd(key, newlines) # -- - if self.module == "medfile": + if self.module in ["medfile", "netgen"]: newlines.append(r''' SET(DEST bin) ''') @@ -1802,7 +2131,10 @@ class CMakeFile(object): ELSE(f STREQUAL SALOME_ContainerPy.py) IF(f STREQUAL am2cmake.py) ELSE(f STREQUAL am2cmake.py) + IF(f STREQUAL copytree1.py) + ELSE(f STREQUAL copytree1.py) INSTALL(SCRIPT ${CMAKE_SOURCE_DIR}/salome_adm/cmake_files/install_and_compile_python_file.cmake) + ENDIF(f STREQUAL copytree1.py) ENDIF(f STREQUAL am2cmake.py) ENDIF(f STREQUAL SALOME_ContainerPy.py) ''') @@ -1857,6 +2189,8 @@ if __name__ == "__main__": from os import getcwd the_root = getcwd() # + nok = 0 + # from os import walk for root, dirs, files in walk(the_root): # -- @@ -1878,12 +2212,20 @@ if __name__ == "__main__": from sys import stdout for f in files: if f in ["Makefile.am", "Makefile.am.cmake"]: - stdout.write("Scanning %s %s ..."%(root, f)) - stdout.flush() convertAmFile(the_root, root, dirs, files, f, module) - stdout.write(" done.\n") + nok += 1 pass pass pass # + if nok: + if nok == 1: + msg = "%s file has been converted to cmake"%(nok) + else: + msg = "%s files have been converted to cmake"%(nok) + pass + stdout.write(msg) + stdout.write("\n") + stdout.flush() + pass pass diff --git a/salome_adm/cmake_files/copytree1.py b/salome_adm/cmake_files/copytree1.py new file mode 100755 index 000000000..5a6c6ac5e --- /dev/null +++ b/salome_adm/cmake_files/copytree1.py @@ -0,0 +1,91 @@ +import os +import sys +import stat +from os.path import abspath +import fnmatch + +import shutil + +class Error(EnvironmentError): + pass +try: + WindowsError +except NameError: + WindowsError = None + +def ignore_patterns(*patterns): + """Function that can be used as copytree() ignore parameter. + + Patterns is a sequence of glob-style patterns + that are used to exclude files""" + def _ignore_patterns(path, names): + ignored_names = [] + for pattern in patterns: + ignored_names.extend(fnmatch.filter(names, pattern)) + return set(ignored_names) + return _ignore_patterns + +def copytree(src, dst, symlinks=False, ignore=None): + """Recursively copy a directory tree using shutil.copy2(). + + The destination directory must not already exist. + If exception(s) occur, an Error is raised with a list of reasons. + + If the optional symlinks flag is true, symbolic links in the + source tree result in symbolic links in the destination tree; if + it is false, the contents of the files pointed to by symbolic + links are copied. + + The optional ignore argument is a callable. If given, it + is called with the `src` parameter, which is the directory + being visited by copytree(), and `names` which is the list of + `src` contents, as returned by os.listdir(): + + callable(src, names) -> ignored_names + + Since copytree() is called recursively, the callable will be + called once for each directory that is copied. It returns a + list of names relative to the `src` directory that should + not be copied. + + XXX Consider this example code rather than the ultimate tool. + + """ + names = os.listdir(src) + if ignore is not None: + ignored_names = ignore(src, names) + else: + ignored_names = set() + + os.makedirs(dst) + errors = [] + for name in names: + if name in ignored_names: + continue + srcname = os.path.join(src, name) + dstname = os.path.join(dst, name) + try: + if symlinks and os.path.islink(srcname): + linkto = os.readlink(srcname) + os.symlink(linkto, dstname) + elif os.path.isdir(srcname): + copytree(srcname, dstname, symlinks, ignore) + else: + shutil.copy2(srcname, dstname) + # XXX What about devices, sockets etc.? + except (IOError, os.error), why: + errors.append((srcname, dstname, str(why))) + # catch the Error from the recursive copytree so that we can + # continue with other files + except Error, err: + errors.extend(err.args[0]) + try: + shutil.copystat(src, dst) + except OSError, why: + if WindowsError is not None and isinstance(why, WindowsError): + # Copying file access times may fail on Windows + pass + else: + errors.extend((src, dst, str(why))) + if errors: + raise Error, errors diff --git a/salome_adm/unix/config_files/Makefile.am b/salome_adm/unix/config_files/Makefile.am index 9583f274b..71cef5843 100644 --- a/salome_adm/unix/config_files/Makefile.am +++ b/salome_adm/unix/config_files/Makefile.am @@ -64,6 +64,7 @@ check_f77.m4 \ check_calcium.m4 \ check_hdf5.m4 \ check_htmlgen.m4 \ +check_sphinx.m4 \ check_lam.m4 \ check_libbatch.m4 \ check_mpi.m4 \ @@ -72,6 +73,7 @@ check_mpich.m4 \ check_omniorb.m4 \ check_sockets.m4 \ check_swig.m4 \ +check_vtk.m4 \ check_withihm.m4 \ enable_pthreads.m4 \ production.m4 \ @@ -79,7 +81,8 @@ pyembed.m4 \ python.m4 \ check_libxml.m4 \ check_paco++.m4 \ -local_install.m4 +local_install.m4 \ +hack_libtool.m4 dist_salome4depr_DATA=\ $(DEPRECATED_FILES) diff --git a/salome_adm/unix/config_files/check_boost.m4 b/salome_adm/unix/config_files/check_boost.m4 index 7005aec86..f377ef236 100644 --- a/salome_adm/unix/config_files/check_boost.m4 +++ b/salome_adm/unix/config_files/check_boost.m4 @@ -29,8 +29,11 @@ AC_REQUIRE([ENABLE_PTHREADS])dnl AC_LANG_SAVE AC_LANG_CPLUSPLUS +gccver=`$CC -dumpversion | sed 's/^\([[0-9]]\+\)\.\([[0-9]]\+\).*/\1\2/g'` +SUFFIXES="empty -mt -gcc -gcc-mt -gcc${gccver} -gcc${gccver}-mt" + BOOST_CPPFLAGS="" -BOOST_LIBSUFFIX="-mt" +BOOST_LIBSUFFIX="" BOOST_LIBS="" AC_CHECKING(for BOOST location) @@ -49,9 +52,11 @@ AC_MSG_RESULT(\$BOOSTDIR = ${BOOSTDIR}) CPPFLAGS_old="${CPPFLAGS}" LIBS_old=$LIBS +LIB_SUFFIX="${LIB_LOCATION_SUFFIX}" + if test "x${BOOSTDIR}" != "x" ; then BOOST_CPPFLAGS="-I${BOOSTDIR}/include" - BOOST_LIBS="-L${BOOSTDIR}/lib${LIB_LOCATION_SUFFIX}" + BOOST_LIBS="-L${BOOSTDIR}/lib${LIB_SUFFIX}" fi if test "x${BOOSTDIR}" = "x/usr" ; then @@ -101,15 +106,18 @@ if test "x${boost_headers_ok}" = "xyes" ; then AC_CHECKING(for BOOST binaries) boost_lib_dir_ok=yes if test "x${BOOSTDIR}" != "x" ; then - AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_LOCATION_SUFFIX}/libboost_thread${BOOST_LIBSUFFIX}.so, - boost_lib_dir_ok=yes, - boost_lib_dir_ok=no) - if test "x${boost_lib_dir_ok}" = "xno" ; then - BOOST_LIBSUFFIX="" - AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_LOCATION_SUFFIX}/libboost_thread${BOOST_LIBSUFFIX}.so, - boost_lib_dir_ok=yes, - boost_lib_dir_ok=no) - fi + for BOOST_LIBSUFFIX in ${SUFFIXES} ; do + test "${BOOST_LIBSUFFIX}" == "empty" && BOOST_LIBSUFFIX="" + AC_CHECK_FILE([${BOOSTDIR}/lib${LIB_SUFFIX}/libboost_thread${BOOST_LIBSUFFIX}.so], + [boost_lib_dir_ok=yes], + [AC_CHECK_FILE([${BOOSTDIR}/lib64/libboost_thread${BOOST_LIBSUFFIX}.so], + [boost_lib_dir_ok=yes; LIB_SUFFIX=64], + [boost_lib_dir_ok=no]) + ]) + if test "x${boost_lib_dir_ok}" = "xyes" ; then + break + fi + done fi if test "x${boost_lib_dir_ok}" = "xyes" ; then LIBS="${LIBS_old} ${BOOST_LIBS} -lboost_thread${BOOST_LIBSUFFIX}" @@ -117,13 +125,8 @@ if test "x${boost_headers_ok}" = "xyes" ; then [struct TBody{ void operator()(){} }; boost::thread(TBody())], boost_binaries_ok=yes, boost_binaries_ok=no) - if test "x${boost_binaries_ok}" = "xno" ; then - BOOST_LIBSUFFIX="" - LIBS="${LIBS_old} ${BOOST_LIBS} -lboost_thread${BOOST_LIBSUFFIX}" - AC_TRY_LINK([#include ], - [struct TBody{ void operator()(){} }; boost::thread(TBody())], - boost_binaries_ok=yes, - boost_binaries_ok=no) + if test "x${boost_binaries_ok}" = "xyes" ; then + break fi fi fi @@ -134,16 +137,16 @@ if test "x${boost_binaries_ok}" = "xno" ; then else AC_MSG_RESULT(\$BOOST_LIBSUFFIX = ${BOOST_LIBSUFFIX}) AC_MSG_RESULT(\$BOOST_LIBS = ${BOOST_LIBS}) - AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_LOCATION_SUFFIX}/libboost_thread${BOOST_LIBSUFFIX}.so, + AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_SUFFIX}/libboost_thread${BOOST_LIBSUFFIX}.so, BOOST_LIB_THREAD="${BOOST_LIBS} -lboost_thread${BOOST_LIBSUFFIX}", BOOST_LIB_THREAD="") - AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_LOCATION_SUFFIX}/libboost_signals${BOOST_LIBSUFFIX}.so, + AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_SUFFIX}/libboost_signals${BOOST_LIBSUFFIX}.so, BOOST_LIB_SIGNALS="${BOOST_LIBS} -lboost_signals${BOOST_LIBSUFFIX}", BOOST_LIB_SIGNALS="") - AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_LOCATION_SUFFIX}/libboost_system${BOOST_LIBSUFFIX}.so, + AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_SUFFIX}/libboost_system${BOOST_LIBSUFFIX}.so, BOOST_LIB_SYSTEM="${BOOST_LIBS} -lboost_system${BOOST_LIBSUFFIX}", BOOST_LIB_SYSTEM="") - AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_LOCATION_SUFFIX}/libboost_regex${BOOST_LIBSUFFIX}.so, + AC_CHECK_FILE(${BOOSTDIR}/lib${LIB_SUFFIX}/libboost_regex${BOOST_LIBSUFFIX}.so, BOOST_LIB_REGEX="${BOOST_LIBS} -lboost_regex${BOOST_LIBSUFFIX}", BOOST_LIB_REGEX="") fi diff --git a/salome_adm/unix/config_files/check_mpi.m4 b/salome_adm/unix/config_files/check_mpi.m4 index 4f9886cb4..d85f67727 100644 --- a/salome_adm/unix/config_files/check_mpi.m4 +++ b/salome_adm/unix/config_files/check_mpi.m4 @@ -82,6 +82,12 @@ if test x"$MPIREQUESTED" = xyes; then mpi_ok=no fi + if test "$WITHMPI2" = "yes";then + mpi2_ok=yes + else + mpi2_ok=no + fi + fi if test "$WITHMPI" = no; then @@ -127,5 +133,8 @@ AC_SUBST(WITHMPI) AC_SUBST(MPI_INCLUDES) AC_SUBST(MPI_LIBS) AC_SUBST(mpi_ok) +AC_SUBST(mpi2_ok) AM_CONDITIONAL(MPI_IS_OK, [test x"$mpi_ok" = xyes]) +AM_CONDITIONAL(MPI2_IS_OK, [test x"$mpi2_ok" = xyes]) + ])dnl diff --git a/salome_adm/unix/config_files/check_omniorb.m4 b/salome_adm/unix/config_files/check_omniorb.m4 index 3590669be..fd381029e 100644 --- a/salome_adm/unix/config_files/check_omniorb.m4 +++ b/salome_adm/unix/config_files/check_omniorb.m4 @@ -210,7 +210,7 @@ if test "x$omniORB_ok" = "xyes" then OMNIORB_IDLCXXFLAGS="-Wba -nf -I${OMNIORB_ROOT}/idl" - OMNIORB_IDLPYFLAGS_1='-bpython' + OMNIORB_IDLPYFLAGS_1='-bpython -nf ' OMNIORB_IDLPYFLAGS_2=" -I${OMNIORB_ROOT}/idl" OMNIORB_IDLPYFLAGS=${OMNIORB_IDLPYFLAGS_1}${OMNIORB_IDLPYFLAGS_2} diff --git a/salome_adm/unix/config_files/check_openmpi.m4 b/salome_adm/unix/config_files/check_openmpi.m4 index 1d18b6332..f0b81ea6c 100644 --- a/salome_adm/unix/config_files/check_openmpi.m4 +++ b/salome_adm/unix/config_files/check_openmpi.m4 @@ -57,11 +57,13 @@ if test "$WITHOPENMPI" = yes; then AC_MSG_CHECKING(for openmpi) if test "$WITHOPENMPI" = "yes";then mpi_ok=yes + mpi2_ok=$WITHMPI2 WITHMPI=yes CPPFLAGS="-DOMPI_IGNORE_CXX_SEEK -DWITHOPENMPI $CPPFLAGS" AC_MSG_RESULT(yes) else mpi_ok=no + mpi2_ok=no WITHMPI=no AC_MSG_RESULT(no) fi diff --git a/salome_adm/unix/config_files/check_sphinx.m4 b/salome_adm/unix/config_files/check_sphinx.m4 new file mode 100644 index 000000000..eec149530 --- /dev/null +++ b/salome_adm/unix/config_files/check_sphinx.m4 @@ -0,0 +1,35 @@ +dnl Copyright (C) 2006-2008 CEA/DEN, EDF R&D +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl +dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +dnl +AC_DEFUN([CHECK_SPHINX],[ + +AC_CHECKING(for sphinx doc generator) + +sphinx_ok=yes +dnl where is sphinx ? +AC_PATH_PROG(SPHINX,sphinx-build) +if test "x$SPHINX" = "x" +then + AC_MSG_WARN(sphinx not found) + sphinx_ok=no +fi + +AM_CONDITIONAL(SPHINX_IS_OK, [test x"$sphinx_ok" = xyes]) + +])dnl +dnl diff --git a/salome_adm/unix/config_files/check_vtk.m4 b/salome_adm/unix/config_files/check_vtk.m4 new file mode 100644 index 000000000..48cf22f0c --- /dev/null +++ b/salome_adm/unix/config_files/check_vtk.m4 @@ -0,0 +1,388 @@ +dnl Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +dnl +dnl Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +dnl CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl +dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +dnl + +dnl OPTIONS_VTK +dnl ------------------------------------------------------------------------ +dnl Adds the --with-vtk=path, --with-vtk-version and --with-paraview configure options +dnl +AC_DEFUN([OPTIONS_VTK], [ + AC_ARG_WITH([vtk], + [AC_HELP_STRING([--with-vtk], [The prefix where VTK is installed (default "" means taking from environment variable unless VTK from ParaView is detected)])], + [with_vtk=$withval], [with_vtk=""]) + + AC_ARG_WITH([vtk-version], + [AC_HELP_STRING([--with-vtk-version], [VTK include directory name is vtk-suffix, e.g. vtk-5.0/. What is the suffix? (Default "yes" means taking from environment variable)])], + [vtk_suffix=$withval], [vtk_suffix="yes"]) + + AC_ARG_WITH([paraview], + [AC_HELP_STRING([--with-paraview], [ParaView from the specified location is used instead of VTK (default "" means taking from environment variable)])]) +]) + +dnl +dnl CHECK_VTK +dnl ------------------------------------------------------------------------ +dnl +AC_DEFUN([CHECK_VTK], [ +AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CXX])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +AC_REQUIRE([AC_PROG_CXXCPP])dnl +AC_REQUIRE([AC_LINKER_OPTIONS])dnl + +AC_REQUIRE([OPTIONS_VTK])dnl + +AC_LANG_SAVE +AC_LANG_CPLUSPLUS + +AC_SUBST(VTK_INCLUDES) +AC_SUBST(VTK_LIBS) +AC_SUBST(VTKPY_MODULES) + +VTK_INCLUDES="" +VTK_LIBS="" +VTKPY_MODULES="" + +vtk_ok=no + +if test "x$OpenGL_ok" != "xyes" ; then + AC_MSG_WARN(VTK needs OpenGL correct configuration, check configure output) +fi + +AC_PATH_X +if test "x$x_libraries" != "x" +then + LXLIB="-L$x_libraries" +else + LXLIB="" +fi + +if test "x$x_libraries" = "x/usr/lib" +then + LXLIB="" +fi + +if test "x$x_libraries" = "x/usr/lib${LIB_LOCATION_SUFFIX}" +then + LXLIB="" +fi + +LOCAL_INCLUDES="$OGL_INCLUDES" +LOCAL_LIBS="-lvtkCommon -lvtkGraphics -lvtkImaging -lvtkFiltering -lvtkIO -lvtkRendering -lvtkHybrid -lvtkParallel -lvtkWidgets $LXLIB -lX11 -lXt" +TRY_LINK_LIBS="-lvtkCommon $LXLIB -lX11 -lXt" + +dnl VTK version suffix +if test -z $vtk_suffix ; then + vtk_suffix="yes" +fi +if test "x$vtk_suffix" = "xno" ; then + dnl in case user wrote --with-vtk-version=no, use empty suffix + vtk_suffix="" +fi +if test "x$vtk_suffix" != "xyes" ; then + VTKSUFFIX="$vtk_suffix" +else + dnl in case user wrote --with-vtk-version=yes, get the suffix from env + if test -z $VTKSUFFIX ; then + VTKSUFFIX="-5.0" + fi +fi + +dnl +dnl Use VTK from ParaView unless --with-paraview=no is given +dnl + +pv_vtk_ok=no + +case "x$with_paraview" in + + xno ) + PVHOME="" + ;; + + xyes | x ) + + if test -z $PVHOME ; then + AC_PATH_PROG(para_path, paraview) + if test "x$para_path" != "x" ; then + para_path=`dirname $para_path` + PVHOME=`dirname $para_path` + else + for d in /usr/local /usr ; do + if test -f ${d}/include/paraview${PVVERSION}/pqDialog.h ; then + AC_MSG_RESULT(trying ${d}) + PVHOME="${d}" + break + fi + if test -f ${d}/include/paraview-3.7/pqDialog.h ; then + AC_MSG_RESULT(trying ${d}) + PVHOME="${d}" + PVVERSION="-3.7" + break + fi + if test -f ${d}/include/paraview-3.8/pqDialog.h ; then + AC_MSG_RESULT(trying ${d}) + PVHOME="${d}" + PVVERSION="-3.8" + break + fi + if test -f ${d}/include/paraview/pqDialog.h ; then + AC_MSG_RESULT(trying ${d}) + PVHOME="${d}" + PVVERSION="" + break + fi + done + fi + fi + ;; + + * ) + PVHOME=${with_paraview} + ;; +esac + +dnl Check VTK from ParaView. + +if test "x$PVHOME" != "x" ; then + + if test "x$PVVERSION" = "x" ; then + for suffix in 3.7 3.8 ; do + if test -f $PVHOME/include/paraview-$suffix/vtkPVConfig.h ; then + PVVERSION=$suffix + break; + fi + done + fi + if test "x$PVVERSION" = "x" ; then + PVVERSION=`basename $PVHOME | sed -e "s,[[^-]]*,,"` + else + if test "${PVVERSION:0:1}" != "-" ; then + PVVERSION="-$PVVERSION" + fi + fi + + AC_CHECKING(for VTK from ParaView) + + PV_LOCAL_INCLUDES="-I$PVHOME/include/paraview$PVVERSION $LOCAL_INCLUDES" + PV_LOCAL_LIBS="-L$PVHOME/lib/paraview$PVVERSION -lvtksys -lvtkzlib -lvtkpng -lvtkjpeg -lvtktiff -lvtkexpat -lvtksqlite -lvtkmetaio -lvtkverdict -lvtkNetCDF -lvtkDICOMParser -lvtkfreetype -lvtkftgl -lvtkexoIIc $LOCAL_LIBS" + PV_TRY_LINK_LIBS="-L$PVHOME/lib/paraview$PVVERSION -lvtksys $TRY_LINK_LIBS" + + dnl vtk headers + CPPFLAGS_old="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $PV_LOCAL_INCLUDES" + + AC_CHECK_HEADER(vtkPoints.h,pv_vtk_ok="yes",pv_vtk_ok="no") + + CPPFLAGS="$CPPFLAGS_old" + + if test "x$pv_vtk_ok" = "xyes"; then + + dnl vtk libraries + + AC_MSG_CHECKING(linking VTK library from ParaView) + + LIBS_old="$LIBS" + LIBS="$LIBS $PV_TRY_LINK_LIBS" + CPPFLAGS_old="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $PV_LOCAL_INCLUDES" + + AC_CACHE_VAL(salome_cv_lib_pvvtk,[ + AC_TRY_LINK([#include "vtkPoints.h" + ], + [vtkPoints::New()], + [salome_cv_lib_pvvtk=yes], + [salome_cv_lib_pvvtk=no]) + ]) + pv_vtk_ok="$salome_cv_lib_pvvtk" + LIBS="$LIBS_old" + CPPFLAGS="$CPPFLAGS_old" + AC_MSG_RESULT($pv_vtk_ok) + fi + + dnl Find out version of VTK from ParaView + PVVTKVERSION=" Undefined" + if test "x$pv_vtk_ok" = "xyes"; then + AC_MSG_CHECKING(VTK version) + PVVTKVERSION=`grep VTK_VERSION $PVHOME/include/paraview$PVVERSION/vtkConfigure.h` + AC_MSG_RESULT(${PVVTKVERSION:20:10}) + fi +fi + +dnl +dnl Use regular VTK if no ParaView found or a newer version is provided via --with-vtk +dnl + +try_regular_vtk=no +if test "$pv_vtk_ok" = "no"; then + try_regular_vtk=yes +fi + +if test -z $with_vtk ; then + with_vtk="" +fi +case "x$with_vtk" in + xyes) + dnl in case user wrote --with-vtk=yes + with_vtk="" + ;; + xno) + dnl in case user wrote --with-vtk=no + with_vtk="" + AC_MSG_WARN(Value "no", specified for option --with-vtk, is not supported) + ;; + x) + ;; + *) + try_regular_vtk=yes + ;; +esac + +if test "$try_regular_vtk" = "yes"; then + + dnl Check regular VTK installation + AC_CHECKING(for regular VTK) + + dnl VTK install dir + + if test "x$with_vtk" != "x" ; then + VTKHOME="$with_vtk" + else + if test -z $VTKHOME ; then + AC_MSG_WARN(undefined VTKHOME variable which specify where vtk was compiled) + for d in /usr/local /usr ; do + if test -f ${d}/include/vtk${VTKSUFFIX}/vtkPlane.h ; then + AC_MSG_RESULT(trying ${d}) + VTKHOME="${d}" + break + fi + if test -f ${d}/include/vtk-5.0/vtkPlane.h ; then + AC_MSG_RESULT(trying ${d}) + VTKHOME="${d}" + VTKSUFFIX="-5.0" + break + fi + if test -f ${d}/include/vtk-5.2/vtkPlane.h ; then + AC_MSG_RESULT(trying ${d}) + VTKHOME="${d}" + VTKSUFFIX="-5.2" + break + fi + if test -f ${d}/include/vtk/vtkPlane.h ; then + AC_MSG_RESULT(trying ${d}) + VTKHOME="${d}" + VTKSUFFIX="" + break + fi + done + fi + fi + + VTK_LOCAL_INCLUDES="-I$VTKHOME/include/vtk${VTKSUFFIX} $LOCAL_INCLUDES" + VTK_LOCAL_LIBS="-L$VTKHOME/lib${LIB_LOCATION_SUFFIX}/vtk${VTKSUFFIX} $LOCAL_LIBS" + VTK_TRY_LINK_LIBS="-L$VTKHOME/lib${LIB_LOCATION_SUFFIX} -L$VTKHOME/lib${LIB_LOCATION_SUFFIX}/vtk${VTKSUFFIX} $TRY_LINK_LIBS" + if test "x$VTKHOME" != "x/usr" ; then + VTK_LOCAL_LIBS="-L$VTKHOME/lib${LIB_LOCATION_SUFFIX}/vtk${VTKSUFFIX} $LOCAL_LIBS" + fi + + dnl vtk headers + CPPFLAGS_old="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $VTK_LOCAL_INCLUDES" + + AC_CHECK_HEADER(vtkPlane.h,vtk_ok="yes",vtk_ok="no") + + CPPFLAGS="$CPPFLAGS_old" + + if test "x$vtk_ok" = "xyes"; then + + # VTK_INCLUDES="$LOCAL_INCLUDES" + + dnl vtk libraries + + AC_MSG_CHECKING(linking regular VTK library) + + LIBS_old="$LIBS" + LIBS="$LIBS $VTK_TRY_LINK_LIBS" + CPPFLAGS_old="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS $VTK_LOCAL_INCLUDES" + + dnl VTKPY_MODULES="$VTKHOME/python" + + AC_CACHE_VAL(salome_cv_lib_vtk,[ + AC_TRY_LINK([#include "vtkPlane.h" + ], + [vtkPlane::New()], + [salome_cv_lib_vtk=yes], + [salome_cv_lib_vtk=no]) + ]) + vtk_ok="$salome_cv_lib_vtk" + LIBS="$LIBS_old" + CPPFLAGS="$CPPFLAGS_old" + AC_MSG_RESULT($vtk_ok) + fi + + VTKVERSION=" Undefined" + if test "x$vtk_ok" = "xyes"; then + AC_MSG_CHECKING(VTK version) + VTKVERSION=`grep VTK_VERSION $VTKHOME/include/vtk${VTKSUFFIX}/vtkConfigure.h` + AC_MSG_RESULT(${VTKVERSION:20:10}) + fi +fi + +dnl Select either of VTKs +if test "x$pv_vtk_ok" = "xyes" ; then + if test "x$vtk_ok" = "xyes" ; then + if test "$VTKVERSION" \> "$PVVTKVERSION" ; then + AC_MSG_RESULT([VTK from ParaView is older, ignored]) + pv_vtk_ok=no + else + AC_MSG_RESULT([regular VTK is older, ignored]) + vtk_ok=no + fi + fi +fi + +if test "x$pv_vtk_ok" = "xyes" ; then + AC_MSG_RESULT(for VTK: yes) + VTK_INCLUDES="$PV_LOCAL_INCLUDES -DVTK_EXCLUDE_STRSTREAM_HEADERS" + VTK_LIBS="$PV_LOCAL_LIBS" + VTK_MT_LIBS="$VTK_LIBS" + #VTKPY_MODULES= + vtk_ok=yes +else + if test "x$vtk_ok" = "xyes" ; then + AC_MSG_RESULT(for VTK: yes) + VTK_INCLUDES="$VTK_LOCAL_INCLUDES -DVTK_EXCLUDE_STRSTREAM_HEADERS" + VTK_LIBS="$VTK_LOCAL_LIBS" + VTK_MT_LIBS="$VTK_LIBS" + #VTKPY_MODULES= + else + AC_MSG_RESULT(for VTK: no) + AC_MSG_WARN(unable to link with vtk library) + fi +fi + +AC_LANG_RESTORE + +# Save cache +AC_CACHE_SAVE + +])dnl diff --git a/salome_adm/unix/config_files/hack_libtool.m4 b/salome_adm/unix/config_files/hack_libtool.m4 new file mode 100644 index 000000000..54a65dc87 --- /dev/null +++ b/salome_adm/unix/config_files/hack_libtool.m4 @@ -0,0 +1,41 @@ +dnl Copyright (C) 2010 CEA/DEN, EDF R&D, OPEN CASCADE +dnl +dnl This library is free software; you can redistribute it and/or +dnl modify it under the terms of the GNU Lesser General Public +dnl License as published by the Free Software Foundation; either +dnl version 2.1 of the License. +dnl +dnl This library is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +dnl Lesser General Public License for more details. +dnl +dnl You should have received a copy of the GNU Lesser General Public +dnl License along with this library; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +dnl +dnl See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +dnl + +dnl --- +dnl File : hack_libtool.m4 +dnl Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +dnl --- +dnl +dnl The purpose of below autoconf macro is to workaround very annoying problem +dnl of the GNU libtool program. The problem leads to the incorrect linking +dnl to the native libraries (installed in /usr/lib[64]) instead of those supplied +dnl with specific -Ldir options. + +AC_DEFUN([AC_HACK_LIBTOOL],[ +sed -i "s%^CC=\"\(.*\)\"%hack_libtool (){ \n\ + if test \"\$(echo \$[@] | grep -E '\\\-L/usr/lib(/../lib)?(64)? ')\" == \"\" \n\ + then\n\ + cmd=\"\1 \$[@]\"\n\ + else\n\ + cmd=\"\1 \"\`echo \$[@] | sed -r -e 's|(.*)-L/usr/lib(/../lib)?(64)? (.*)|\\\1\\\4 -L/usr/lib\\\3|g'\`\n\ + fi\n\ + \$cmd\n\ +}\n\ +CC=\"hack_libtool\"%g" libtool +]) diff --git a/salome_adm/unix/config_files/python.m4 b/salome_adm/unix/config_files/python.m4 index 5260f7eb3..e842a2798 100644 --- a/salome_adm/unix/config_files/python.m4 +++ b/salome_adm/unix/config_files/python.m4 @@ -64,6 +64,11 @@ AC_DEFUN([CHECK_PYTHON], AC_SUBST(PYTHON_VERSION) PY_MAKEFILE=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/Makefile + if test ! -f "$PY_MAKEFILE"; then + if test "${build_cpu::6}" = "x86_64" ; then + PY_MAKEFILE=${PYTHON_PREFIX}/lib64/python$PYTHON_VERSION/config/Makefile + fi + fi if test ! -f "$PY_MAKEFILE"; then AC_MSG_WARN([*** Couldn't find ${PY_MAKEFILE}. Maybe you are *** missing the development portion of the python installation]) @@ -77,6 +82,13 @@ AC_DEFUN([CHECK_PYTHON], PYTHON_LIBS="-L${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}" PYTHON_LIB=$PYTHON_LIBS PYTHON_LIBA=${PYTHON_PREFIX}/lib${LIB_LOCATION_SUFFIX}/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a + if test "${build_cpu::6}" = "x86_64" ; then + if test "$PY_MAKEFILE" = "${PYTHON_PREFIX}/lib64/python$PYTHON_VERSION/config/Makefile" ; then + PYTHON_LIBS="-L${PYTHON_PREFIX}/lib64/python${PYTHON_VERSION}/config -lpython${PYTHON_VERSION}" + PYTHON_LIB=$PYTHON_LIBS + PYTHON_LIBA=${PYTHON_PREFIX}/lib64/python$PYTHON_VERSION/config/libpython$PYTHON_VERSION.a + fi + fi dnl At times (like when building shared libraries) you may want dnl to know which OS Python thinks this is. diff --git a/salome_adm/unix/make_common_starter.am b/salome_adm/unix/make_common_starter.am index 198595381..d1ebd26cd 100644 --- a/salome_adm/unix/make_common_starter.am +++ b/salome_adm/unix/make_common_starter.am @@ -44,9 +44,17 @@ salomeincludedir = $(includedir)/salome libdir = $(prefix)/lib@LIB_LOCATION_SUFFIX@/salome bindir = $(prefix)/bin/salome salomescriptdir = $(bindir) +# _GBO_SALOME_PYTHON_PACKAGING_ +# Maybe we could try to suppress on stage in this folder path, for +# example by installing by default the python files in site-packages +# folder. Then, python packages could be installed in the +# site-packages/salome folder (main package containing the root +# __init__.py file). This could be done by replacing salomepythondir +# and salomepyexecdir by pythondir and pyexecdir respectively (TO BE +# DONE) salomepythondir = $(pythondir)/salome salomepyexecdir = $(pyexecdir)/salome - +salomepypkgdir = $(salomepythondir)/salome # Directory for installing idl files salomeidldir = $(prefix)/idl/salome diff --git a/src/Container/SALOME_Container.py b/src/Container/SALOME_Container.py index d3dfc6482..c830f8d96 100644 --- a/src/Container/SALOME_Container.py +++ b/src/Container/SALOME_Container.py @@ -128,7 +128,7 @@ class SALOME_Container_i: def create_pynode(self,nodeName,code): try: - node=SALOME_PyNode.PyNode_i(nodeName,code,self._poa) + node=SALOME_PyNode.PyNode_i(nodeName,code,self._poa,self) id_o = self._poa.activate_object(node) comp_o = self._poa.id_to_reference(id_o) comp_iors = self._orb.object_to_string(comp_o) diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 497e0c1ed..a22a39c2f 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -86,6 +86,11 @@ SALOME_ContainerManager::SALOME_ContainerManager(CORBA::ORB_ptr orb, PortableSer #ifdef HAVE_MPI2 #ifdef WITHOPENMPI + std::string urifile = getenv("HOME"); + std::ostringstream mypid; + mypid << getpid(); + urifile += "/.urifile_" + mypid.str(); + setenv("OMPI_URI_FILE",urifile.c_str(),0); if( getenv("OMPI_URI_FILE") != NULL ){ system("killall ompi-server"); std::string command; @@ -286,14 +291,10 @@ SALOME_ContainerManager::GiveContainer(const Engines::ContainerParameters& param std::string containerNameInNS; if(params.isMPI){ int nbproc; - if ( (params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0) ) + if ( params.nb_proc <= 0 ) nbproc = 1; - else if ( params.resource_params.nb_node == 0 ) - nbproc = params.resource_params.nb_proc_per_node; - else if ( params.resource_params.nb_proc_per_node == 0 ) - nbproc = params.resource_params.nb_node; else - nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node; + nbproc = params.nb_proc; if( getenv("LIBBATCH_NODEFILE") != NULL ) machFile = machinesFile(nbproc); // A mpi parallel container register on zero node in NS @@ -406,7 +407,9 @@ SALOME_ContainerManager::GiveContainer(const Engines::ContainerParameters& param #ifdef WNT std::string logFilename=getenv("TEMP"); logFilename += "\\"; + std::string user = getenv( "USERNAME" ); #else + std::string user = getenv( "USER" ); std::string logFilename="/tmp"; char* val = getenv("SALOME_TMP_DIR"); if(val) @@ -419,7 +422,7 @@ SALOME_ContainerManager::GiveContainer(const Engines::ContainerParameters& param } logFilename += "/"; #endif - logFilename += _NS->ContainerName(params)+"_"+ resource_selected +"_"+getenv( "USER" ) ; + logFilename += _NS->ContainerName(params)+"_"+ resource_selected +"_"+user; std::ostringstream tmp; tmp << "_" << getpid(); logFilename += tmp.str(); @@ -469,7 +472,7 @@ SALOME_ContainerManager::GiveContainer(const Engines::ContainerParameters& param // Setting log file name logFilename=":"+logFilename; logFilename="@"+Kernel_Utils::GetHostname()+logFilename; - logFilename=getenv( "USER" )+logFilename; + logFilename=user+logFilename; ret->logfilename(logFilename.c_str()); RmTmpFile(_TmpFileName); // command file can be removed here } @@ -589,14 +592,10 @@ SALOME_ContainerManager::BuildCommandToLaunchRemoteContainer if (params.isMPI) { - if ((params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0)) + if ( params.nb_proc <= 0 ) nbproc = 1; - else if (params.resource_params.nb_node == 0) - nbproc = params.resource_params.nb_proc_per_node; - else if (params.resource_params.nb_proc_per_node == 0) - nbproc = params.resource_params.nb_node; else - nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node; + nbproc = params.nb_proc; } // "ssh -l user machine distantPath/runRemote.sh hostNS portNS WORKINGDIR workingdir \ @@ -696,14 +695,10 @@ SALOME_ContainerManager::BuildCommandToLaunchLocalContainer { o << "mpirun -np "; - if ( (params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0) ) + if ( params.nb_proc <= 0 ) nbproc = 1; - else if ( params.resource_params.nb_node == 0 ) - nbproc = params.resource_params.nb_proc_per_node; - else if ( params.resource_params.nb_proc_per_node == 0 ) - nbproc = params.resource_params.nb_node; else - nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node; + nbproc = params.nb_proc; o << nbproc << " "; @@ -910,14 +905,10 @@ SALOME_ContainerManager::BuildTempFileToLaunchRemoteContainer tempOutputFile << "mpirun -np "; int nbproc; - if ( (params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0) ) + if ( params.nb_proc <= 0 ) nbproc = 1; - else if ( params.resource_params.nb_node == 0 ) - nbproc = params.resource_params.nb_proc_per_node; - else if ( params.resource_params.nb_proc_per_node == 0 ) - nbproc = params.resource_params.nb_node; else - nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node; + nbproc = params.nb_proc; std::ostringstream o; @@ -1063,7 +1054,7 @@ std::string SALOME_ContainerManager::GetMPIZeroNode(const std::string machine, c status = system(command.c_str()); if( status == 0 ){ std::ifstream fp(tmpFile.c_str(),std::ios::in); - fp >> zeronode; + while(fp >> zeronode); } RmTmpFile(tmpFile); diff --git a/src/Container/SALOME_PyNode.py b/src/Container/SALOME_PyNode.py index f02d54f36..cf50f8ca6 100644 --- a/src/Container/SALOME_PyNode.py +++ b/src/Container/SALOME_PyNode.py @@ -48,14 +48,16 @@ class Generic(SALOME__POA.GenericObj): class PyNode_i (Engines__POA.PyNode,Generic): """The implementation of the PyNode CORBA IDL""" - def __init__(self, nodeName,code,poa): + def __init__(self, nodeName,code,poa,my_container): """Initialize the node : compilation in the local context""" Generic.__init__(self,poa) self.nodeName=nodeName self.code=code + self.my_container=my_container._container linecache.cache[nodeName]=0,None,string.split(code,'\n'),nodeName ccode=compile(code,nodeName,'exec') self.context={} + self.context["my_container"] = self.my_container exec ccode in self.context def execute(self,funcName,argsin): diff --git a/src/HDFPersist/HDFascii.cc b/src/HDFPersist/HDFascii.cc index c138caab6..53b344272 100644 --- a/src/HDFPersist/HDFascii.cc +++ b/src/HDFPersist/HDFascii.cc @@ -123,7 +123,7 @@ char* HDFascii::ConvertFromHDFToASCII(const char* thePath, char name[HDF_NAME_MAX_LEN+1]; int nbsons = hdf_file->nInternalObjects(), nbAttr = hdf_file->nAttributes(); - FILE* fp = fopen(aFileName.c_str(), "w"); + FILE* fp = fopen(aFileName.c_str(), "wb"); fprintf(fp, "%s\n", ASCIIHDF_ID); fprintf(fp, "%i\n", nbsons+nbAttr); @@ -386,7 +386,7 @@ char* HDFascii::ConvertFromASCIIToHDF(const char* thePath, aFullName = std::string(thePath)+".ascii_tmp"; } - FILE *fp = fopen(thePath, "r"); + FILE *fp = fopen(thePath, "rb"); if(!fp) return NULL; HDFfile *hdf_file = new HDFfile((char*)aFullName.c_str()); @@ -446,6 +446,8 @@ char* HDFascii::ConvertFromASCIIToHDF(const char* thePath, char *new_str = new char[ 1+length ]; strcpy(new_str , aTmpDir.c_str()) ; + fclose(fp); + return new_str; } @@ -667,20 +669,12 @@ bool CreateAttributeFromASCII(HDFinternalObject *father, FILE* fp) //============================================================================ std::string GetTmpDir() { - //Find a temporary directory to store a file - std::string aTmpDir; - char *Tmp_dir = getenv("SALOME_TMP_DIR"); if(Tmp_dir != NULL) { aTmpDir = std::string(Tmp_dir); if(aTmpDir[aTmpDir.size()-1] != dir_separator) aTmpDir+=dir_separator; -/*#ifdef WIN32 - if(aTmpDir[aTmpDir.size()-1] != '\\') aTmpDir+='\\'; -#else - if(aTmpDir[aTmpDir.size()-1] != '/') aTmpDir+='/'; -#endif*/ } else { #ifdef WIN32 @@ -700,16 +694,9 @@ std::string GetTmpDir() aTmpDir += aSubDir; //Get RND sub directory if(aTmpDir[aTmpDir.size()-1] != dir_separator) aTmpDir+=dir_separator; -/* -#ifdef WIN32 - if(aTmpDir[aTmpDir.size()-1] != '\\') aTmpDir+='\\'; -#else - if(aTmpDir[aTmpDir.size()-1] != '/') aTmpDir+='/'; -#endif - */ std::string aDir = aTmpDir; - + for(aRND = 0; Exists(aDir); aRND++) { sprintf(buffer, "%d", aRND); aDir = aTmpDir+buffer; //Build a unique directory name @@ -782,10 +769,10 @@ void read_float64(FILE* fp, hdf_float64* value) bool Exists(const std::string thePath) { #ifdef WIN32 - if ( GetFileAttributes ( thePath.c_str() ) == 0xFFFFFFFF ) { - if ( GetLastError () != ERROR_FILE_NOT_FOUND ) { + if ( GetFileAttributes ( thePath.c_str() ) == 0xFFFFFFFF ) { + DWORD errorId = GetLastError (); + if ( errorId == ERROR_FILE_NOT_FOUND || errorId == ERROR_PATH_NOT_FOUND ) return false; - } } #else int status = access ( thePath.c_str() , F_OK ); diff --git a/src/HDFPersist/HDFdatasetRead.c b/src/HDFPersist/HDFdatasetRead.c index 843f2d717..e3dc6b13a 100644 --- a/src/HDFPersist/HDFdatasetRead.c +++ b/src/HDFPersist/HDFdatasetRead.c @@ -46,10 +46,10 @@ hdf_err HDFdatasetRead(hdf_idt id, void *val) if ((datatype = H5Dget_type(id)) < 0) return -1; -#if defined (PCLINUX) || defined (PCLINUX64) +//#if defined (PCLINUX) || defined (PCLINUX64) if ((H5Tget_class(datatype) == H5T_INTEGER) && (H5Tget_size(datatype) == 4)) datatype = H5T_NATIVE_INT; -#endif +//#endif if ((ret = H5Dread(id,datatype,H5S_ALL,H5S_ALL,H5P_DEFAULT, val)) < 0) return -1; diff --git a/src/KERNEL_PY/Makefile.am b/src/KERNEL_PY/Makefile.am index 8ec0e4f73..177977feb 100755 --- a/src/KERNEL_PY/Makefile.am +++ b/src/KERNEL_PY/Makefile.am @@ -36,7 +36,6 @@ if CORBA_GEN salomepython_PYTHON += \ Help.py \ PyInterp.py \ - salome.py \ batchmode_salome.py \ salome_test.py \ salome_kernel.py \ @@ -50,4 +49,11 @@ if CORBA_GEN salome_genericobj.py endif +# _GBO_SALOME_PYTHON_PACKAGING_ +# Note that the salome.py should not be installed any more +# Special extention to create a python packaging +SUBDIRS= kernel +salomepypkg_PYTHON= \ + __init__.py + sharedpkgpython_PYTHON = kernel_shared_modules.py diff --git a/src/KERNEL_PY/__init__.py b/src/KERNEL_PY/__init__.py new file mode 100644 index 000000000..2c8755ecd --- /dev/null +++ b/src/KERNEL_PY/__init__.py @@ -0,0 +1,218 @@ +# -*- coding: iso-8859-1 -*- +# Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +# +# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +# + +# File : salome.py renamed as __init__.py for python packaging (gboulant) +# Author : Paul RASCLE, EDF +# Module : SALOME +# $Header$ +# +""" +Module salome gives access to Salome ressources. + +variables: + + - salome.orb : CORBA + - salome.naming_service : instance of naming Service class + - methods: + - Resolve(name) : find a CORBA object (ior) by its pathname + - Register(name) : register a CORBA object under a pathname + + - salome.lcc : instance of lifeCycleCORBA class + - methods: + - FindOrLoadComponent(server,name) : + obtain an Engine (CORBA object) + or launch the Engine if not found, + with a Server name and an Engine name + + - salome.sg : salome object to communicate with the graphical user interface (if any) + - methods: + - updateObjBrowser(bool): + - getActiveStudyId(): + - getActiveStudyName(): + + - SelectedCount(): returns number of selected objects + - getSelected(i): returns entry of selected object number i + - getAllSelected(): returns list of entry of selected objects + - AddIObject(Entry): select an existing Interactive object + - RemoveIObject(Entry): remove object from selection + - ClearIObjects(): clear selection + + - Display(*Entry): + - DisplayOnly(Entry): + - Erase(Entry): + - DisplayAll(): + - EraseAll(): + + - IDToObject(Entry): returns CORBA reference from entry + + - salome.myStudyName : active Study Name + - salome.myStudyId : active Study Id + - salome.myStudy : the active Study itself (CORBA ior) + - methods : defined in SALOMEDS.idl + +""" +## @package salome +# Module salome gives access to Salome ressources. +# +# \param salome.orb : CORBA orb object +# \param salome.naming_service : instance of naming Service class (SALOME_NamingServicePy::SALOME_NamingServicePy_i) +# \param salome.lcc : instance of lifeCycleCORBA class (SALOME_LifeCycleCORBA) +# \param salome.sg : Salome object to communicate with the graphical user interface, if running (see interface in salome_iapp::SalomeOutsideGUI) +# \param salome.myStudyName : active Study Name +# \param salome.myStudyId : active Study Id +# \param salome.myStudy : the active Study (interface SALOMEDS::Study) + +# +# ========================================================================== +# +# The function extend_path is used here to aggregate in a single +# virtual python package all the python sub-packages embedded in each +# SALOME modules (python "namespace" pattern). +# +ROOT_PYTHONPACKAGE_NAME="salome" +# +# This root package name is expected to be found as a directory in +# some paths of the sys.path variable, especially the paths +# /lib/pythonX.Y/site-packages/salome where are +# installed the python files. These paths are theorically appended by +# the SALOME main runner and should be in the sys.path at this point +# of the application. The extend_path is looking then for directories +# of the type: +# +# /lib/pythonX.Y/site-packages/salome/ +# +# And append them to the sys.path. These directories are supposed to +# be the pieces to be aggregated as a single virtual python package. +# +import os, sys +MATCH_ENDING_PATTERN="site-packages/salome" +def extend_path(pname): + for dir in sys.path: + if not isinstance(dir, basestring) or not os.path.isdir(dir) or not dir.endswith(MATCH_ENDING_PATTERN): + continue + subdir = os.path.join(dir, pname) + # XXX This may still add duplicate entries to path on + # case-insensitive filesystems + if os.path.isdir(subdir) and subdir not in __path__: + print "INFO - The directory %s is appended to sys.path" % subdir + __path__.append(subdir) + +extend_path(ROOT_PYTHONPACKAGE_NAME) +# ========================================================================== +# + +from salome_kernel import * +from salome_study import * +from salome_iapp import * + +# +# The next block is workaround for the problem of shared symbols loading for the extension modules (e.g. SWIG-generated) +# that causes RTTI unavailable in some cases. To solve this problem, sys.setdlopenflags() function is used. +# Depending on the Python version and platform, the dlopen flags can be defined in the dl, DLFUN or ctypes module. +# +import sys +flags = None +if not flags: + try: + # dl module can be unavailable + import dl + flags = dl.RTLD_NOW | dl.RTLD_GLOBAL + except: + pass + pass +if not flags: + try: + # DLFCN module can be unavailable + import DLFCN + flags = DLFCN.RTLD_NOW | DLFCN.RTLD_GLOBAL + except: + pass + pass +if not flags: + try: + # ctypes module can be unavailable + import ctypes + flags = ctypes.RTLD_GLOBAL + except: + pass + pass + +if flags: + sys.setdlopenflags(flags) + pass + +orb, lcc, naming_service, cm,sg=None,None,None,None,None +myStudyManager, myStudyId, myStudy, myStudyName=None,None,None,None + +salome_initial=1 +def salome_init(theStudyId=0,embedded=0): + """ + Performs only once SALOME general purpose intialisation for scripts. + optional argument : theStudyId + When in embedded interpreter inside IAPP, theStudyId is not used + When used without GUI (external interpreter) + 0 : create a new study (default). + n (>0) : try connection to study with Id = n, or create a new one + if study not found. + If study creation, its Id may be different from theStudyId ! + Provides: + orb reference to CORBA + lcc a LifeCycleCorba instance + naming_service a naming service instance + cm reference to the container manager + sg access to SALOME GUI (when linked with IAPP GUI) + myStudyManager the study manager + myStudyId active study identifier + myStudy active study itself (CORBA reference) + myStudyName active study name + """ + global salome_initial + global orb, lcc, naming_service, cm + global sg + global myStudyManager, myStudyId, myStudy, myStudyName + + try: + if salome_initial: + salome_initial=0 + sg = salome_iapp_init(embedded) + orb, lcc, naming_service, cm = salome_kernel_init() + myStudyManager, myStudyId, myStudy, myStudyName =salome_study_init(theStudyId) + pass + pass + except RuntimeError, inst: + # wait a little to avoid trace mix + import time + time.sleep(0.2) + x = inst + print "salome.salome_init():", x + print """ + ============================================ + May be there is no running SALOME session + salome.salome_init() is intented to be used + within an already running session + ============================================ + """ + raise + +#to expose all objects to pydoc +__all__=dir() diff --git a/src/KERNEL_PY/import_hook.py b/src/KERNEL_PY/import_hook.py index 54c5f1313..d812d8f67 100755 --- a/src/KERNEL_PY/import_hook.py +++ b/src/KERNEL_PY/import_hook.py @@ -119,6 +119,7 @@ def import_module(partname, fqname, parent): """ Try to import module fqname It's parent is module parent and has name partname """ + #print "import_module",partname, fqname, parent try: m = sys.modules[fqname] except KeyError: @@ -129,6 +130,7 @@ def import_module(partname, fqname, parent): def ensure_fromlist(m, fromlist, recursive=0): """ Return the real modules list to be imported """ + #print "ensure_fromlist",m, fromlist, recursive l=[] for sub in fromlist: if sub == "*": @@ -139,11 +141,23 @@ def ensure_fromlist(m, fromlist, recursive=0): pass else: l.extend(ensure_fromlist(m, all, 1)) - elif hasattr(m,sub): - submod=getattr(m,sub) + else: + #try to find if sub is an attribute (eventually dotted) of m + components=sub.split('.') + has_submod=True + submod=m + for comp in components: + if hasattr(submod,comp): + submod=getattr(submod, comp) + else: + has_submod=False + break + + if has_submod: + #the attribute has been found if type(submod) == type(sys): l.append(("%s.%s" % (m.__name__, sub),submod)) - else: + else: subname="%s.%s" % (m.__name__, sub) submod = import_module(sub, subname, m) if not submod: @@ -151,14 +165,14 @@ def ensure_fromlist(m, fromlist, recursive=0): l.append((subname,submod)) return l -def import_hook(name, globals=None, locals=None, fromlist=None, *args): +def import_hook(name, globals=None, locals=None, fromlist=None, *args, **kwds): """ Import replacement for sharing modules among multiple interpreters Mostly update sys.modules before doing real import """ #print "import_hook",name,fromlist m=get_shared_imported(name,fromlist) - module= original_import(name, globals, locals, fromlist, *args) + module= original_import(name, globals, locals, fromlist, *args, **kwds) if fromlist: #when fromlist is specified, module is the real module diff --git a/src/KERNEL_PY/kernel/Makefile.am b/src/KERNEL_PY/kernel/Makefile.am new file mode 100644 index 000000000..9152084da --- /dev/null +++ b/src/KERNEL_PY/kernel/Makefile.am @@ -0,0 +1,11 @@ +include $(top_srcdir)/salome_adm/unix/make_common_starter.am + +mypkgpythondir =$(salomepypkgdir)/kernel + +mypkgpython_PYTHON = \ + __init__.py \ + deprecation.py \ + logger.py \ + studyedit.py \ + termcolor.py \ + logconfig.py diff --git a/src/KERNEL_PY/kernel/__init__.py b/src/KERNEL_PY/kernel/__init__.py new file mode 100644 index 000000000..7527b3e7b --- /dev/null +++ b/src/KERNEL_PY/kernel/__init__.py @@ -0,0 +1,2 @@ +# -*- coding: iso-8859-1 -*- +__all__ = [ "deprecation", "logger", "termcolor", "studyedit", "logconfig" ] diff --git a/src/KERNEL_PY/kernel/deprecation.py b/src/KERNEL_PY/kernel/deprecation.py new file mode 100644 index 000000000..4a7ae671d --- /dev/null +++ b/src/KERNEL_PY/kernel/deprecation.py @@ -0,0 +1,115 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2007-2009 EDF R&D +# +# This file is part of PAL_SRC. +# +# PAL_SRC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# PAL_SRC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with PAL_SRC; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +""" +This module provides several functions to indicate the deprecation of a +module, a method or a function. +""" + +import sys +import warnings +import inspect +import os + +from salome.kernel import termcolor + +msg_seedoc = "See documentation for possible replacements." + +def __deprecated_with_msg(func, msg): + + def new_func(*args, **kwargs): + if len(inspect.stack()) > 1: + callingfunc = inspect.stack()[1][3] + else: + callingfunc = "CORBA middleware" + warnings.warn( + ("Call to deprecated function %(funcname)s of module " + + "%(modname)s (called from %(callingfunc)s).\n %(msg)s") % { + 'funcname': func.__name__, + 'modname': func.__module__, + 'callingfunc': callingfunc, + 'msg': msg, + }, + category = DeprecationWarning, + stacklevel = 2 + ) + return func(*args, **kwargs) + return new_func + +def deprecated(msg = msg_seedoc): + """ + This is a decorator which can be used to mark functions + as deprecated. It will result in a warning being emitted + when the function is used. The message in parameter will + be displayed and should indicate how this function can be + replaced. If the terminal can display colors, the warning + messages will appear in blue. + """ + def make_dep(f): + if is_called_by_sphinx(): + return f + else: + g = __deprecated_with_msg(f, msg) + g.__name__ = f.__name__ + g.__doc__ = f.__doc__ + g.__dict__.update(f.__dict__) + return g + return make_dep + +def deprecated_module(msg = msg_seedoc): + """ + This function can be used to mark a module as deprecated. + It must be called explicitly at the beginning of the deprecated + module. It will result in a warning being emitted. The message + in parameter will be displayed and should indicate how this + module can be replaced. If the terminal can display colors, + the warning messages will appear in blue. + """ + if not is_called_by_sphinx(): + warnings.warn( + "Importation of deprecated module %(modname)s.\n %(msg)s" % { + 'modname': inspect.getmodulename(inspect.stack()[1][1]), + 'msg': msg, + }, + category = DeprecationWarning, + stacklevel = 5 + ) + +def is_called_by_sphinx(): + """ + Determine if the calling code is ultimately called by sphinx to generate + documentation. The result can be used to conditionally inhibit the + decorators or some Salome-related imports that fail when called outside + Salome. + """ + calling_file = inspect.stack()[len(inspect.stack())-1][1] + basename = os.path.basename(calling_file) + return (basename == "sphinx-build") + + +def __show_colored_warning(message, category, filename, + lineno, file = sys.stderr): + str = warnings.formatwarning(message, category, filename, lineno) + if category == DeprecationWarning and termcolor.canDisplayColor(file): + file.write(termcolor.makeColoredMessage(str, termcolor.BLUE)) + else: + file.write(str) + +warnings.showwarning = __show_colored_warning diff --git a/src/KERNEL_PY/kernel/logconfig.py.in b/src/KERNEL_PY/kernel/logconfig.py.in new file mode 100755 index 000000000..5f3a9d0a8 --- /dev/null +++ b/src/KERNEL_PY/kernel/logconfig.py.in @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2007-2009 EDF R&D +# +# This file is part of PAL_SRC. +# +# PAL_SRC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# PAL_SRC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with PAL_SRC; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +""" +This module defines a variable to indicate which traces should be logged. +""" + +import logging + +loggingLevel = logging.@PYLOGLEVEL@ diff --git a/src/KERNEL_PY/kernel/logger.py b/src/KERNEL_PY/kernel/logger.py new file mode 100644 index 000000000..e4165c3d6 --- /dev/null +++ b/src/KERNEL_PY/kernel/logger.py @@ -0,0 +1,230 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2007-2009 EDF R&D +# +# This file is part of PAL_SRC. +# +# PAL_SRC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# PAL_SRC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with PAL_SRC; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# + +#============================================================================= +# Author : Guillaume Boulant (CSSI) +# Rewritten by Renaud Barate (EDF R&D) +# Project : SALOME +# Copyright : EDF 2001-2009 +# $Header$ +#============================================================================= +""" +This module defines a class which provides logging facility in Salome: +""" + +import sys, os +import logging + +from salome.kernel.deprecation import deprecated +from salome.kernel import termcolor +import salome.kernel.logconfig + +class Logger(logging.Logger): + """ + This class formats and displays log messages in Salome environment. It + inherits :class:`Logger` class defined in :mod:`logging` + module from Python library, so all methods from :class:`logging.Logger` + can be used here. The format of the traces is: + + LEVEL [keyword] : Message + + where `LEVEL` is the level of the message (`DEBUG`, `INFO`, etc.), + `keyword` is the name of the logger, and `Message` is the message to log. + + When creating a new Logger object, the parameter `keyword` defines the + name of the logger, `level` defines the logging level (default is + :const:`logging.DEBUG` if KERNEL module is configured with --enable-debug + option or :const:`logging.WARNING` otherwise), and `color` defines the color + of the log messages for this logger (log messages will appear in color + only when displayed on color-capable ASCII terminals). See module + :mod:`salome.kernel.termcolor` for the color constants. + + By default, log messages will be displayed only on standard output. They + can also be recorded in a file (see method :meth:`setLogFile`). For now, + the CORBA-based logging facility can not be used through this class. + + A source filename `sourceFileName` can be defined. If this argument is + specified, then the `keyword` is modified to the basename of the `sourceFileName` + + Basic usage:: + + from salome.kernel.logger import Logger + log = Logger("Test") + log.debug("Debug message") + log.info("Information message") + log.warning("Warning message") + log.error("Error message") + log.critical("Fatal error message") + + """ + + def __init__(self, keyword = "KEY", level = salome.kernel.logconfig.loggingLevel, + color = None, sourceFileName=None): + + if sourceFileName is not None: + keyword = os.path.basename(sourceFileName).split('.')[0] + logging.Logger.__init__(self, keyword, level) + self._baseFormatString = "%(levelname)-8s [%(name)s] : %(message)s" + self._baseFormatter = logging.Formatter(self._baseFormatString) + if hasattr(sys.stdout, "flush"): + self._stdoutStream = sys.stdout + else: + self._stdoutStream = _UnFlushableLogStream(sys.stdout) + self._stdoutHandler = logging.StreamHandler(self._stdoutStream) + self._stdoutHandler.setLevel(logging.DEBUG) + self.setColor(color) + self.addHandler(self._stdoutHandler) + self._fileHandler = None + + def showDebug(self): + """ + Log all messages, including DEBUG level messages (equivalent to + ``setLevel(logging.DEBUG)``). + """ + self.setLevel(logging.DEBUG) + + def setLogFile(self, logFilename): + """ + Define a log file to record the log messages (in addition to the + standard output). + """ + self.closeLogFile() + self._fileHandler = logging.FileHandler(logFilename, 'w') + self._fileHandler.setLevel(logging.DEBUG) + self._fileHandler.setFormatter(self._baseFormatter) + self.addHandler(self._fileHandler) + + def setColor(self, color): + """ + Set the color of log messages on color-capable terminals. If `color` + is :const:`None`, the default color will be used. + """ + if color is None or not termcolor.canDisplayColor(self._stdoutStream): + stdoutFormatter = self._baseFormatter + else: + format = ("%s%s%s" % + (termcolor.getControlSequence(color), + self._baseFormatString, + termcolor.getControlSequence(termcolor.DEFAULT))) + stdoutFormatter = logging.Formatter(format) + self._stdoutHandler.setFormatter(stdoutFormatter) + + def closeLogFile(self): + """Close the log file.""" + if self._fileHandler is not None: + self.removeHandler(self._fileHandler) + self._fileHandler.close() + self._fileHandler = None + + def hideDebug(self): + """ + Hide DEBUG level messages (equivalent to ``setLevel(logging.INFO)``). + """ + self.setLevel(logging.INFO) + + @deprecated("Deprecated since version 5.1.5. Please replace with " + "Logger.critical(message)") + def fatal(self, message): + """ + Log a message with CRITICAL level. This method only exists for + backward compatibility and is equivalent to ``critical(message)``. + """ + self.critical(message) + + +class _UnFlushableLogStream: + """ + This utility class allows to log messages to a stream with no `flush` + method. This is useful to send log messages to `PyOut` objects. + """ + + def __init__(self, stream): + self._stream = stream + + def write(self, msg): + self._stream.write(msg) + + def flush(self): + pass + + +class ExtLogger(Logger): + """ + This class extends :class:`Logger` class and adds exception information + when DEBUG messages are recorded. It exists mainly for backward + compatibility, as the same thing can be done by calling + ``Logger.debug(message, exc_info = True)``. + """ + + @deprecated("Class ExtLogger is deprecated since version 5.1.5. See " + "documentation for replacement.") + def __init__(self, keyword = "KEY", + level = salome.kernel.logconfig.loggingLevel, + color = None, sourceFileName=None): + Logger.__init__(self, keyword, level, color, sourceFileName) + + def debug( self, message ): + """ + Log a DEBUG message with exception information (equivalent to + ``Logger.debug(message, exc_info = True)``). + """ + Logger.debug(self, message, exc_info = True) + + +def TEST_Logger(): + """Test function for logger module""" + log = Logger("TST") + + # Base methods + log.info("Information message") + log.debug("Debug message") + log.fatal("Fatal error message") + + # Message building + data = 12 + log.info("This message displays data = " + str(data)) + + data = {} + data["KERNEL"] = "V1" + data["GEOM"] = "V2" + log.info("This message displays data = " + str(data)) + + # Test with a non-string parameter + log.info(data) + + # Test with a default instance + log = Logger() + log.info("Default logger") + + # Test showDebug method + log.setLogFile("test.log") + log.debug("Debug trace") + log.hideDebug() + log.debug("This trace should NOT be displayed") + log.showDebug() + log.debug("This trace should be displayed") + log.closeLogFile() + log.info("After closing the log file") + + +# Main function only used to test the module +if __name__ == "__main__": + TEST_Logger() diff --git a/src/KERNEL_PY/kernel/studyedit.py b/src/KERNEL_PY/kernel/studyedit.py new file mode 100644 index 000000000..09e41c360 --- /dev/null +++ b/src/KERNEL_PY/kernel/studyedit.py @@ -0,0 +1,487 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2007-2009 EDF R&D +# +# This file is part of PAL_SRC. +# +# PAL_SRC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# PAL_SRC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with PAL_SRC; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +""" +This module provides a new class :class:`StudyEditor` to complement +:class:`Study` and :class:`StudyBuilder` classes. +""" + +import re + +import salome +from salome.kernel.logger import Logger +from salome.kernel import termcolor +logger = Logger("salome.kernel.studyedit", color = termcolor.PURPLE) + +_editors = {} +_DEFAULT_CONTAINER = "FactoryServer" + +def getActiveStudyId(): + """ + Return the ID of the active study. In GUI mode, this function is equivalent + to ``salome.sg.getActiveStudyId()``. Outside GUI, it returns + ``salome.myStudyId`` variable. + """ + salome.salome_init() + if salome.hasDesktop(): + return salome.sg.getActiveStudyId() + else: + return salome.myStudyId + +def getStudyEditor(studyId = None): + """ + Return a :class:`StudyEditor` instance to edit the study with ID + `studyId`. If `studyId` is :const:`None`, return an editor for the current + study. + """ + if studyId is None: + studyId = getActiveStudyId() + if not _editors.has_key(studyId): + _editors[studyId] = StudyEditor(studyId) + return _editors[studyId] + + +class StudyEditor: + """ + This class provides utility methods to complement :class:`Study` and + :class:`StudyBuilder` classes. Those methods may be moved in those classes + in the future. The parameter `studyId` defines the ID of the study to + edit. If it is :const:`None`, the edited study will be the current study. + The preferred way to get a StudyEditor object is through the method + :meth:`getStudyEditor` which allows to reuse existing instances. + + .. attribute:: studyId + + This instance attribute contains the ID of the edited study. This + attribute should not be modified. + + .. attribute:: study + + This instance attribute contains the underlying :class:`Study` object. + It can be used to access the study but the attribute itself should not + be modified. + + .. attribute:: builder + + This instance attribute contains the underlying :class:`StudyBuilder` + object. It can be used to edit the study but the attribute itself + should not be modified. + + """ + def __init__(self, studyId = None): + salome.salome_init() + if studyId is None: + studyId = getActiveStudyId() + self.studyId = studyId + self.study = salome.myStudyManager.GetStudyByID(studyId) + if self.study is None: + raise Exception("Can't create StudyEditor object: " + "Study %d doesn't exist" % studyId) + self.builder = self.study.NewBuilder() + + def findOrCreateComponent(self, moduleName, componentName = None, + icon = None, containerName = _DEFAULT_CONTAINER): + """ + Find a component corresponding to the Salome module `moduleName` in + the study. If none is found, create a new component and associate it + with the corresponding engine (i.e. the engine named `moduleName`). + Note that in Salome 5, the module name and engine name must be + identical (every module must provide an engine with the same name). + In Salome 6 it will be possible to define a different name for the + engine. + + :type moduleName: string + :param moduleName: name of the module corresponding to the component + (the module name is the string value in the + attribute "AttributeComment" of the component) + + :type componentName: string + :param componentName: name of the new component if created. If + :const:`None`, use `moduleName` instead. + + :type icon: string + :param icon: icon for the new component (attribute "AttributePixMap"). + + :type containerName: string + :param containerName: name of the container in which the engine should be + loaded. + + :return: the SComponent found or created. + + """ + sComponent = self.study.FindComponent(moduleName) + if sComponent is None: + sComponent = self.builder.NewComponent(moduleName) + # Note that the NewComponent method set the "comment" attribute to the + # value of its argument (moduleName here) + if componentName is None: + componentName = moduleName + self.builder.SetName(sComponent, componentName) + if icon is not None: + # _MEM_ : This will be effective if and only if "moduleName" + # really corresponds to the module name (as specified in the + # SalomeApp.xml) + self.setIcon(sComponent, icon) + + # This part will stay inactive until Salome 6. In Salome 6, the + # engine name will be stored separately from the module name. + # An internal convention (in this class) is to store the name of the + # associated engine in the parameter attribute of the scomponent (so that + # it could be retrieved in a future usage of this scomponent, for example, + # for the need of the function loadComponentEngine). The comment attribute + # SHOULD NOT be used for this purpose because it's used by the SALOME + # resources manager to identify the SALOME module and then localized + # the resource files + #attr = self.builder.FindOrCreateAttribute( sComponent, "AttributeParameter" ) + #attr.SetString( "ENGINE_NAME", engineName ) + + engine = salome.lcc.FindOrLoadComponent(containerName, moduleName) + if engine is None: + raise Exception("Cannot load engine %s in container %s. See " + "logs of container %s for more details." % + (moduleName, containerName, containerName)) + self.builder.DefineComponentInstance(sComponent, engine) + + return sComponent + + def loadComponentEngine(self, sComponent, + containerName = _DEFAULT_CONTAINER): + """ + Load the engine corresponding to `sComponent` in the container + `containerName`, associate the engine with the component and load the + CORBA objects of this component in the study. + """ + # This part will stay inactive until Salome 6. In Salome 6, the + # engine name will be stored separately from the module name. + #attr = self.builder.FindOrCreateAttribute( sComponent, "AttributeParameter" ) + #engineName = attr.GetString( "ENGINE_NAME" ) + engine = salome.lcc.FindOrLoadComponent(containerName, + sComponent.GetComment()) + if engine is None: + raise Exception("Cannot load component %s in container %s. See " + "logs of container %s for more details." % + (sComponent.GetComment(), containerName, + containerName)) + self.builder.LoadWith(sComponent, engine) + + def getOrLoadObject(self, item): + """ + Get the CORBA object associated with the SObject `item`, eventually by + first loading it with the corresponding engine. + """ + object = item.GetObject() + if object is None: # the engine has not been loaded yet + sComponent = item.GetFatherComponent() + self.loadComponentEngine(sComponent) + object = item.GetObject() + return object + + def findOrCreateItem(self, fatherItem, name, fileType = None, + fileName = None, comment = None, icon = None, + IOR = None, typeId = None): + """ + Find an object under `fatherItem` in the study with the given + attributes. Return the first one found if at least one exists, + otherwise create a new one with the given attributes and return it. + + See :meth:`setItem` for the description of the parameters. + """ + sObject = self.findItem(fatherItem, name, fileType, fileName, comment, + icon, IOR, typeId) + if sObject is None: + sObject = self.createItem(fatherItem, name, fileType, fileName, + comment, icon, IOR, typeId) + return sObject + + def findItem(self, fatherItem, name = None, fileType = None, + fileName = None, comment = None, icon = None, IOR = None, + typeId = None): + """ + Find an item with given attributes under `fatherItem` in the study. If + none is found, return :const:`None`. If several items correspond to + the parameters, only the first one is returned. The search is made + only on given parameters (i.e. not :const:`None`). To look explicitly + for an empty attribute, use an empty string in the corresponding + parameter. + + See :meth:`setItem` for the description of the parameters. + """ + foundItem = None; + childIterator = self.study.NewChildIterator(fatherItem) + while childIterator.More() and foundItem is None: + childItem = childIterator.Value() + if childItem and \ + (name is None or childItem.GetName() == name) and \ + (fileType is None or \ + self.getFileType(childItem) == fileType) and \ + (fileName is None or \ + self.getFileName(childItem) == fileName) and \ + (comment is None or childItem.GetComment() == comment) and \ + (icon is None or \ + self.getIcon(childItem) == icon) and \ + (IOR is None or childItem.GetIOR() == IOR) and \ + (typeId is None or \ + self.getTypeId(childItem) == typeId): + foundItem = childItem + childIterator.Next() + return foundItem + + def createItem(self, fatherItem, name, fileType = None, fileName = None, + comment = None, icon = None, IOR = None, typeId = None): + """ + Create a new object named `name` under `fatherItem` in the study, with + the given attributes. If an object named `name` already exists under + the father object, the new object is created with a new name `name_X` + where X is the first available index. + + :type fatherItem: SObject + :param fatherItem: item under which the new item will be added. + + :return: new SObject created in the study + + See :meth:`setItem` for the description of the other parameters. + """ + aSObject = self.builder.NewObject(fatherItem) + + aChildIterator = self.study.NewChildIterator(fatherItem) + aMaxId = -1 + aLength = len(name) + aDelim = "_" + anIdRE = re.compile("^" + aDelim + "[0-9]+") + aNameRE = re.compile("^" + name) + while aChildIterator.More(): + aSObj = aChildIterator.Value() + aChildIterator.Next() + aName = aSObj.GetName() + if re.match(aNameRE,aName): + aTmp = aName[aLength:] + if re.match(anIdRE,aTmp): + import string + anId = string.atol(aTmp[1:]) + if aMaxId < anId: + aMaxId = anId + pass + pass + elif aMaxId < 0: + aMaxId = 0 + pass + pass + pass + + aMaxId = aMaxId + 1 + aName = name + if aMaxId > 0: + aName = aName + aDelim + str(aMaxId) + pass + + self.setItem(aSObject, aName, fileType, fileName, comment, icon, + IOR, typeId) + + return aSObject + + def setItem(self, item, name = None, fileType = None, fileName = None, + comment = None, icon = None, IOR = None, typeId = None): + """ + Modify the attributes of an item in the study. Unspecified attributes + (i.e. those set to :const:`None`) are left unchanged. + + :type item: SObject + :param item: item to modify. + + :type name: string + :param name: item name (attribute 'AttributeName'). + + :type fileType: string + :param fileType: item file type (attribute 'AttributeFileType'). + + :type fileName: string + :param fileName: item file name (attribute + 'AttributeExternalFileDef'). + + :type comment: string + :param comment: item comment (attribute 'AttributeComment'). Note that + this attribute will appear in the 'Value' column in + the object browser. + + :type icon: string + :param icon: item icon name (attribute 'AttributePixMap'). + + :type IOR: string + :param IOR: IOR of a CORBA object associated with the item + (attribute 'AttributeIOR'). + + :type typeId: integer + :param typeId: item type (attribute 'AttributeLocalID'). + """ + logger.debug("setItem (ID=%s): name=%s, fileType=%s, fileName=%s, " + "comment=%s, icon=%s, IOR=%s" % + (item.GetID(), name, fileType, fileName, comment, + icon, IOR)) + # Explicit cast is necessary for unicode to string conversion + if name is not None: + self.builder.SetName(item, str(name)) + if fileType is not None: + self.setFileType(item, fileType) + if fileName is not None: + self.setFileName(item, fileName) + if comment is not None: + self.builder.SetComment(item, str(comment)) + if icon is not None: + self.setIcon(item, icon) + if IOR is not None: + self.builder.SetIOR(item, str(IOR)) + if typeId is not None: + self.setTypeId(item, typeId) + + def removeItem(self, item, withChildren = False ): + """ + Remove the given item from the study. Note that the items are never + really deleted. They just don't appear in the study anymore. + + :type item: SObject + :param item: the item to be removed + + :type withChildren: boolean + :param withChildren: if :const:`True`, also remove the children of + `item` + + :return: :const:`True` if the item was removed successfully, or + :const:`False` if an error happened. + """ + ok = False + try: + if withChildren: + self.builder.RemoveObjectWithChildren(item) + else: + self.builder.RemoveObject(item) + ok = True + except: + ok = False + return ok + + def setItemAtTag(self, fatherItem, tag, name = None, fileType = None, + fileName = None, comment = None, icon = None, IOR = None, + typeId = None): + """ + Find an item tagged `tag` under `fatherItem` in the study tree or + create it if there is none, then set its attributes. + + :type fatherItem: SObject + :param fatherItem: item under which the tagged item will be looked for + and eventually created. + + :type tag: integer + :param tag: tag of the item to look for. + + :return: the SObject at `tag` if found or created successfully, or + :const:`None` if an error happened. + + See :meth:`setItem` for the description of the other parameters. + """ + found, sObj = fatherItem.FindSubObject(tag) + if not found: + sObj = self.builder.NewObjectToTag(fatherItem, tag) + self.setItem(sObj, name, fileType, fileName, comment, icon, + IOR, typeId) + return sObj + + def getAttributeValue(self, sObject, attributeName, default = None): + """ + Return the value of the attribute named `attributeName` on the object + `sObject`, or `default` if the attribute doesn't exist. + """ + value = default + found, attr = self.builder.FindAttribute(sObject, attributeName) + if found: + value = attr.Value() + return value + + def setAttributeValue(self, sObject, attributeName, attributeValue): + """ + Set the value of the attribute named `attributeName` on the object + `sObject` to the value `attributeValue`. + """ + attr = self.builder.FindOrCreateAttribute(sObject, attributeName) + attr.SetValue(attributeValue) + + def getTypeId(self, sObject): + """ + Return the value of the attribute "AttributeLocalID" of the object + `sObject`, or :const:`None` if it is not set. + """ + return self.getAttributeValue(sObject, "AttributeLocalID") + + def setTypeId(self, sObject, value): + """ + Set the attribute "AttributeLocalID" of the object `sObject` to the + value `value`. + """ + self.setAttributeValue(sObject, "AttributeLocalID", value) + + def getFileType(self, sObject): + """ + Return the value of the attribute "AttributeFileType" of the object + `sObject`, or an empty string if it is not set. + """ + return self.getAttributeValue(sObject, "AttributeFileType", "") + + def setFileType(self, sObject, value): + """ + Set the attribute "AttributeFileType" of the object `sObject` to the + value `value`. + """ + # Explicit cast is necessary for unicode to string conversion + self.setAttributeValue(sObject, "AttributeFileType", str(value)) + + def getFileName(self, sObject): + """ + Return the value of the attribute "AttributeExternalFileDef" of the + object `sObject`, or an empty string if it is not set. + """ + return self.getAttributeValue(sObject, "AttributeExternalFileDef", "") + + def setFileName(self, sObject, value): + """ + Set the attribute "AttributeExternalFileDef" of the object `sObject` + to the value `value`. + """ + # Explicit cast is necessary for unicode to string conversion + self.setAttributeValue(sObject, "AttributeExternalFileDef", + str(value)) + + def getIcon(self, sObject): + """ + Return the value of the attribute "AttributePixMap" of the object + `sObject`, or an empty string if it is not set. + """ + value = "" + found, attr = self.builder.FindAttribute(sObject, "AttributePixMap") + if found and attr.HasPixMap(): + value = attr.GetPixMap() + return value + + def setIcon(self, sObject, value): + """ + Set the attribute "AttributePixMap" of the object `sObject` to the + value `value`. + """ + attr = self.builder.FindOrCreateAttribute(sObject, "AttributePixMap") + # Explicit cast is necessary for unicode to string conversion + attr.SetPixMap(str(value)) diff --git a/src/KERNEL_PY/kernel/termcolor.py b/src/KERNEL_PY/kernel/termcolor.py new file mode 100644 index 000000000..9d584afc8 --- /dev/null +++ b/src/KERNEL_PY/kernel/termcolor.py @@ -0,0 +1,150 @@ +# -*- coding: utf-8 -*- +# +# Copyright (C) 2007-2009 EDF R&D +# +# This file is part of PAL_SRC. +# +# PAL_SRC is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# PAL_SRC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with PAL_SRC; if not, write to the Free Software +# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +# +# Author : Renaud Barate (EDF R&D) +# Date : August 2009 +# +""" +This module provides utility functions to display colored text in the +terminal. It is based on ISO 6429 standard that defines control codes to +change characters representation in color-capable ASCII terminals. + +In this module, colors are represented as lists of codes, so they can be added +to obtain special effects (e.g. RED + GREEN_BG to display red text on green +background). Several constants are defined for the most usual codes to +facilitate the use of colors, but it is also possible to define colors +directly from the corresponding code from ISO 6429 standard. In fact it is +even necessary for less usual codes that don't have an associated constant +(e.g. PURPLE + ['09'] can be used to display a crossed-out purple text). + +Example:: + + import sys + from pal import termcolor + if termcolor.canDisplayColor(sys.stdout): + print termcolor.makeColoredMessage("Hello world!", termcolor.BLUE) + else: + print "Hello world!" + +""" + +# Constants for color codes +DEFAULT = ['00'] +"""Default color for the terminal""" +BOLD = ['01'] +"""Bold text and brighter colors""" +UNDERLINED = ['04'] +"""Underlined text""" +BLACK_FG = ['30'] +"""Black foreground""" +RED_FG = ['31'] +"""Red foreground""" +GREEN_FG = ['32'] +"""Green foreground""" +YELLOW_FG = ['33'] +"""Yellow foreground""" +BLUE_FG = ['34'] +"""Blue foreground""" +PURPLE_FG = ['35'] +"""Purple foreground""" +CYAN_FG = ['36'] +"""Cyan foreground""" +WHITE_FG = ['37'] +"""White foreground""" +BLACK_BG = ['40'] +"""Black background""" +RED_BG = ['41'] +"""Red background""" +GREEN_BG = ['42'] +"""Green background""" +YELLOW_BG = ['43'] +"""Yellow background""" +BLUE_BG = ['44'] +"""Blue background""" +PURPLE_BG = ['45'] +"""Purple background""" +CYAN_BG = ['46'] +"""Cyan background""" +WHITE_BG = ['47'] +"""White background""" + +# Constants for common colored text +BLACK = BLACK_FG +"""Black text (equivalent to BLACK_FG)""" +RED = BOLD + RED_FG +"""Red text (equivalent to BOLD + RED_FG)""" +GREEN = BOLD + GREEN_FG +"""Green text (equivalent to BOLD + GREEN_FG)""" +YELLOW = BOLD + YELLOW_FG +"""Yellow text (equivalent to BOLD + YELLOW_FG)""" +BLUE = BOLD + BLUE_FG +"""Blue text (equivalent to BOLD + BLUE_FG)""" +PURPLE = BOLD + PURPLE_FG +"""Purple text (equivalent to BOLD + PURPLE_FG)""" +CYAN = BOLD + CYAN_FG +"""Cyan text (equivalent to BOLD + CYAN_FG)""" +WHITE = WHITE_FG +"""White text (equivalent to WHITE_FG)""" + + +def canDisplayColor(stream): + """ + Return True if the stream can display colored text, False otherwise. + """ + return hasattr(stream, "isatty") and stream.isatty() + +def getControlSequence(color): + """ + Return the control sequence for the color in parameter, i.e. the string + telling the terminal to display the following text in the given color. + """ + seq = "\x1b[" + for i in range(len(color)): + seq += color[i] + if i < len(color)-1: + seq += ";" + seq += "m" + return seq + +def makeColoredMessage(message, color): + """ + Return a string that can be used to display the message in parameter with + the given color. + """ + return (getControlSequence(color) + + str(message) + + getControlSequence(DEFAULT)) + +def TEST_termcolor(): + """Test function for termcolor module.""" + import sys + if not canDisplayColor(sys.stdout): + print "Standard output does not support colors." + return + print makeColoredMessage("This message must appear in blue.", BLUE) + print makeColoredMessage("This message must appear in red on green " + + "background.", RED + GREEN_BG) + print makeColoredMessage("This message must appear in magenta and " + + "crossed-out.", PURPLE + ['09']) + + +# Main function only used to test the module +if __name__ == "__main__": + TEST_termcolor() diff --git a/src/KERNEL_PY/salome.py b/src/KERNEL_PY/salome.py index 2ffceb179..8fca332b5 100755 --- a/src/KERNEL_PY/salome.py +++ b/src/KERNEL_PY/salome.py @@ -21,6 +21,14 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +# ================================================================================ +# WARNING: this file is deprecated and should not be used any more. It has been +# replaced by the file __init__.py of the python package named "salome". +# To prevent any error, a warning is raised in the case where this file is imported +raise RuntimeError("WRN - the file salome.py is deprecated. It should NOT be used any more.") +# ================================================================================ + + # File : salome.py # Author : Paul RASCLE, EDF # Module : SALOME @@ -82,7 +90,7 @@ variables: # \param salome.myStudyId : active Study Id # \param salome.myStudy : the active Study (interface SALOMEDS::Study) - +# from salome_kernel import * from salome_study import * from salome_iapp import * diff --git a/src/Launcher/Launcher_Job_SALOME.cxx b/src/Launcher/Launcher_Job_SALOME.cxx index 5d0e16b2d..d11057b51 100644 --- a/src/Launcher/Launcher_Job_SALOME.cxx +++ b/src/Launcher/Launcher_Job_SALOME.cxx @@ -77,7 +77,7 @@ Launcher::Job_SALOME::buildSalomeScript(Batch::Parametre params) resource_protocol = "rsh"; launch_script_stream << "if [ \"x$LIBBATCH_NODEFILE\" != \"x\" ]; then " << std::endl; - launch_script_stream << "CATALOG_FILE=" << work_directory << "/CatalogResources_" << _launch_date << ".xml" << std::endl; + launch_script_stream << "CATALOG_FILE=" << "CatalogResources_" << _launch_date << ".xml" << std::endl; launch_script_stream << "export USER_CATALOG_RESOURCES_FILE=" << "$CATALOG_FILE" << std::endl; launch_script_stream << "echo '' > $CATALOG_FILE" << std::endl; launch_script_stream << "echo '' >> $CATALOG_FILE" << std::endl; diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index 4c5c24360..e616e68aa 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -498,14 +498,10 @@ int SALOME_LifeCycleCORBA::NbProc(const Engines::ContainerParameters& params) { if( !isMpiContainer(params) ) return 0; - else if( (params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0) ) + else if( params.nb_proc <= 0 ) return 1; - else if( params.resource_params.nb_node == 0 ) - return params.resource_params.nb_proc_per_node; - else if( params.resource_params.nb_proc_per_node == 0 ) - return params.resource_params.nb_node; else - return params.resource_params.nb_node * params.resource_params.nb_proc_per_node; + return params.nb_proc; } //============================================================================= diff --git a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py index 57bcebff5..cb19f164a 100644 --- a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py +++ b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py @@ -41,12 +41,17 @@ class LifeCycleCORBA (SALOME_LifeCycleCORBA): componentName) class MachineParameters (Engines.MachineParameters): - def __init__(self, container_name='', hostname='', componentList=[], computerList=[], OS='', - mem_mb=0, cpu_clock=0, nb_proc_per_node=0, nb_node=0, isMPI=False, workingdir='', - mode='start', policy='altcycl', parallelLib='', nb_component_nodes=0): - Engines.MachineParameters.__init__(self,container_name, hostname, componentList, computerList, OS, - mem_mb, cpu_clock, nb_proc_per_node, nb_node, isMPI, workingdir, - mode, policy, parallelLib, nb_component_nodes) + def __init__(self, container_name='', hostname='', componentList=[], computerList=[], OS='', + mem_mb=0, cpu_clock=0, nb_proc_per_node=0, nb_node=0, isMPI=False, workingdir='', + mode='start', policy='altcycl', parallelLib='', nb_component_nodes=0): + Engines.MachineParameters.__init__(self,container_name, hostname, componentList, computerList, OS, + mem_mb, cpu_clock, nb_proc_per_node, nb_node, isMPI, workingdir, + mode, policy, parallelLib, nb_component_nodes) + +class ContainerParameters (Engines.ContainerParameters): + def __init__(self, container_name='', mode='start', workingdir='', nb_proc=0, isMPI=False, parallelLib='',resource_params=None): + if resource_params is None:resource_params=ResourceParameters() + Engines.ContainerParameters.__init__(self,container_name, mode, workingdir, nb_proc, isMPI, parallelLib,resource_params) class ResourceParameters (Engines.ResourceParameters): def __init__(self, name="", hostname="", OS="", componentList=[], diff --git a/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py b/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py index 4e7b68d8f..dde270f3d 100644 --- a/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py +++ b/src/LifeCycleCORBA_SWIG/Test/testcontainermanager.py @@ -42,35 +42,33 @@ Test with catalog : def test0(self): """""" - p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="start", - policy="best",componentList=["PYHELLO"]) - co=cm.StartContainer( p ) - print "Container:",co,co.getHostName(), co.getPID(),co._get_name() + rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"]) + p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="start",resource_params=rp) + co=cm.GiveContainer( p ) self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer") - co=cm.StartContainer( p ) + co=cm.GiveContainer( p ) self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer") def test1(self): """""" - p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="get", - policy="best",componentList=["PYHELLO"]) - co=cm.StartContainer( p ) - print "Container:",co,co.getHostName(), co.getPID(),co._get_name() + rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"]) + p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="get",resource_params=rp) + co=cm.GiveContainer( p ) self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer") - co=cm.StartContainer( p ) + co=cm.GiveContainer( p ) self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer") def test2(self): """""" - p=LifeCycleCORBA.MachineParameters(container_name="MyContainer",mode="getorstart", - policy="best",componentList=["PYHELLO"]) - co=cm.StartContainer( p ) - print "Container:",co,co.getHostName(), co.getPID(),co._get_name() + rp=LifeCycleCORBA.ResourceParameters(policy="best",componentList=["PYHELLO"]) + p=LifeCycleCORBA.ContainerParameters(container_name="MyContainer",mode="getorstart",resource_params=rp) + co=cm.GiveContainer( p ) self.assertEqual(co._get_name(), "/Containers/claui2c6/MyContainer") - co=cm.StartContainer( p ) + co=cm.GiveContainer( p ) self.assertEqual(co._get_name(), "/Containers/clt10br/MyContainer") if __name__ == '__main__': - unittest.main() + suite = unittest.TestLoader().loadTestsFromTestCase(TestContainerManager) + unittest.TextTestRunner().run(suite) diff --git a/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py b/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py index e8211ffc5..2ec086bcf 100644 --- a/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py +++ b/src/LifeCycleCORBA_SWIG/Test/testresourcemanager.py @@ -21,6 +21,7 @@ import unittest import salome import LifeCycleCORBA +import SALOME salome.salome_init() cm= salome.lcc.getContainerManager() rm= salome.lcc.getResourcesManager() @@ -49,55 +50,60 @@ Test with CatalogResources.xml: def test0(self): """host required""" - params=LifeCycleCORBA.MachineParameters(hostname="m3") + params=LifeCycleCORBA.ResourceParameters(hostname="m3") machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ["m3"]) def test1(self): """OS required""" - params=LifeCycleCORBA.MachineParameters(OS="Linux") - machineList=rm.GetFittingResources(params) - self.assertEqual(machineList, []) + params=LifeCycleCORBA.ResourceParameters(OS="Linux") + self.assertRaises(SALOME.SALOME_Exception,rm.GetFittingResources,params) def test2(self): """component add required""" - params=LifeCycleCORBA.MachineParameters(componentList=["add"]) + params=LifeCycleCORBA.ResourceParameters(componentList=["add"]) machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ['claui2c6', 'm1', 'm2']) def test3(self): """component tutu required""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["tutu"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["tutu"]) + machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ['m1', 'm2', 'm3']) def test4(self): """component tata required""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["tata"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["tata"]) + machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ['m1', 'm2']) def test5(self): """component titi required""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["titi"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["titi"]) + machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ['m1', 'm2']) def test6(self): """component toto required""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["toto"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["toto"]) + machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ['claui2c6', 'm1', 'm2']) def test7(self): """components add and toto required""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"]) + machineList=rm.GetFittingResources(params) self.assertEqual(machineList, ['claui2c6', 'm1', 'm2']) def test8(self): """components add and toto required""" - machineDef=rm.GetMachineParameters('claui2c6') + machineDef=rm.GetResourceDefinition('claui2c6') self.assertEqual(machineDef.componentList, ['toto', 'add']) def test10(self): """policy altcycl""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"]) + machineList=rm.GetFittingResources(params) self.assertEqual(rm.Find('altcycl',machineList), "claui2c6") self.assertEqual(rm.Find('altcycl',machineList), "m1") self.assertEqual(rm.Find('altcycl',machineList), "m2") @@ -107,7 +113,8 @@ Test with CatalogResources.xml: def test11(self): """policy cycl""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"]) + machineList=rm.GetFittingResources(params) self.assertEqual(rm.Find('cycl',machineList), "claui2c6") self.assertEqual(rm.Find('cycl',machineList), "m1") self.assertEqual(rm.Find('cycl',machineList), "m2") @@ -117,13 +124,15 @@ Test with CatalogResources.xml: def test12(self): """policy first""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"]) + machineList=rm.GetFittingResources(params) self.assertEqual(rm.Find('first',machineList), "claui2c6") self.assertEqual(rm.Find('first',machineList), "claui2c6") def test13(self): """policy best""" - machineList=rm.GetFittingResources(LifeCycleCORBA.MachineParameters(componentList=["add","toto"])) + params=LifeCycleCORBA.ResourceParameters(componentList=["add","toto"]) + machineList=rm.GetFittingResources(params) self.assertEqual(rm.Find('best',machineList), "claui2c6") self.assertEqual(rm.Find('best',machineList), "m1") self.assertEqual(rm.Find('best',machineList), "m2") @@ -132,5 +141,6 @@ Test with CatalogResources.xml: self.assertEqual(rm.Find('best',machineList), "m2") if __name__ == '__main__': - unittest.main() + suite = unittest.TestLoader().loadTestsFromTestCase(TestResourceManager) + unittest.TextTestRunner().run(suite) diff --git a/src/MPIContainer/MPIContainer_i.cxx b/src/MPIContainer/MPIContainer_i.cxx index e1ca6cc6b..627f398be 100644 --- a/src/MPIContainer/MPIContainer_i.cxx +++ b/src/MPIContainer/MPIContainer_i.cxx @@ -87,6 +87,7 @@ void Engines_MPIContainer_i::Shutdown() MESSAGE("[" << _numproc << "] shutdown of MPI Corba Server"); if( _numproc == 0 ){ _NS->Destroy_FullDirectory(_containerName.c_str()); + _NS->Destroy_Name(_containerName.c_str()); for(ip= 1;ip<_nbproc;ip++) (Engines::MPIContainer::_narrow((*_tior)[ip]))->Shutdown(); } diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index 80bb67144..6e4444976 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -636,14 +636,10 @@ SALOME_NamingService::ContainerName(const Engines::ContainerParameters& params) if ( !params.isMPI ) nbproc = 0; - else if ( (params.resource_params.nb_node <= 0) && (params.resource_params.nb_proc_per_node <= 0) ) + else if ( params.nb_proc <= 0 ) nbproc = 1; - else if ( params.resource_params.nb_node == 0 ) - nbproc = params.resource_params.nb_proc_per_node; - else if ( params.resource_params.nb_proc_per_node == 0 ) - nbproc = params.resource_params.nb_node; else - nbproc = params.resource_params.nb_node * params.resource_params.nb_proc_per_node; + nbproc = params.nb_proc; std::string ret = ContainerName(params.container_name); diff --git a/src/ResourcesManager/ResourcesManager.cxx b/src/ResourcesManager/ResourcesManager.cxx index a265e9f25..868ac8cb8 100644 --- a/src/ResourcesManager/ResourcesManager.cxx +++ b/src/ResourcesManager/ResourcesManager.cxx @@ -455,21 +455,21 @@ void ResourcesManager_cpp::KeepOnlyResourcesWithComponent(std::vector& resources, const std::vector& componentList) { + std::vector kept_resources; + std::vector::iterator iter = resources.begin(); for (; iter != resources.end(); iter++) { - MapOfParserResourcesType::const_iterator it = _resourcesList.find(*iter); - const std::vector& mapOfComponentsOfCurrentHost = (*it).second.ComponentsList; + const std::vector& mapOfComponentsOfCurrentHost = _resourcesList[*iter].ComponentsList; bool erasedHost = false; if( mapOfComponentsOfCurrentHost.size() > 0 ) { for(unsigned int i=0; i::const_iterator itt = find(mapOfComponentsOfCurrentHost.begin(), - mapOfComponentsOfCurrentHost.end(), - compoi); + mapOfComponentsOfCurrentHost.end(), + componentList[i]); if (itt == mapOfComponentsOfCurrentHost.end()) { erasedHost = true; @@ -477,9 +477,10 @@ ResourcesManager_cpp::KeepOnlyResourcesWithComponent(std::vector& r } } } - if(erasedHost) - resources.erase(iter); + if(!erasedHost) + kept_resources.push_back(*iter); } + resources=kept_resources; } diff --git a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx index ac6341bb6..20851ed2a 100755 --- a/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx +++ b/src/ResourcesManager/SALOME_ResourcesCatalog_Handler.cxx @@ -130,11 +130,6 @@ void SALOME_ResourcesCatalog_Handler::ProcessXmlDocument(xmlDocPtr theDoc) if(_resource.HostName == "localhost") { _resource.HostName = Kernel_Utils::GetHostname(); - if (_resource.Name == "localhost") - { - _resource.Name = Kernel_Utils::GetHostname(); - _resource.DataForSort._Name = Kernel_Utils::GetHostname(); - } } std::map::const_iterator iter = _resources_list.find(_resource.Name); if (iter != _resources_list.end()) diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 56be377dc..94e3537e0 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -678,7 +678,7 @@ SALOMEDS::UseCaseBuilder_ptr SALOMEDS_Study_i::GetUseCaseBuilder() void SALOMEDS_Study_i::Close() { SALOMEDS::Locker lock; - + RemovePostponed(-1); SALOMEDS::SComponentIterator_var itcomponent = NewComponentIterator(); @@ -756,7 +756,10 @@ void SALOMEDS_Study_i::RemovePostponed(CORBA::Long /*theUndoLimit*/) try { CORBA::Object_var obj = _orb->string_to_object(anIORs[i].c_str()); SALOME::GenericObj_var aGeneric = SALOME::GenericObj::_narrow(obj); - if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy(); + //rnv: To avoid double deletion of the Salome Generic Objects: + //rnv: 1. First decrement of the reference count in the SALOMEDSImpl_AttributeIOR::~SALOMEDSImpl_AttributeIOR(); + //rnv: 2. Second decrement of the reference count in the next string : aGeneric->Destroy(); + //if (!CORBA::is_nil(aGeneric)) aGeneric->Destroy(); } catch (...) {} } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.cxx index 72eeda9c8..ae2c2414f 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.cxx @@ -86,8 +86,7 @@ void SALOMEDSImpl_AttributeTarget::Add(const SALOMEDSImpl_SObject& theSO) DF_Label aRefLabel = theSO.GetLabel(); SALOMEDSImpl_AttributeReference* aReference; if ((aReference=(SALOMEDSImpl_AttributeReference*)aRefLabel.FindAttribute(SALOMEDSImpl_AttributeReference::GetID()))) { - for(int i = 0, len = myVariables.size(); iLabel() == aRefLabel) return; //BugID: PAL6192 - myVariables.push_back(aReference); + myVariables[aRefLabel.Entry()]=aReference; } SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved @@ -101,8 +100,8 @@ std::vector SALOMEDSImpl_AttributeTarget::Get() { std::vector aSeq; - for(int i = 0, len = myVariables.size(); iLabel())); + for (std::map< std::string , DF_Attribute* >::iterator iter = myVariables.begin(); iter != myVariables.end(); ++iter) + aSeq.push_back( SALOMEDSImpl_Study::SObject(iter->second->Label())); return aSeq; } @@ -116,15 +115,7 @@ void SALOMEDSImpl_AttributeTarget::Remove(const SALOMEDSImpl_SObject& theSO) Backup(); DF_Label aRefLabel = theSO.GetLabel(); - std::vector va; - for(int i = 0, len = myVariables.size(); iLabel(); - if(myVariables[i]->Label() == aRefLabel) continue; - va.push_back(myVariables[i]); - } - - myVariables.clear(); - myVariables = va; + myVariables.erase(aRefLabel.Entry()); SetModifyFlag(); //SRN: Mark the study as being modified, so it could be saved } @@ -144,8 +135,8 @@ void SALOMEDSImpl_AttributeTarget::Restore(DF_Attribute* With) SALOMEDSImpl_AttributeTarget* REL = dynamic_cast(With); myRelation = REL->GetRelation(); myVariables.clear(); - for (int i = 0, len = REL->myVariables.size(); imyVariables[i]); + for (std::map< std::string , DF_Attribute* >::iterator iter = REL->myVariables.begin(); iter != REL->myVariables.end(); ++iter){ + myVariables[iter->first]=iter->second; } } @@ -167,7 +158,7 @@ void SALOMEDSImpl_AttributeTarget::Paste(DF_Attribute* into) SALOMEDSImpl_AttributeTarget* REL = dynamic_cast(into); REL->SetRelation(myRelation); REL->myVariables.clear(); - for (int i = 0, len = myVariables.size(); imyVariables.push_back(myVariables[i]); + for (std::map< std::string , DF_Attribute* >::iterator iter = myVariables.begin(); iter != myVariables.end(); ++iter){ + REL->myVariables[iter->first]=iter->second; } } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.hxx index f5a1849bf..842931bc4 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTarget.hxx @@ -33,13 +33,14 @@ #include #include "SALOMEDSImpl_GenericAttribute.hxx" #include "SALOMEDSImpl_SObject.hxx" +#include class SALOMEDSIMPL_EXPORT SALOMEDSImpl_AttributeTarget : public SALOMEDSImpl_GenericAttribute { private: std::string myRelation; - std::vector myVariables; + std::map< std::string , DF_Attribute* > myVariables; public: static const std::string& GetID() ; @@ -50,7 +51,7 @@ public: void Remove(const SALOMEDSImpl_SObject& theSO); std::string GetRelation() { return myRelation; } void SetRelation(const std::string& theRelation); - std::vector& GetVariables() { return myVariables; } + std::map< std::string , DF_Attribute* >& GetVariables() { return myVariables; } const std::string& ID() const; void Restore(DF_Attribute* with) ; DF_Attribute* NewEmpty() const; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx index e6bb38616..1bd9fb353 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_ScalarVariable.cxx @@ -122,7 +122,7 @@ std::string SALOMEDSImpl_ScalarVariable::Save() const{ } case SALOMEDSImpl_GenericVariable::STRING_VAR: { - sprintf(buffer, "\"%s\"", myStrValue.c_str()); + sprintf(buffer, "%s", myStrValue.c_str()); break; } default:break; @@ -187,11 +187,15 @@ void SALOMEDSImpl_ScalarVariable::Load(const std::string& theStrValue) { Kernel_Utils::Localizer loc; + std::string strCopy = theStrValue; if ( Type() == SALOMEDSImpl_GenericVariable::STRING_VAR ) { - setStringValue( theStrValue ); +#ifdef OLDSTUDY_COMPATIBILITY + if (strCopy.size() > 1 && strCopy[0] == '\"' && strCopy[strCopy.size()-1] == '\"') + strCopy = strCopy.substr(1, strCopy.size()-2); +#endif // OLDSTUDY_COMPATIBILITY + setStringValue( strCopy ); } else { - std::string strCopy = theStrValue; #ifdef OLDSTUDY_COMPATIBILITY int dotpos = strCopy.find(','); if (dotpos != std::string::npos) diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx index 62f4e169a..2e2e012ae 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_StudyManager.cxx @@ -137,6 +137,8 @@ SALOMEDSImpl_Study* SALOMEDSImpl_StudyManager::Open(const std::string& aUrl) if (HDFascii::isASCII(aUrl.c_str())) { isASCII = true; char* aResultPath = HDFascii::ConvertFromASCIIToHDF(aUrl.c_str()); + if ( !aResultPath ) + return NULL; aC_HDFUrl = new char[strlen(aResultPath) + 19]; sprintf(aC_HDFUrl, "%shdf_from_ascii.hdf", aResultPath); delete [] (aResultPath); @@ -152,15 +154,15 @@ SALOMEDSImpl_Study* SALOMEDSImpl_StudyManager::Open(const std::string& aUrl) hdf_file->OpenOnDisk(HDF_RDONLY);// mpv: was RDWR, but opened file can be write-protected too } catch (HDFexception) - { - char *eStr; - eStr = new char[strlen(aUrl.c_str())+17]; - sprintf(eStr,"Can't open file %s",aUrl.c_str()); - delete [] eStr; - _errorCode = std::string(eStr); - return NULL; - } - + { + char *eStr; + eStr = new char[strlen(aUrl.c_str())+17]; + sprintf(eStr,"Can't open file %s",aUrl.c_str()); + delete [] eStr; + _errorCode = std::string(eStr); + return NULL; + } + // Temporary aStudyUrl in place of study name DF_Document* Doc = _appli->NewDocument("SALOME_STUDY"); @@ -186,13 +188,13 @@ SALOMEDSImpl_Study* SALOMEDSImpl_StudyManager::Open(const std::string& aUrl) BuildTree (Study, hdf_group_study_structure); } catch (HDFexception) - { - char *eStr = new char [strlen(aUrl.c_str())+17]; - sprintf(eStr,"Can't open file %s", aUrl.c_str()); - _errorCode = std::string(eStr); - return NULL; - } - + { + char *eStr = new char [strlen(aUrl.c_str())+17]; + sprintf(eStr,"Can't open file %s", aUrl.c_str()); + _errorCode = std::string(eStr); + return NULL; + } + //Read and create notebook variables if(hdf_file->ExistInternalObject("NOTEBOOK_VARIABLES")) { hdf_notebook_vars = new HDFgroup("NOTEBOOK_VARIABLES",hdf_file); @@ -770,7 +772,7 @@ bool SALOMEDSImpl_StudyManager::Impl_SaveAs(const std::string& aStudyUrl, system(aCmd.c_str()); // Iterate and move files in the temporary directory - FILE* fp = fopen(aTmpFile.c_str(), "r"); + FILE* fp = fopen(aTmpFile.c_str(), "rb"); if(!fp) return false; char* buffer = new char[2047]; while(!feof(fp)) { diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx index 7f63ea527..9cd5b05ca 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include "SALOMEDSImpl_Tool.hxx" @@ -241,24 +243,66 @@ std::vector SALOMEDSImpl_Tool::splitString(const std::string& theVa // purpose : The functions returns a list of substring of initial string // divided by given separator include empty strings //============================================================================ + +std::vector treatRepetation(const std::string& theValue); + +std::vector treatRepetation(const std::string& theValue) +{ + std::vector aResult; + int pos = theValue.find(";*="); + if(pos < 0 ) + { + aResult.push_back(theValue); + return aResult; + } + std::string val(theValue.substr(0, pos)); + std::string suffix(theValue.substr(pos+3)); + int nb; + std::istringstream tmp(suffix); + tmp >> nb; + for(int i=0; i SALOMEDSImpl_Tool::splitStringWithEmpty(const std::string& theValue, char sep) { std::vector aResult; if(theValue[0] == sep ) aResult.push_back(std::string()); int pos = theValue.find(sep); if(pos < 0 ) { - aResult.push_back(theValue); + if(sep == '|') + { + std::vector tmp = treatRepetation(theValue); + std::copy(tmp.begin(), tmp.end(), std::back_insert_iterator< std::vector >(aResult)); + } + else + aResult.push_back(theValue); return aResult; } std::string s = theValue; if(s[0] == sep) s = s.substr(1, s.size()); while((pos = s.find(sep)) >= 0) { - aResult.push_back(s.substr(0, pos)); + if(sep == '|') + { + std::vector tmp = treatRepetation(s.substr(0, pos)); + std::copy(tmp.begin(), tmp.end(), std::back_insert_iterator< std::vector >(aResult)); + } + else + aResult.push_back(s.substr(0, pos)); s = s.substr(pos+1, s.size()); } - if(!s.empty() && s[0] != sep) aResult.push_back(s); + if(!s.empty() && s[0] != sep) { + if(sep == '|') + { + std::vector tmp = treatRepetation(s); + std::copy(tmp.begin(), tmp.end(), std::back_insert_iterator< std::vector >(aResult)); + } + else + aResult.push_back(s); + } if(theValue[theValue.size()-1] == sep) aResult.push_back(std::string()); return aResult; diff --git a/src/TOOLSDS/SALOMEDS_Tool.cxx b/src/TOOLSDS/SALOMEDS_Tool.cxx index a2222ef20..b1b269454 100644 --- a/src/TOOLSDS/SALOMEDS_Tool.cxx +++ b/src/TOOLSDS/SALOMEDS_Tool.cxx @@ -330,6 +330,13 @@ SALOMEDS_Tool::PutStreamToFiles(const SALOMEDS::TMPFile& theStream, char *aFileName = new char[aFileNameSize]; //Put a file name to aFileName memcpy(aFileName, (aBuffer + aCurrentPos), aFileNameSize); +#ifdef WIN32 + for (int i = 0; i < strlen(aFileName); i++) + { + if (aFileName[i] == ':') + aFileName[i] = '_'; + } +#endif aCurrentPos += aFileNameSize; //Put a length of the file to aFileSize diff --git a/src/Utils/Utils_Identity.py b/src/Utils/Utils_Identity.py index f7a9af420..e55406a31 100644 --- a/src/Utils/Utils_Identity.py +++ b/src/Utils/Utils_Identity.py @@ -59,7 +59,7 @@ class Identity: self._adip = socket.gethostbyname(self._machine) # IP adress if sys.platform == "win32": self._uid = os.getpid() - self._pwname = os.environ["USER"] + self._pwname = os.environ["USERNAME"] else: self._uid = os.getuid() list = pwd.getpwuid(self._uid) -- 2.39.2