From 53dd782a8e750e4af654d62b34412d59b566c822 Mon Sep 17 00:00:00 2001 From: secher Date: Mon, 8 Sep 2008 14:28:39 +0000 Subject: [PATCH] after merge with V4_1_0_maintainance --- Makefile.am | 4 +- bin/Makefile.am | 78 ++-- bin/NSparam.py | 27 +- bin/addToKillList.py | 101 ++--- bin/envSalome.py | 2 +- bin/killSalome.py | 68 ++-- bin/killSalomeWithPort.py | 179 +++++---- bin/launchConfigureParser.py | 13 +- bin/nameserver.py | 15 +- bin/orbmodule.py | 3 +- bin/runNS.py | 2 +- bin/runSalome.py | 191 +++++----- bin/salome_session.py | 49 +-- bin/salome_utilities.py | 346 ++++++++++++++++++ bin/setenv.py | 114 +++--- idl/Makefile.am | 5 +- salome_adm/unix/Makefile.am | 6 +- salome_adm/unix/SALOMEconfig.ref.in | 4 + salome_adm/unix/config_files/check_cas.m4 | 3 +- src/Basics/BasicsGenericDestructor.cxx | 1 + src/Batch/Batch_Date.cxx | 2 +- src/Batch/Batch_Versatile.cxx | 2 +- src/Communication_SWIG/libSALOME_Comm.i | 22 +- src/Container/Component_i.cxx | 4 +- src/Container/Container_i.cxx | 15 +- src/Container/Container_init_python.hxx | 3 +- src/Container/SALOME_ComponentPy.py | 5 +- src/Container/SALOME_Container.cxx | 11 +- src/Container/SALOME_Container.py | 4 +- src/Container/SALOME_ContainerManager.cxx | 21 +- .../SALOME_Container_SignalsHandler.cxx | 2 + src/Container/SALOME_FileRef_i.cxx | 4 + src/Container/Salome_file_i.cxx | 4 + src/DF/testDF.cxx | 2 +- src/DSC/DSC_Python/calcium.i | 54 ++- .../Calcium/CalciumCxxInterface.hxx | 123 ++++--- .../Calcium/CalciumGenericProvidesPort.hxx | 32 +- .../Datastream/Calcium/CalciumInterface.hxx | 28 +- .../Datastream/Calcium/CalciumPortTraits.hxx | 9 +- .../Datastream/Calcium/Copy2CorbaSpace.hxx | 13 +- .../DSC_User/Datastream/Calcium/Makefile.am | 2 +- .../Datastream/Palm/test_DataIdContainer.cxx | 4 +- src/DSC/DSC_User/Datastream/fake.cc | 2 +- src/HDFPersist/HDFfile.cc | 2 +- src/HDFPersist/HDFfile.hxx | 2 +- src/HDFPersist/HDFgroup.cc | 2 +- src/HDFPersist/HDFgroup.hxx | 2 +- src/HDFPersist/HDFnObjects.c | 2 +- src/HDFPersist/HDFobject.hxx | 2 +- src/HDFPersist/HDFobjectIdentify.c | 2 +- src/HDFPersist/hdfi.h | 4 +- src/Launcher/SALOME_LauncherServer.cxx | 6 +- .../SALOME_FileTransferCORBA.cxx | 6 +- src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx | 2 +- .../Test/LifeCycleCORBATest.cxx | 4 +- src/Logger/SALOME_Trace.hxx | 1 + .../SALOME_ModuleCatalog_impl.cxx | 8 +- src/NamingService/SALOME_NamingService.cxx | 4 +- src/NamingService/SALOME_NamingServicePy.py | 52 ++- src/NamingService/Test/NamingServiceTest.cxx | 4 +- src/Registry/RegistryService.cxx | 4 + src/Registry/RegistryService.hxx | 2 +- src/Registry/SALOME_Registry_Server.cxx | 1 + src/SALOMEDS/SALOMEDS.cxx | 2 +- src/SALOMEDS/SALOMEDS_AttributeUserID.cxx | 2 +- src/SALOMEDS/SALOMEDS_GenericAttribute.cxx | 2 +- src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx | 6 +- src/SALOMEDS/SALOMEDS_SObject.cxx | 2 +- src/SALOMEDS/SALOMEDS_SObject_i.cxx | 2 +- src/SALOMEDS/SALOMEDS_Study.cxx | 2 +- src/SALOMEDS/SALOMEDS_StudyManager.cxx | 4 +- src/SALOMEDS/SALOMEDS_StudyManager_i.cxx | 4 +- src/SALOMEDS/SALOMEDS_StudyManager_i.hxx | 2 +- src/SALOMEDS/SALOMEDS_Study_i.cxx | 2 +- src/SALOMEDS/Test/SALOMEDSTest.cxx | 4 +- .../SALOMEDSImpl_AttributeIOR.cxx | 2 +- .../SALOMEDSImpl_AttributeTableOfString.cxx | 2 +- src/SALOMELocalTrace/FileTraceCollector.cxx | 4 +- src/SALOMELocalTrace/LocalTraceBufferPool.cxx | 7 +- src/SALOMELocalTrace/LocalTraceBufferPool.hxx | 2 +- src/SALOMELocalTrace/LocalTraceCollector.cxx | 4 +- .../Test/SALOMELocalTraceTest.cxx | 10 +- src/SALOMELocalTrace/utilities.h | 5 + .../SALOMETraceCollector.cxx | 4 +- .../Test/SALOMETraceCollectorTest.cxx | 4 +- .../TraceCollector_WaitForServerReadiness.cxx | 2 +- .../TraceCollector_WaitForServerReadiness.hxx | 1 + src/TestContainer/SALOME_TestComponent_i.cxx | 4 +- src/TestContainer/TestContainer.cxx | 4 + src/Utils/Test/UtilsTest.cxx | 2 +- src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx | 7 +- src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx | 2 +- src/Utils/Utils_Identity.cxx | 8 + src/Utils/Utils_SALOME_Exception.hxx | 3 + src/Utils/Utils_Timer.cxx | 2 + 95 files changed, 1205 insertions(+), 599 deletions(-) create mode 100644 bin/salome_utilities.py diff --git a/Makefile.am b/Makefile.am index d3b87e52d..a49a0cc21 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,10 +33,10 @@ ACLOCAL_AMFLAGS = -I salome_adm/unix/config_files if WITHONLYLAUNCHER SUBDIRS = src resources else - SUBDIRS = $(IDLDIR) salome_adm src doc bin resources + SUBDIRS = salome_adm $(IDLDIR) src doc bin resources endif -DIST_SUBDIRS= idl salome_adm src doc bin resources +DIST_SUBDIRS= salome_adm idl src doc bin resources DISTCLEANFILES = a.out diff --git a/bin/Makefile.am b/bin/Makefile.am index b8086e529..077743e33 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -32,40 +32,44 @@ include $(top_srcdir)/salome_adm/unix/make_common_starter.am # # These files are data, module or lib files -dist_salomescript_DATA= \ - VERSION \ - orbmodule.py \ - salomeConsole.py \ - salome_session.py +dist_salomescript_DATA = \ + config_appli.xml \ + salome.launch \ + VERSION # These files are executable scripts -dist_salomescript_SCRIPTS=\ - envSalome.py \ - runIDLparser \ - runSalome.py \ - killSalome.py \ - killSalomeWithPort.py \ - runSalome \ - runSalome.csh \ - runNS.sh \ - createAppli.sh \ - appli_install.sh \ - appli_clean.sh \ - appli_gen.py \ - virtual_salome.py \ - config_appli.xml \ - launchConfigureParser.py \ - showNS.py \ - addToKillList.py \ - NSparam.py \ - setenv.py \ - launchSalome.py \ - nameserver.py \ - server.py \ - waitNS.sh \ - waitNS.py \ - waitContainers.py \ - shutdownSalome.py +dist_salomescript_SCRIPTS = \ + addToKillList.py \ + appli_clean.sh \ + appli_gen.py \ + appli_install.sh \ + createAppli.sh \ + envSalome.py \ + killSalome.py \ + killSalomeWithPort.py \ + launchConfigureParser.py \ + launchSalome.py \ + nameserver.py \ + NSparam.py \ + orbmodule.py \ + runIDLparser \ + runNS.py \ + runNS.sh \ + runSalome \ + runSalome.csh \ + runSalome.ksh \ + runSalome.py \ + salomeConsole.py \ + salome_session.py \ + salome_utilities.py \ + server.py \ + setenv.py \ + showNS.py \ + shutdownSalome.py \ + virtual_salome.py \ + waitContainers.py \ + waitNS.py \ + waitNS.sh EXTRA_DIST = appliskel @@ -74,21 +78,17 @@ dist-hook: DISTCLEANFILES = $(top_builddir)/bin/salome/Makefile.am -clean-local: - rm -rf $(top_builddir)/bin/salome/appliskel - cd $(top_builddir)/bin/salome; \ - rm -f $(dist_salomescript_DATA) $(dist_salomescript_SCRIPTS) - # This is an ugly target to avoid exploring the appliskel subdirectory. install-exec-local: $(INSTALL) -d $(DESTDIR)$(salomescriptdir) $(RM) -rf $(DESTDIR)$(salomescriptdir)/appliskel 1> /dev/null 2>&1 cp -r $(srcdir)/appliskel $(DESTDIR)$(salomescriptdir) + chmod a+x -R $(DESTDIR)$(salomescriptdir)/appliskel find $(DESTDIR)$(salomescriptdir) -name CVS -prune -exec rm -rf {} \; uninstall-local: if test -d $(DESTDIR)$(salomescriptdir)/appliskel; then \ find $(DESTDIR)$(salomescriptdir)/appliskel -exec chmod +w {} ';' ; \ - rm -rf $(DESTDIR)$(salomescriptdir)/appliskel; \ - fi; + rm -rf $(DESTDIR)$(salomescriptdir)/appliskel; \ + fi; diff --git a/bin/NSparam.py b/bin/NSparam.py index 652e6da66..2f93c9e54 100755 --- a/bin/NSparam.py +++ b/bin/NSparam.py @@ -20,7 +20,6 @@ # import sys,os -import string def getNSparams(info=""): """ @@ -32,25 +31,8 @@ def getNSparams(info=""): elif info==port print host else print 2 strings on stdout on one line: host port """ - my_port="" - my_host="" - if os.environ.has_key("OMNIORB_CONFIG"): - file = open(os.environ["OMNIORB_CONFIG"], "r") - s = file.readline() - while len(s): - l = string.split(s, ":") - if string.split(l[0], " ")[0] == "ORBInitRef" or \ - string.split(l[0], " ")[0] == "InitRef" : - my_port = l[len(l)-1] - if my_port[-1] == '\n': - my_port = my_port[:-1] - pass - my_host = l[len(l)-2] - break; - pass - s = file.readline() - pass - pass + from salome_utilities import getORBcfgInfo + my_version, my_host, my_port = getORBcfgInfo() if info=='host': # keep print, stdout used in shell print my_host @@ -80,9 +62,10 @@ if __name__ == "__main__": getNSparams('port') pass else: - getNSparams('') + getNSparams() pass pass else: - getNSparams('') + getNSparams() pass + pass diff --git a/bin/addToKillList.py b/bin/addToKillList.py index 537dfaf3d..548a8958d 100755 --- a/bin/addToKillList.py +++ b/bin/addToKillList.py @@ -25,78 +25,87 @@ from launchConfigureParser import verbose ########## adds to the kill list of SALOME one more process ########## def findFileDict(): - if os.environ.has_key('NSPORT'): - my_port = os.environ['NSPORT'] - pass - else: - my_port = 2809 - try: - file = open(os.environ["OMNIORB_CONFIG"], "r") - s = file.read() - while len(s): - l = string.split(s, ":") - if string.split(l[0], " ")[0] == "ORBInitRef" or string.split(l[0], " ")[0] == "InitRef" : - my_port = int(l[len(l)-1]) - pass - s = file.read() - pass - pass - except: - pass - pass - if verbose(): print "myport = ", my_port - return my_port + """ + Detect current SALOME session's port number. + Returns port number. + """ + from salome_utilities import getPortNumber + port = getPortNumber() + if verbose(): print "myport = ", port + return port -def addToKillList(command_pid, command): - my_port = findFileDict() +def addToKillList(command_pid, command, port=None): + """ + Add the process to the SALOME processes dictionary file. + Parameters: + - command_pid : command PID + - command : command (string or list of strings) + - [port] : SALOME port number; if this parameter is None (default), + it is detected automatically + """ + # retrieve current processes dictionary from killSalomeWithPort import getPiDict - filedict=getPiDict(my_port) + if port is None: port=findFileDict() + filedict=getPiDict(port) try: fpid=open(filedict, 'r') process_ids=pickle.load(fpid) fpid.close() except: - process_ids=[{}] + process_ids=[] pass - - already_in=0 + # check if PID is already in dictionary + already_in=False for process_id in process_ids: - if verbose(): print process_id for pid, cmd in process_id.items(): - #print "see process %s : %s"% (pid, cmd[0]) - if pid == command_pid: - already_in=1 - pass + if int(pid) == int(command_pid): + already_in=True + break pass + if already_in: break pass - - command=(command.split(" "))[0] - if already_in == 0: + # add process to the dictionary + if not already_in: + import types + if type(command) == types.ListType: command=" ".join([str(c) for c in command]) + command=command.split()[0] try: - process_ids.append({command_pid: [command]}) - fpid=open(filedict,'w') + if verbose(): print "addToKillList: %s : %s" % ( str(command_pid), command ) + process_ids.append({int(command_pid): [command]}) + dir = os.path.dirname(filedict) + if not os.path.exists(dir): os.makedirs(dir, 0777) + fpid = open(filedict,'w') pickle.dump(process_ids, fpid) fpid.close() except: - print "addToKillList: can not add command %s to the kill list"% filedict + if verbose(): print "addToKillList: can not add command %s : %s to the kill list" % ( str(command_pid), command ) pass pass pass -def killList(): - my_port = findFileDict() +def killList(port=None): + """ + Kill all the processes listed in the SALOME processes dictionary file. + - [port] : SALOME port number; if this parameter is None (default), + it is detected automatically + """ + # retrieve processes dictionary from killSalomeWithPort import getPiDict - filedict=getPiDict(my_port) + if port is None: port=findFileDict() + # new-style dot-prefixed pidict file + filedict=getPiDict(port, hidden=True) + # provide compatibility with old-style pidict file (not dot-prefixed) + if not os.path.exists(filedict): filedict = getPiDict(port, hidden=False) try: fpid=open(filedict, 'r') process_ids=pickle.load(fpid) fpid.close() except: - process_ids=[{}] + process_ids=[] pass - + # kill processes for process_id in process_ids: - print process_id + #print process_id for pid, cmd in process_id.items(): print "stop process %s : %s"% (pid, cmd[0]) try: @@ -106,11 +115,11 @@ def killList(): pass pass pass + # remove processes dictionary file os.remove(filedict) pass - - if __name__ == "__main__": if verbose(): print sys.argv addToKillList(sys.argv[1], sys.argv[2]) + pass diff --git a/bin/envSalome.py b/bin/envSalome.py index 1d0d61cb6..ed153d41b 100755 --- a/bin/envSalome.py +++ b/bin/envSalome.py @@ -39,6 +39,6 @@ sys.argv = argv[1:] #args, modules_list, modules_root_dir = setenv.get_config() #runSalome.set_env(args, modules_list, modules_root_dir) -setenv.main(); +setenv.main(True); os.execvp(argv[0],argv) diff --git a/bin/killSalome.py b/bin/killSalome.py index 2f1388182..1c76890a9 100755 --- a/bin/killSalome.py +++ b/bin/killSalome.py @@ -19,36 +19,62 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -import os, string, sys, re +import os, sys, re, signal from killSalomeWithPort import killMyPort, getPiDict def killAllPorts(): + """ + Kill all SALOME sessions belonging to the user. + """ user = os.getenv('USER') - filedict = "^%s$"%(getPiDict('(\d*)',full=False)) - fnamere = re.compile(filedict) - for file in os.listdir(os.getenv("HOME")): - mo = re.match(fnamere,file) - if mo and len(mo.groups()): - killMyPort(mo.groups()[0]) + # new-style dot-prefixed pidict file + fpidict = getPiDict('(\d*)',hidden=True) + dirpidict = os.path.dirname(fpidict) + fpidict = os.path.basename(fpidict) + fnamere = re.compile("^%s$" % fpidict) + try: + for f in os.listdir(dirpidict): + mo = fnamere.match(f) + try: + killMyPort(mo.group(1)) + except: + pass + pass pass - - if not sys.platform == 'win32': - cmd = "pid=`ps -fea | grep '"+os.getenv('USER')+"' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'` ; echo $pid > /tmp/logs/"+os.getenv('USER')+"/_"+"Pid_ghs3d.log" - a = os.system(cmd) - try: - fpidomniNames=open('/tmp/logs/'+os.getenv('USER')+"/_"+"Pid_ghs3d.log") - prc = fpidomniNames.read() - fpidomniNames.close() - if prc != None : - for field in prc.split(" ") : - field = field.strip() - if field != None and len(field) != 0: - os.system('kill -9 '+field) - except: + except: + pass + # provide compatibility with old-style pidict file (not dot-prefixed) + fpidict = getPiDict('(\d*)',hidden=False) + dirpidict = os.path.dirname(fpidict) + fpidict = os.path.basename(fpidict) + fnamere = re.compile("^%s$" % fpidict) + try: + for f in os.listdir(dirpidict): + mo = fnamere.match(f) + try: + killMyPort(mo.group(1)) + except: + pass + pass + pass + except: + pass + # kill other processes + if sys.platform != 'win32': + import commands + cmd = "ps -fea | grep '%s' | grep 'ghs3d' | grep 'f /tmp/GHS3D_' | grep -v 'grep' | awk '{print $2}'" % user + prc = commands.getoutput(cmd) + for field in prc.split(): + try: + os.kill(int(field), signal.SIGKILL) + except: + pass pass pass + pass if __name__ == "__main__": killAllPorts() + pass diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index 79c168279..2308505a0 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -22,47 +22,69 @@ import os, sys, pickle, signal, commands from launchConfigureParser import verbose -def getPiDict(port,appname='salome',full=True): - from Utils_Identity import getShortHostName - - # get hostname by special function in all cases to - # have always same result in lower case at win32 - host = getShortHostName() - if not host: - host = os.getenv("HOSTNAME") - if not host: - host = os.getenv("HOST") - - filedict = [] - filedict.append( os.getenv('USER') ) # user name - filedict.append( host ) # host name - filedict.append( str(port) ) # port number - filedict.append( appname.upper() ) # application name - filedict.append( 'pidict' ) # constant part +def getPiDict(port,appname='salome',full=True,hidden=True): + """ + Get file with list of SALOME processes. + This file is located in the user's home directory + and named .___SALOME_pidict + where + is user name + is host name + is port number - filedict = '_'.join(filedict) + Parameters: + - port : port number + - appname : application name (default is 'SALOME') + - full : if True, full path to the file is returned, otherwise only file name is returned + - hidden : if True, file name is prefixed with . (dot) symbol; this internal parameter is used + to support compatibility with older versions of SALOME + """ + from salome_utilities import generateFileName, getTmpDir + dir = "" if full: - filedict = os.getenv("HOME") + '/' + filedict - return filedict + # full path to the pidict file is requested + if hidden: + # new-style dot-prefixed pidict files + # are in the system-dependant temporary diretory + dir = getTmpDir() + else: + # old-style non-dot-prefixed pidict files + # are in the user's home directory + dir = os.getenv("HOME") + pass + pass + return generateFileName(dir, + suffix="pidict", + hidden=hidden, + with_username=True, + with_hostname=True, + with_port=port, + with_app=appname.upper()) def appliCleanOmniOrbConfig(port): """ - remove omniorb config files related to the port in SALOME application: + Remove omniorb config files related to the port in SALOME application: - ${HOME}/${APPLI}/.omniORB_${HOSTNAME}_${NSPORT}.cfg - ${HOME}/${APPLI}/.omniORB_last.cfg the last is removed only if the link points to the first file. """ - from Utils_Identity import getShortHostName - appli=os.environ.get("APPLI") + from salome_utilities import generateFileName + home = os.getenv("HOME") + appli = os.getenv("APPLI") if appli is None: #Run outside application context pass else: - home = os.environ['HOME'] - home='%s/%s'%(home,appli) - hostname=getShortHostName() - omniorb_config = '%s/.omniORB_%s_%s.cfg'%(home,hostname, str(port)) - last_running_config = '%s/.omniORB_last.cfg'%(home) + dir = os.path.join(home, appli) + omniorb_config = generateFileName(dir, prefix="omniORB", + extension="cfg", + hidden=True, + with_hostname=True, + with_port=port) + last_running_config = generateFileName(dir, prefix="omniORB", + suffix="last", + extension="cfg", + hidden=True) if os.access(last_running_config,os.F_OK): pointedPath = os.readlink(last_running_config) if pointedPath[0] != '/': @@ -75,77 +97,100 @@ def appliCleanOmniOrbConfig(port): os.remove(omniorb_config) pass pass + pass ########## kills all salome processes with the given port ########## def killMyPort(port): - filedict=getPiDict(port) - found = 0 + """ + Kill SALOME session running on the specified port. + Parameters: + - port - port number + """ + # new-style dot-prefixed pidict file + filedict = getPiDict(port, hidden=True) + # provide compatibility with old-style pidict file (not dot-prefixed) + if not os.path.exists(filedict): filedict = getPiDict(port, hidden=False) + # try: - fpid=open(filedict, 'r') - found = 1 - except: - print "file %s giving SALOME process id is not readable"% filedict - pass - - if found: + fpid = open(filedict, 'r') + # + from salome_utilities import generateFileName + fpidomniNames = generateFileName(os.path.join('/tmp/logs', os.getenv('USER')), + prefix="", + suffix="Pid_omniNames", + extension="log", + with_port=port) if not sys.platform == 'win32': - cmd = 'pid=`ps -eo pid,command | egrep "[0-9] omniNames -start '+str(port)+'"` ; echo $pid > /tmp/logs/'+os.getenv('USER')+"/_"+port+'_Pid_omniNames.log' + cmd = 'pid=`ps -eo pid,command | egrep "[0-9] omniNames -start %s"` ; echo $pid > %s' % ( str(port), fpidomniNames ) a = os.system(cmd) + pass try: - fpidomniNames=open('/tmp/logs/'+os.getenv('USER')+"/_"+port+'_Pid_omniNames.log') - prc = fpidomniNames.read() - fpidomniNames.close() - if prc != None : - for field in prc.split(" ") : - if field == "omniNames" : - if pidfield != "egrep" : - if sys.platform == "win32": - import win32pm - print 'stop process '+pidfield+' : omniNames' - win32pm.killpid(int(pidfield),0) - else: - if verbose(): print 'stop process '+pidfield+' : omniNames' - os.system('kill -9 '+pidfield) - pidfield = field + fpidomniNamesFile = open(fpidomniNames) + lines = fpidomniNamesFile.readlines() + fpidomniNamesFile.close() + os.remove(fpidomniNames) + for l in lines: + try: + pidfield = l.split()[0] # pid should be at the first position + if sys.platform == "win32": + import win32pm + if verbose(): print 'stop process '+pidfield+' : omniNames' + win32pm.killpid(int(pidfield),0) + else: + if verbose(): print 'stop process '+pidfield+' : omniNames' + os.kill(int(pidfield),signal.SIGKILL) + pass + pass + except: + pass + pass + pass except: pass - + # try: process_ids=pickle.load(fpid) fpid.close() for process_id in process_ids: - for pid, cmd in process_id.items(): if verbose(): print "stop process %s : %s"% (pid, cmd[0]) try: if sys.platform == "win32": - import win32pm - win32pm.killpid(int(pid),0) + import win32pm + win32pm.killpid(int(pid),0) else: - os.kill(int(pid),signal.SIGKILL) + os.kill(int(pid),signal.SIGKILL) + pass + pass except: if verbose(): print " ------------------ process %s : %s not found"% (pid, cmd[0]) pass - pass + pass # for pid, cmd ... + pass # for process_id ... + pass # try... except: pass - + # os.remove(filedict) cmd='ps -eo pid,command | egrep "[0-9] omniNames -start '+str(port)+'" | sed -e "s%[^0-9]*\([0-9]*\) .*%\\1%g"' pid = commands.getoutput(cmd) a = "" - while pid != "" and len(a.split(" ")) < 2: - a = commands.getoutput("pid=`ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"`; kill -9 $pid") - pid = commands.getoutput("ps -eo pid,command | egrep \"[0-9] omniNames -start "+str(port)+"\" | sed -e \"s%[^0-9]*\([0-9]*\) .*%\\1%g\"") - print pid - + while pid and len(a.split()) < 2: + a = commands.getoutput("kill -9 " + pid) + pid = commands.getoutput(cmd) + #print pid + pass pass - + except: + print "Cannot find or open SALOME PIDs file for port", port + pass + # appliCleanOmniOrbConfig(port) pass - if __name__ == "__main__": for port in sys.argv[1:]: killMyPort(port) + pass + pass diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 399c40ef7..74b3cd0a1 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -701,9 +701,16 @@ def get_env(theAdditionalOptions=[], appname="SalomeApp"): dirs += re.split(';', os.getenv(config_var)) else: dirs += re.split('[;|:]', os.getenv(config_var)) - + + gui_available = True if os.getenv("GUI_ROOT_DIR") and os.path.isdir( os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui" ): dirs += [os.getenv("GUI_ROOT_DIR") + "/share/salome/resources/gui"] + pass + else: + gui_available = False + if os.getenv("KERNEL_ROOT_DIR") and os.path.isdir( os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/appliskel" ): + dirs += [os.getenv("KERNEL_ROOT_DIR") + "/bin/salome/appliskel"] + pass os.environ[config_var] = separator.join(dirs) dirs.reverse() # reverse order, like in "path" variable - FILO-style processing @@ -800,6 +807,10 @@ def get_env(theAdditionalOptions=[], appname="SalomeApp"): args[gui_nam] = cmd_opts.gui if cmd_opts.batch is not None: args[batch_nam] = True + + if not gui_available: + args[gui_nam] = False + if args[gui_nam]: args["session_gui"] = True if cmd_opts.desktop is not None: diff --git a/bin/nameserver.py b/bin/nameserver.py index dd03c51a3..99ec4c3b2 100755 --- a/bin/nameserver.py +++ b/bin/nameserver.py @@ -4,6 +4,7 @@ import sys, os, re, socket #import commands from server import * from Utils_Identity import getShortHostName +from launchConfigureParser import verbose # ----------------------------------------------------------------------------- @@ -45,12 +46,12 @@ class NamingServer(Server): #os.system("touch " + upath + "/dummy") for fname in os.listdir(upath): try: - os.remove(upath + "/" + fname) + if not fname.startswith("."): os.remove(upath + "/" + fname) except: pass #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log") - print "Name Service... ", + if verbose(): print "Name Service... ", #hname=os.environ["HOST"] #commands.getoutput("hostname") if sys.platform == "win32": hname=getShortHostName(); @@ -60,7 +61,7 @@ class NamingServer(Server): f=open(os.environ["OMNIORB_CONFIG"]) ss=re.findall("NameService=corbaname::" + hname + ":\d+", f.read()) - print "ss = ", ss, + if verbose(): print "ss = ", ss, f.close() sl=ss[0] ll = sl.split(':') @@ -74,15 +75,15 @@ class NamingServer(Server): #print "port=", aPort if sys.platform == "win32": #print "start omniNames -start " + aPort + " -logdir " + upath - self.CMD=['omniNames -start ' , aPort , ' -logdir ' , '\"' + upath + '\"'] + self.CMD=['omniNames -start ' , aPort , ' -logdir ' , '\"' + upath + '\"', ' -errlog', upath+'/omniNameErrors.log'] #os.system("start omniNames -start " + aPort + " -logdir " + upath) else: #self.CMD=['omniNames -start ' , aPort , ' -logdir ' , upath , ' &'] - self.CMD=['omniNames','-start' , aPort, '-logdir' , upath ] + self.CMD=['omniNames','-start' , aPort, '-logdir' , upath, '-errlog', upath+'/omniNameErrors.log'] #os.system("omniNames -start " + aPort + " -logdir " + upath + " &") - print "... ok" - print "to list contexts and objects bound into the context with the specified name : showNS " + if verbose(): print "... ok" + if verbose(): print "to list contexts and objects bound into the context with the specified name : showNS " def initArgs(self): diff --git a/bin/orbmodule.py b/bin/orbmodule.py index 9f3c66324..ffb211fab 100755 --- a/bin/orbmodule.py +++ b/bin/orbmodule.py @@ -20,6 +20,7 @@ import sys,os,time import string from nameserver import * from omniORB import CORBA +from launchConfigureParser import verbose # Import the stubs for the Naming service import CosNaming @@ -47,7 +48,7 @@ class client: return except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): self.rootContext = None - print "Launch Naming Service++", + if verbose(): print "Launch Naming Service++", # On lance le Naming Server (doit etre dans le PATH) NamingServer(args).run() diff --git a/bin/runNS.py b/bin/runNS.py index 444760369..601c7b00d 100755 --- a/bin/runNS.py +++ b/bin/runNS.py @@ -39,7 +39,7 @@ def startOmni(): #os.system("touch " + upath + "/dummy") for fname in os.listdir(upath): try: - os.remove(upath + "/" + fname) + if not fname.startswith("."): os.remove(upath + "/" + fname) except: pass #os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log") diff --git a/bin/runSalome.py b/bin/runSalome.py index dc256253e..aae7d0dfa 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -19,7 +19,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -import sys, os, string, glob, time, pickle +import sys, os, string, glob, time, pickle, re import orbmodule import setenv from server import * @@ -204,10 +204,22 @@ class LoggerServer(Server): def __init__(self,args): self.args=args self.initArgs() - if sys.platform == "win32": - self.CMD=['SALOME_Logger_Server', os.environ["HOME"] + "/logger.log"]; - else: - self.CMD=['SALOME_Logger_Server', 'logger.log'] + from salome_utilities import generateFileName + if sys.platform == "win32": dirpath = os.environ["HOME"] + else: dirpath = "/tmp" + logfile = generateFileName( dirpath, + prefix="logger", + extension="log", + with_username=True, + with_hostname=True, + with_port=True) + print "===========================================================" + print "Logger server: put log to the file:" + print logfile + print "===========================================================" + self.CMD=['SALOME_Logger_Server', logfile] + pass + pass # end of LoggerServer class # --- @@ -418,10 +430,8 @@ def startSalome(args, modules_list, modules_root_dir): # Notify Server launch # - if verbose(): print "Notify Server to launch" - if sys.platform != "win32": - print "Notify Server to launch" + if verbose(): print "Notify Server to launch" myServer=NotifyServer(args,modules_root_dir) myServer.run() @@ -623,22 +633,14 @@ def useSalome(args, modules_list, modules_root_dir): #print process_id + from addToKillList import addToKillList from killSalomeWithPort import getPiDict - filedict = getPiDict(args['port']) - process_ids = [] - try: - fpid=open(filedict, 'r') - process_ids=pickle.load(fpid) - fpid.close() - except: + filedict = getPiDict(args['port']) + for pid, cmd in process_id.items(): + addToKillList(pid, cmd, args['port']) pass - - fpid=open(filedict, 'w') - process_ids.append(process_id) - pickle.dump(process_ids,fpid) - fpid.close() - + if verbose(): print """ Saving of the dictionary of Salome processes in %s To kill SALOME processes from a console (kill all sessions from all ports): @@ -714,89 +716,92 @@ def registerEnv(args, modules_list, modules_root_dir): def searchFreePort(args, save_config=1): print "Searching for a free port for naming service:", + # + if sys.platform == "win32": + tmp_file = os.getenv('TEMP'); + else: + tmp_file = '/tmp' + tmp_file = os.path.join(tmp_file, '.netstat_%s'%os.getpid()) + # + ###status = os.system("netstat -ltn | grep -E :%s > /dev/null 2>&1"%(NSPORT)) + os.system( "netstat -a -n > %s" % tmp_file ); + f = open( tmp_file, 'r' ); + ports = f.readlines(); + f.close(); + os.remove( tmp_file ); + # + def portIsUsed(port, data): + regObj = re.compile( "tcp.*:([0-9]+).*:.*listen", re.IGNORECASE ); + for item in data: + try: + p = int(regObj.match(item).group(1)) + if p == port: return True + pass + except: + pass + pass + return False + # NSPORT=2810 - limit=NSPORT - limit=limit+10 + limit=NSPORT+100 + # while 1: - import os - import re - from os import getpid - from os import system - - if sys.platform == "win32": - tmp_file = os.getenv('TEMP'); - else: - tmp_file = '/tmp/' - tmp_file += 'hostname_%s'%(getpid()) - -# status = os.system("netstat -ltn | grep -E :%s > /dev/null 2>&1"%(NSPORT)) - - system( "netstat -a -n > %s" % tmp_file ); - - f = open( tmp_file, 'r' ); - lines = f.readlines(); - f.close(); - - pattern = "tcp.*:([0-9]+).*:.*listen"; - regObj = re.compile( pattern, re.IGNORECASE ); - - status = 1; - for item in lines: - m = regObj.search( item ) - if m: - try: - p = int( m.group(1) ) - if p == NSPORT: - status = 0; - break; - except: - pass - pass - - if status == 1: + if not portIsUsed(NSPORT, ports): print "%s - OK"%(NSPORT) # - system('hostname > %s'%(tmp_file)) - f = open(tmp_file) - myhost = f.read() - myhost = myhost[:-1] - f.close() - - os.remove( tmp_file ); - + from salome_utilities import generateFileName, getHostName + hostname = getHostName() # - home = os.environ['HOME'] - appli=os.environ.get("APPLI") - if appli is not None: - home='%s/%s'%(home,appli) - pass + home = os.getenv("HOME") + appli = os.getenv("APPLI") + if appli is not None: home = os.path.join(home, appli) # - os.environ['OMNIORB_CONFIG'] = '%s/.omniORB_%s_%s.cfg'%(home, myhost, NSPORT) - initref = "NameService=corbaname::%s:%s"%(myhost, NSPORT) - os.environ['NSPORT'] = "%s"%(NSPORT) - os.environ['NSHOST'] = "%s"%(myhost) - f = open(os.environ['OMNIORB_CONFIG'], "w") + omniorb_config = generateFileName(home, prefix="omniORB", + extension="cfg", + hidden=True, + with_hostname=True, + with_port=NSPORT) + orbdata = [] + initref = "NameService=corbaname::%s:%s"%(hostname, NSPORT) import CORBA if CORBA.ORB_ID == "omniORB4": - initref += "\ngiopMaxMsgSize = 2097152000 # 2 GBytes"; - initref += "\ntraceLevel = 0 # critical errors only"; - f.write("InitRef = %s\n"%(initref)) + orbdata.append("InitRef = %s"%(initref)) + orbdata.append("giopMaxMsgSize = 2097152000 # 2 GBytes") + orbdata.append("traceLevel = 0 # critical errors only") else: - initref += "\nORBgiopMaxMsgSize = 2097152000 # 2 GBytes"; - initref += "\nORBtraceLevel = 0 # critical errors only"; - f.write("ORBInitRef %s\n"%(initref)) + orbdata.append("ORBInitRef %s"%(initref)) + orbdata.append("ORBgiopMaxMsgSize = 2097152000 # 2 GBytes") + orbdata.append("ORBtraceLevel = 0 # critical errors only") pass + orbdata.append("") + f = open(omniorb_config, "w") + f.write("\n".join(orbdata)) f.close() + # + os.environ['OMNIORB_CONFIG'] = omniorb_config + os.environ['NSPORT'] = "%s"%(NSPORT) + os.environ['NSHOST'] = "%s"%(hostname) args['port'] = os.environ['NSPORT'] # if save_config: - from os import system - if sys.platform == "win32": - import shutil - shutil.copyfile( os.environ['OMNIORB_CONFIG'], "%s/.omniORB_last.cfg"%( home ) ) - else: - system('ln -s -f %s %s/.omniORB_last.cfg'%(os.environ['OMNIORB_CONFIG'], home)) - pass + last_running_config = generateFileName(home, prefix="omniORB", + suffix="last", + extension="cfg", + hidden=True) + try: + if sys.platform == "win32": + import shutil + shutil.copyfile(omniorb_config, last_running_config) + else: + try: + os.remove(last_running_config) + except OSError: + pass + os.symlink(omniorb_config, last_running_config) + pass + pass + except: + pass break print "%s"%(NSPORT), if NSPORT == limit: @@ -826,14 +831,16 @@ def no_main(): def main(): """Salome launch as a main application""" import sys - print "runSalome running on ",os.getenv('HOSTNAME') + from salome_utilities import getHostName + print "runSalome running on %s" % getHostName() args, modules_list, modules_root_dir = setenv.get_config() kill_salome(args) save_config = True if args.has_key('save_config'): save_config = args['save_config'] searchFreePort(args, save_config) - setenv.main() + #setenv.main() + setenv.set_env(args, modules_list, modules_root_dir) clt = useSalome(args, modules_list, modules_root_dir) return clt,args diff --git a/bin/salome_session.py b/bin/salome_session.py index 870b53bc4..64e13c951 100644 --- a/bin/salome_session.py +++ b/bin/salome_session.py @@ -39,48 +39,55 @@ def getShortHostName(): socket.gethostname() gives short or complete Hostname, depending on defined aliases. """ - return string.split(socket.gethostname(),'.')[0] + from salome_utilities import getShortHostName + return getShortHostName() def searchFreePort(): + """ + Search free port for SALOME session. + Returns first found free port number. + """ print "Searching a free port for naming service:", - NSPORT=2810 - limit=NSPORT - limit=limit+100 + from salome_utilities import generateFileName, getHostName + hostname = getHostName() + NSPORT = 2810 + limit = NSPORT+100 while 1: print "%s "%(NSPORT), status = os.system("netstat -ltn | grep -E :%s"%(NSPORT)) if status: - home = os.environ['HOME'] - appli=os.environ.get("APPLI") - if appli is None: - #Run outside application context - home=home - else: - home='%s/%s'%(home,appli) - hostname=getShortHostName() - omniorb_config = '%s/.omniORB_%s_%s.cfg'%(home,hostname, NSPORT) - os.environ['OMNIORB_CONFIG'] = omniorb_config + home = os.getenv("HOME") + appli = os.getenv("APPLI") + if appli is not None: home = os.path.join(home, appli) + omniorb_config = generateFileName(home, prefix="omniORB", + extension="cfg", + hidden=True, + with_hostname=True, + with_port=NSPORT) f = open(omniorb_config, "w") f.write("ORBInitRef NameService=corbaname::%s:%s\n"%(hostname, NSPORT)) f.close() - last_running_config = '%s/.omniORB_last.cfg'%(home, hostname) + os.environ['OMNIORB_CONFIG'] = omniorb_config + last_running_config = generateFileName(home, prefix="omniORB", + suffix="last", + extension="cfg", + hidden=True) os.environ['LAST_RUNNING_CONFIG'] = last_running_config if os.access(last_running_config,os.F_OK): os.unlink(last_running_config) pass os.symlink(omniorb_config,last_running_config) - # LAST_RUNNING_CONFIG=${HOME}/${APPLI}/.omniORB_${myhost}_last.cfg print "- Ok" break if NSPORT == limit: msg = "" - msg += "I Can't find a free port to launch omniNames\n" - msg += "I suggest you to kill the running servers and try again.\n" + msg += "Can not find a free port to launch omniNames\n" + msg += "Kill the running servers and try again.\n" raise msg - NSPORT=NSPORT+1 + NSPORT = NSPORT+1 pass - os.environ['NSHOST']=hostname - os.environ['NSPORT']=str(NSPORT) + os.environ['NSHOST'] = hostname + os.environ['NSPORT'] = str(NSPORT) return NSPORT diff --git a/bin/salome_utilities.py b/bin/salome_utilities.py new file mode 100644 index 000000000..b4349cd20 --- /dev/null +++ b/bin/salome_utilities.py @@ -0,0 +1,346 @@ +# Copyright (C) 2005 OPEN CASCADE, CEA, EDF R&D, LEG +# PRINCIPIA R&D, EADS CCR, Lip6, BV, CEDRAT +# 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_utilities.py +# Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) +# +# --- + +""" +Set of utility functions used by SALOME python scripts. +""" + +# +# Exported functions +# +__all__ = [ + 'getORBcfgInfo', + 'getHostFromORBcfg', + 'getPortFromORBcfg', + 'getUserName', + 'getHostName', + 'getShortHostName', + 'getAppName', + 'getPortNumber', + 'getTmpDir', + 'generateFileName', + ] + +# --- + +def _try_bool( arg ): + """ + Check if specified parameter represents boolean value and returns its value. + String values like 'True', 'TRUE', 'YES', 'Yes', 'y', 'NO', 'false', 'n', etc + are supported. + If does not represent a boolean, an exception is raised. + """ + import types + if type( arg ) == types.BooleanType : + return arg + elif type( arg ) == types.StringType : + v = str( arg ).lower() + if v in [ "yes", "y", "true" ]: return True + elif v in [ "no", "n", "false" ]: return False + pass + raise Exception("Not boolean value") + +# --- + +def getORBcfgInfo(): + """ + Get omniORB current configuration. + Returns a list of three values: [ orb_version, host_name, port_number ]. + + The information is retrieved from the omniORB configuration file defined + by the OMNIORB_CONFIG environment variable. + If omniORB configuration file can not be accessed, a list of three empty + strings is returned. + """ + import os, re + ret = [ "", "", "" ] + try: + f = open( os.getenv( "OMNIORB_CONFIG" ) ) + lines = f.readlines() + f.close() + regvar = re.compile( "(ORB)?InitRef.*corbaname::(.*):(\d+)\s*$" ) + for l in lines: + try: + m = regvar.match( l ) + if m: + if m.group(1) is None: + ret[0] = "4" + else: + ret[0] = "3" + pass + ret[1] = m.group(2) + ret[2] = m.group(3) + break + pass + except: + pass + pass + pass + except: + pass + return ret + +# --- + +def getHostFromORBcfg(): + """ + Get current omniORB host. + """ + return getORBcfgInfo()[1] +# --- + +def getPortFromORBcfg(): + """ + Get current omniORB port. + """ + return getORBcfgInfo()[2] + +# --- + +def getUserName(): + """ + Get user name: + 1. try USER environment variable + 2. if fails, return 'unknown' as default user name + """ + import os + return os.getenv( "USER", "unknown" ) # 'unknown' is default user name + +# --- + +def getHostName(): + """ + Get host name: + 1. try socket python module gethostname() function + 2. if fails, try HOSTNAME environment variable + 3. if fails, try HOST environment variable + 4. if fails, return 'unknown' as default host name + """ + import os + try: + import socket + host = socket.gethostname() + except: + host = None + pass + if not host: host = os.getenv("HOSTNAME") + if not host: host = os.getenv("HOST") + if not host: host = "unknown" # 'unknown' is default host name + return host + +# --- + +def getShortHostName(): + """ + Get short host name: + 1. try socket python module gethostname() function + 2. if fails, try HOSTNAME environment variable + 3. if fails, try HOST environment variable + 4. if fails, return 'unknown' as default host name + """ + try: + return getHostName().split('.')[0] + except: + pass + return "unknown" # 'unknown' is default host name + +# --- + +def getAppName(): + """ + Get application name: + 1. try APPNAME environment variable + 2. if fails, return 'SALOME' as default application name + """ + import os + return os.getenv( "APPNAME", "SALOME" ) # 'SALOME' is default user name + +# --- + +def getPortNumber(): + """ + Get current naming server port number: + 1. try NSPORT environment variable + 1. if fails, try to parse config file defined by OMNIORB_CONFIG environment variable + 2. if fails, return 2809 as default port number + """ + import os + try: + return int( os.getenv( "NSPORT" ) ) + except: + pass + port = getPortFromORBcfg() + if port is not None: return port + return 2809 # '2809' is default port number + +# --- + +def getTmpDir(): + """ + Get directory to be used for the temporary files. + """ + import os, sys + if sys.platform == "win32": + # for Windows: temporarily using home directory for tmp files; + # to be replaced with TEMP environment variable later... + dir = os.getenv("HOME") + else: + # for Linux: use /tmp/logs/{user} folder + dir = os.path.join( '/tmp', 'logs', getUserName() ) + pass + return dir + +# --- + +def generateFileName( dir, prefix = None, suffix = None, extension = None, + unique = False, separator = "_", hidden = False, **kwargs ): + """ + Generate file name by sepecified parameters. If necessary, file name + can be generated to be unique. + + Parameters: + - dir : directory path + - prefix : file prefix (not added by default) + - suffix : file suffix (not added by default) + - extension : file extension (not added by default) + - unique : if this parameter is True, the unique file name is generated: + in this case, if the file with the generated name already exists + in the directory, an integer suffix is added to the end of the + file name. This parameter is False by default. + - separator : separator of the words ('_' by default) + - hidden : if this parameter is True, the file name is prepended by . (dot) + symbol. This parameter is False by default. + + Other keyword parameters are: + - with_username : 'add user name' flag/option: + * boolean value can be passed to determine user name automatically + * string value to be used as user name + - with_hostname : 'add host name' flag/option: + * boolean value can be passed to determine host name automatically + * string value to be used as host name + - with_port : 'add port number' flag/option: + * boolean value can be passed to determine port number automatically + * string value to be used as port number + - with_app : 'add application name' flag/option: + * boolean value can be passed to determine application name automatically + * string value to be used as application name + All parameters are optional. + """ + supported = [ 'with_username', 'with_hostname', 'with_port', 'with_app' ] + from launchConfigureParser import verbose + filename = [] + # separator + if separator is None: + separator = "" + pass + else: + separator = str( separator ) + pass + # prefix (if specified) + if prefix is not None: + filename.append( str( prefix ) ) + pass + # additional keywords + ### check unsupported parameters + for kw in kwargs: + if kw not in supported and verbose(): + print 'Warning! salome_utilitie.py: generateFileName(): parameter %s is not supported' % kw + pass + pass + ### process supported keywords + for kw in supported: + if kw not in kwargs: continue + ### user name + if kw == 'with_username': + try: + # auto user name ? + if _try_bool( kwargs[kw] ): filename.append( getUserName() ) + pass + except: + # user name given as parameter + filename.append( kwargs[kw] ) + pass + pass + ### host name + elif kw == 'with_hostname': + try: + # auto host name ? + if _try_bool( kwargs[kw] ): filename.append( getShortHostName() ) + pass + except: + # host name given as parameter + filename.append( kwargs[kw] ) + pass + pass + ### port number + elif kw == 'with_port': + try: + # auto port number ? + if _try_bool( kwargs[kw] ): filename.append( str( getPortNumber() ) ) + pass + except: + # port number given as parameter + filename.append( str( kwargs[kw] ) ) + pass + pass + ### application name + elif kw == 'with_app': + try: + # auto application name ? + if _try_bool( kwargs[kw] ): filename.append( getAppName() ) + pass + except: + # application name given as parameter + filename.append( kwargs[kw] ) + pass + pass + pass + # suffix (if specified) + if suffix is not None: + filename.append( str( suffix ) ) + pass + # raise an exception if file name is empty + if not filename: + raise Exception("Empty file name") + # + if extension is not None and extension.startswith("."): extension = extension[1:] + # + import os + name = separator.join( filename ) + if hidden: name = "." + name # add dot for hidden files + if extension: name = name + "." + str( extension ) # add extension if defined + name = os.path.join( dir, name ) + if unique: + # create unique file name + index = 0 + while os.path.exists( name ): + index = index + 1 + name = separator.join( filename ) + separator + str( index ) + if hidden: name = "." + name # add dot for hidden files + if extension: name = name + "." + str( extension ) # add extension if defined + name = os.path.join( dir, name ) + pass + pass + return name diff --git a/bin/setenv.py b/bin/setenv.py index 86a4803ba..14ae3c5bc 100755 --- a/bin/setenv.py +++ b/bin/setenv.py @@ -75,7 +75,7 @@ def get_lib_dir(): # ----------------------------------------------------------------------------- -def get_config(): +def get_config(silent=False): """ Get list of modules, paths. @@ -116,12 +116,14 @@ def get_config(): for module in modules_list : module_variable=module+"_ROOT_DIR" if not os.environ.has_key(module_variable): - print "*******************************************************" - print "*" - print "* Environment variable",module_variable,"must be set" - print "* Module", module, "will be not available" - print "*" - print "********************************************************" + if not silent: + print "*******************************************************" + print "*" + print "* Environment variable",module_variable,"must be set" + print "* Module", module, "will be not available" + print "*" + print "********************************************************" + pass to_remove_list.append(module) continue pass @@ -147,7 +149,7 @@ def get_config(): # ----------------------------------------------------------------------------- -def set_env(args, modules_list, modules_root_dir): +def set_env(args, modules_list, modules_root_dir, silent=False): """Add to the PATH-variables modules specific paths""" python_version="python%d.%d" % sys.version_info[0:2] @@ -187,9 +189,46 @@ def set_env(args, modules_list, modules_root_dir): salome_subdir, "shared_modules"), "PYTHONPATH") - pass - pass + # set environment for SMESH plugins + if module == "SMESH" : + os.environ["SMESH_MeshersList"]="StdMeshers" + if not os.environ.has_key("SALOME_StdMeshersResources"): + os.environ["SALOME_StdMeshersResources"] \ + = modules_root_dir["SMESH"]+"/share/"+salome_subdir+"/resources/smesh" + pass + if args.has_key("SMESH_plugins"): + for plugin in args["SMESH_plugins"]: + plugin_root = "" + if os.environ.has_key(plugin+"_ROOT_DIR"): + plugin_root = os.environ[plugin+"_ROOT_DIR"] + else: + # workaround to avoid modifications of existing environment + if os.environ.has_key(plugin.upper()+"_ROOT_DIR"): + plugin_root = os.environ[plugin.upper()+"_ROOT_DIR"] + pass + pass + if plugin_root != "": + os.environ["SMESH_MeshersList"] \ + = os.environ["SMESH_MeshersList"]+":"+plugin + if not os.environ.has_key("SALOME_"+plugin+"Resources"): + os.environ["SALOME_"+plugin+"Resources"] \ + = plugin_root+"/share/"+salome_subdir+"/resources/"+plugin.lower() + add_path(os.path.join(plugin_root,get_lib_dir(),python_version, "site-packages",salome_subdir), "PYTHONPATH") + add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "PYTHONPATH") + + if sys.platform == "win32": + add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "PATH") + else: + add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), "LD_LIBRARY_PATH") + add_path(os.path.join(plugin_root,"bin",salome_subdir), "PYTHONPATH") + add_path(os.path.join(plugin_root,"bin",salome_subdir), "PATH") + pass + pass + pass + pass + pass + if sys.platform == 'win32': os.environ["SALOMEPATH"]=";".join(modules_root_dir_list) else: @@ -204,51 +243,6 @@ def set_env(args, modules_list, modules_root_dir): if args['logger']: os.environ["SALOME_trace"]="with_logger" - # set environment for SMESH plugins - - if "SMESH" in modules_list: - os.environ["SMESH_MeshersList"]="StdMeshers" - if not os.environ.has_key("SALOME_StdMeshersResources"): - os.environ["SALOME_StdMeshersResources"] \ - = modules_root_dir["SMESH"]+"/share/"+salome_subdir+"/resources/smesh" - pass - if args.has_key("SMESH_plugins"): - for plugin in args["SMESH_plugins"]: - plugin_root = "" - if os.environ.has_key(plugin+"_ROOT_DIR"): - plugin_root = os.environ[plugin+"_ROOT_DIR"] - else: - # workaround to avoid modifications of existing environment - if os.environ.has_key(plugin.upper()+"_ROOT_DIR"): - plugin_root = os.environ[plugin.upper()+"_ROOT_DIR"] - pass - pass - if plugin_root != "": - os.environ["SMESH_MeshersList"] \ - = os.environ["SMESH_MeshersList"]+":"+plugin - if not os.environ.has_key("SALOME_"+plugin+"Resources"): - os.environ["SALOME_"+plugin+"Resources"] \ - = plugin_root+"/share/"+salome_subdir+"/resources/"+plugin.lower() - add_path(os.path.join(plugin_root,get_lib_dir(),python_version, - "site-packages",salome_subdir), - "PYTHONPATH") - add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), - "PYTHONPATH") - - - if sys.platform == "win32": - add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), - "PATH") - else: - add_path(os.path.join(plugin_root,get_lib_dir(),salome_subdir), - "LD_LIBRARY_PATH") - add_path(os.path.join(plugin_root,"bin",salome_subdir), - "PYTHONPATH") - add_path(os.path.join(plugin_root,"bin",salome_subdir), - "PATH") - pass - pass - # set environment for SUPERV module os.environ["ENABLE_MACRO_NODE"]="1" # set resources variables if not yet set @@ -261,7 +255,7 @@ def set_env(args, modules_list, modules_root_dir): salome_subdir,"resources","kernel") if "GEOM" in modules_list: - if verbose(): print "GEOM OCAF Resources" + if verbose() and not silent: print "GEOM OCAF Resources" # set CSF_PluginDefaults variable only if it is not customized # by the user @@ -273,16 +267,16 @@ def set_env(args, modules_list, modules_root_dir): os.environ["CSF_GEOMDS_ResourcesDefaults"] \ = os.path.join(modules_root_dir["GEOM"],"share", salome_subdir,"resources","geom") - if verbose(): print "GEOM Shape Healing Resources" + if verbose() and not silent: print "GEOM Shape Healing Resources" os.environ["CSF_ShHealingDefaults"] \ = os.path.join(modules_root_dir["GEOM"],"share", salome_subdir,"resources","geom") # ----------------------------------------------------------------------------- -def main(): - args, modules_list, modules_root_dir = get_config() - set_env(args, modules_list, modules_root_dir) +def main(silent=False): + args, modules_list, modules_root_dir = get_config(silent=silent) + set_env(args, modules_list, modules_root_dir, silent=silent) return args # ----------------------------------------------------------------------------- diff --git a/idl/Makefile.am b/idl/Makefile.am index 9ff37591d..05bad5140 100644 --- a/idl/Makefile.am +++ b/idl/Makefile.am @@ -201,14 +201,15 @@ DSC_EnginesPaCO.h DSC_EnginesPaCO.cc : DSC_Engines.idl DSC_Engines.xml lib_LTLIBRARIES = libSalomeIDLKernel.la $(PAR_LIB) nodist_libSalomeIDLKernel_la_SOURCES = $(IDL_SOURCES) $(DYNIDL_SRCS) -libSalomeIDLKernel_la_CPPFLAGS =-I$(top_builddir)/salome_adm/unix \ +libSalomeIDLKernel_la_CPPFLAGS =-I$(top_builddir)/salome_adm/unix -include SALOMEconfig.h \ -I$(top_builddir)/idl \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ libSalomeIDLKernel_la_LDFLAGS = -no-undefined -version-info=0:0:0 libSalomeIDLKernel_la_LIBADD = @CORBA_LIBS@ nodist_libSalomeParallelIDLKernel_la_SOURCES = $(PAR) $(GEN_PACO) -libSalomeParallelIDLKernel_la_CPPFLAGS =-I$(top_builddir)/idl \ +libSalomeParallelIDLKernel_la_CPPFLAGS =-I$(top_builddir)/salome_adm/unix -include SALOMEconfig.h \ + -I$(top_builddir)/idl \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ \ @PACO_INCLUDES@ libSalomeParallelIDLKernel_la_LDFLAGS = -no-undefined -version-info=0:0:0 diff --git a/salome_adm/unix/Makefile.am b/salome_adm/unix/Makefile.am index b2d2a9a5f..0597e7822 100644 --- a/salome_adm/unix/Makefile.am +++ b/salome_adm/unix/Makefile.am @@ -34,7 +34,7 @@ DEPRECATED_FILES=\ # rules for install and build (see make_common_starter.am) salomeadmux_DATA = SALOMEconfig.h.in salomeinclude_DATA = SALOMEconfig.h -BUILT_SOURCES=SALOMEconfig.h SALOMEconfig.h.in +BUILT_SOURCES=SALOMEconfig.ref SALOMEconfig.h SALOMEconfig.h.in mostlyclean-local: -rm -rf SALOMEconfig.h SALOMEconfig.h.in @@ -45,9 +45,11 @@ SALOMEconfig.h.in : SALOMEconfig.ref.in # test if SALOMEconfig.ref has changed (contents), at build time SALOMEconfig.h: $(top_builddir)/salome_adm/unix/SALOMEconfig.ref @if ! [ -a $@ ]; then \ + echo cp -p $< $@; \ cp -p $< $@; \ fi; \ - if ! cmp $< $@; then \ + if ! cmp -s $< $@; then \ + echo cp -p $< $@; \ cp -p $< $@; \ fi; diff --git a/salome_adm/unix/SALOMEconfig.ref.in b/salome_adm/unix/SALOMEconfig.ref.in index 78688bd88..923fef356 100644 --- a/salome_adm/unix/SALOMEconfig.ref.in +++ b/salome_adm/unix/SALOMEconfig.ref.in @@ -71,4 +71,8 @@ #undef PACKAGE_VERSION #endif +#ifdef _POSIX_C_SOURCE +#undef _POSIX_C_SOURCE +#endif + #endif diff --git a/salome_adm/unix/config_files/check_cas.m4 b/salome_adm/unix/config_files/check_cas.m4 index ab2ba319d..1eade7949 100644 --- a/salome_adm/unix/config_files/check_cas.m4 +++ b/salome_adm/unix/config_files/check_cas.m4 @@ -188,8 +188,7 @@ if test "x$occ_ok" = xyes ; then AC_CACHE_VAL(salome_cv_lib_occ,[ AC_TRY_LINK( #include -, size_t size; - TCollection_AsciiString aStr ("toto"); +, TCollection_AsciiString aStr ("toto"); aStr.Capitalize();, eval "salome_cv_lib_occ=yes",eval "salome_cv_lib_occ=no") ]) diff --git a/src/Basics/BasicsGenericDestructor.cxx b/src/Basics/BasicsGenericDestructor.cxx index 9c1e21300..deca0e9c9 100644 --- a/src/Basics/BasicsGenericDestructor.cxx +++ b/src/Basics/BasicsGenericDestructor.cxx @@ -172,6 +172,7 @@ void HouseKeeping( void ) delete GENERIC_DESTRUCTOR::Destructors; GENERIC_DESTRUCTOR::Destructors = 0; + atExitSingletonDone = false ; DEVTRACE("HouseKeeping() very end "); return ; } diff --git a/src/Batch/Batch_Date.cxx b/src/Batch/Batch_Date.cxx index a657696ac..b228a5ddc 100644 --- a/src/Batch/Batch_Date.cxx +++ b/src/Batch/Batch_Date.cxx @@ -124,7 +124,7 @@ namespace Batch { _sec = p_tm->tm_sec; } else { - char c; +// char c; // istringstream ist(s); // ist >> _day >> c // >> _month >> c diff --git a/src/Batch/Batch_Versatile.cxx b/src/Batch/Batch_Versatile.cxx index ad778fa14..58dfacc87 100644 --- a/src/Batch/Batch_Versatile.cxx +++ b/src/Batch/Batch_Versatile.cxx @@ -184,7 +184,7 @@ namespace Batch { ostream & operator << (ostream & os, const Versatile & V) { Versatile::const_iterator it; - char * sep = ""; + const char * sep = ""; for(it=V.begin(); it!=V.end(); it++, sep=" ") { string s = (*it)->affiche(); diff --git a/src/Communication_SWIG/libSALOME_Comm.i b/src/Communication_SWIG/libSALOME_Comm.i index 4ff9731e8..f27bc4f3c 100644 --- a/src/Communication_SWIG/libSALOME_Comm.i +++ b/src/Communication_SWIG/libSALOME_Comm.i @@ -43,7 +43,7 @@ // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string - PyObject* iorSupport = PyObject_CallMethod(orb, "object_to_string", "O", $input); + PyObject* iorSupport = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input); if (iorSupport == Py_None) return NULL; @@ -52,7 +52,7 @@ // Ask omniORB to convert IOR string to SALOME::SenderDouble_ptr int argc = 0; - char *xargv = ""; + char *xargv = (char*)""; char **argv = &xargv; CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); CORBA::Object_var O = ORB->string_to_object(s); @@ -73,7 +73,7 @@ // Ask omniORBpy to transform SUPPORT (python Corba) ptr to IOR string - PyObject* iorSupport = PyObject_CallMethod(orb, "object_to_string", "O", $input); + PyObject* iorSupport = PyObject_CallMethod(orb, (char*)"object_to_string", (char*)"O", $input); if (iorSupport == Py_None) return NULL; @@ -82,7 +82,7 @@ // Ask omniORB to convert IOR string to SALOME::SenderInt_ptr int argc = 0; - char *xargv = ""; + char *xargv = (char*)""; char **argv = &xargv; CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); CORBA::Object_var O = ORB->string_to_object(s); @@ -100,12 +100,12 @@ PyObject* orb = PyDict_GetItemString(pdict, "o"); // Get the orb Corba C++ int argc = 0; - char *xargv = ""; + char *xargv = (char*)""; char **argv = &xargv; CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); std::string s = ORB->object_to_string($1); PyObject * tmp = PyString_FromString(s.c_str()); - $result = PyObject_CallMethod(orb, "string_to_object", "O", tmp); + $result = PyObject_CallMethod(orb, (char*)"string_to_object", (char*)"O", tmp); } %typemap(python,out) SALOME::SenderInt_ptr @@ -118,12 +118,12 @@ PyObject* orb = PyDict_GetItemString(pdict, "o"); // Get the orb Corba C++ int argc = 0; - char *xargv = ""; + char *xargv = (char*)""; char **argv = &xargv; CORBA::ORB_var ORB = CORBA::ORB_init(argc, argv); std::string s = ORB->object_to_string($1); PyObject * tmp = PyString_FromString(s.c_str()); - $result = PyObject_CallMethod(orb, "string_to_object", "O", tmp); + $result = PyObject_CallMethod(orb, (char*)"string_to_object", (char*)"O", tmp); } PyObject * getValueForSenderDouble(SALOME::SenderDouble_ptr senderDouble); @@ -140,7 +140,7 @@ PyObject * getValueForSenderDouble(SALOME::SenderDouble_ptr senderDouble) int err = PyList_SetItem(py_list, i, Py_BuildValue("d", (double) ret[i])); if(err) { - char * message = "Error in SUPPORT::getTypes"; + const char * message = "Error in SUPPORT::getTypes"; PyErr_SetString(PyExc_RuntimeError, message); return NULL; } @@ -167,7 +167,7 @@ PyObject * getValueForSenderInt(SALOME::SenderInt_ptr senderInt) int err = PyList_SetItem(py_list, i, Py_BuildValue("i", (int) ret[i])); if(err) { - char * message = "Error in SUPPORT::getTypes"; + const char * message = "Error in SUPPORT::getTypes"; PyErr_SetString(PyExc_RuntimeError, message); return NULL; } @@ -195,7 +195,7 @@ PyObject * getValueForMatrix(SALOME::Matrix_ptr matrix) int err = PyList_SetItem(tmpRow, j, Py_BuildValue("d", (double) ret[i*column+j])); if(err) { - char * message = "PyList_SetItem matrix sent may be invalid"; + const char * message = "PyList_SetItem matrix sent may be invalid"; PyErr_SetString(PyExc_RuntimeError, message); return NULL; } diff --git a/src/Container/Component_i.cxx b/src/Container/Component_i.cxx index 867411196..885750da9 100644 --- a/src/Container/Component_i.cxx +++ b/src/Container/Component_i.cxx @@ -295,8 +295,8 @@ void Engines_Component_i::destroy() delete _myConnexionToRegistry; _myConnexionToRegistry = 0 ; - _poa->deactivate_object(*_id) ; - delete(_id) ; + if(_id) + delete(_id) ; //SCRUTE(pd_refCount); _thisObj->_remove_ref(); //SCRUTE(pd_refCount); diff --git a/src/Container/Container_i.cxx b/src/Container/Container_i.cxx index 0095b0bc5..985fd4e42 100644 --- a/src/Container/Container_i.cxx +++ b/src/Container/Container_i.cxx @@ -480,8 +480,8 @@ Engines_Container_i::load_component_Library(const char* componentName) PyObject *globals = PyModule_GetDict(mainmod); PyObject *pyCont = PyDict_GetItemString(globals, "pyCont"); PyObject *result = PyObject_CallMethod(pyCont, - "import_component", - "s",componentName); + (char*)"import_component", + (char*)"s",componentName); int ret= PyInt_AsLong(result); Py_XDECREF(result); SCRUTE(ret); @@ -557,8 +557,8 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName, PyObject *globals = PyModule_GetDict(mainmod); PyObject *pyCont = PyDict_GetItemString(globals, "pyCont"); PyObject *result = PyObject_CallMethod(pyCont, - "create_component_instance", - "ssl", + (char*)"create_component_instance", + (char*)"ssl", aCompName.c_str(), instanceName.c_str(), studyId); @@ -655,7 +655,7 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName, } else { - int count=10; + int count=20; CORBA::Object_var obj = CORBA::Object::_nil() ; while ( CORBA::is_nil(obj) && count ) { @@ -678,6 +678,7 @@ Engines_Container_i::create_component_instance(const char*genericRegisterName, { MESSAGE("SALOME_Container::create_component_instance successful"); iobject=Engines::Component::_narrow(obj); + _listInstances_map[instanceName] = iobject; return iobject._retn(); } } @@ -1075,8 +1076,12 @@ Engines_Container_i::createInstance(string genericRegisterName, SCRUTE(aGenRegisterName); SCRUTE(_cntInstances_map[aGenRegisterName]); //SCRUTE(servant->pd_refCount); +#if defined(_DEBUG_) || defined(_DEBUG) bool ret_studyId = servant->setStudyId(studyId); ASSERT(ret_studyId); +#else + servant->setStudyId(studyId); +#endif // --- register the engine under the name // containerName(.dir)/instanceName(.object) diff --git a/src/Container/Container_init_python.hxx b/src/Container/Container_init_python.hxx index dcdaed6e1..d81ac5760 100644 --- a/src/Container/Container_init_python.hxx +++ b/src/Container/Container_init_python.hxx @@ -30,6 +30,7 @@ #define _CONTAINER_INIT_PYTHON_HXX_ #include +#include #include // must be before Python.h ! #include @@ -50,7 +51,7 @@ #define Py_ACQUIRE_NEW_THREAD \ PyEval_AcquireLock(); \ PyThreadState *myTstate = PyThreadState_New(KERNEL_PYTHON::_interp); \ - PyThreadState *myoldTstate = PyThreadState_Swap(myTstate); + PyThreadState_Swap(myTstate); #define Py_RELEASE_NEW_THREAD \ PyEval_ReleaseThread(myTstate); \ diff --git a/src/Container/SALOME_ComponentPy.py b/src/Container/SALOME_ComponentPy.py index 5d071b8e4..77f89ac47 100755 --- a/src/Container/SALOME_ComponentPy.py +++ b/src/Container/SALOME_ComponentPy.py @@ -147,8 +147,9 @@ class SALOME_ComponentPy_i (Engines__POA.Component): def destroy(self): MESSAGE( "SALOME_ComponentPy_i::destroy" ) - id = self._poa.servant_to_id(self) - self._poa.deactivate_object(id) + #id = self._poa.servant_to_id(self) + #self._poa.deactivate_object(id) + return #------------------------------------------------------------------------- diff --git a/src/Container/SALOME_Container.cxx b/src/Container/SALOME_Container.cxx index 39812040d..61401e7f0 100644 --- a/src/Container/SALOME_Container.cxx +++ b/src/Container/SALOME_Container.cxx @@ -142,8 +142,8 @@ int main(int argc, char* argv[]) if (!isSupervContainer) { - int _argc = 1; - char* _argv[] = {""}; + // int _argc = 1; + // char* _argv[] = {""}; KERNEL_PYTHON::init_python(argc,argv); } else @@ -152,7 +152,7 @@ int main(int argc, char* argv[]) PySys_SetArgv( argc , argv ) ; } - char *containerName = ""; + char *containerName = (char *)""; if(argc > 1) { containerName = argv[1] ; @@ -173,8 +173,7 @@ int main(int argc, char* argv[]) system(aCommand.str().c_str()); #endif - Engines_Container_i * myContainer - = new Engines_Container_i(orb, root_poa, containerName , argc , argv ); + new Engines_Container_i(orb, root_poa, containerName , argc , argv ); pman->activate(); @@ -189,7 +188,7 @@ int main(int argc, char* argv[]) if (!isSupervContainer) { - PyGILState_STATE gstate = PyGILState_Ensure(); + PyGILState_Ensure(); //Delete python container that destroy orb from python (pyCont._orb.destroy()) Py_Finalize(); } diff --git a/src/Container/SALOME_Container.py b/src/Container/SALOME_Container.py index 179150954..405d1f963 100644 --- a/src/Container/SALOME_Container.py +++ b/src/Container/SALOME_Container.py @@ -64,8 +64,8 @@ class SALOME_Container_i: #------------------------------------------------------------------------- - def __del__(self ): - self._orb.destroy() + #def __del__(self ): + # self._orb.destroy() def import_component(self, componentName): MESSAGE( "SALOME_Container_i::import_component" ) diff --git a/src/Container/SALOME_ContainerManager.cxx b/src/Container/SALOME_ContainerManager.cxx index 20f46f6d7..8d887aed8 100644 --- a/src/Container/SALOME_ContainerManager.cxx +++ b/src/Container/SALOME_ContainerManager.cxx @@ -280,10 +280,19 @@ StartContainer(const Engines::MachineParameters& params, CORBA::Object_var obj = _NS->Resolve(containerNameInNS.c_str()); if ( !CORBA::is_nil(obj) ) { - // unregister the registered container if it exists - _NS->Destroy_Name(containerNameInNS.c_str()); - // unregister component instances ??? - //Engines::Container_var cont=Engines::Container::_narrow(obj); + // shutdown the registered container if it exists + Engines::Container_var cont=Engines::Container::_narrow(obj); + if(!CORBA::is_nil(cont)) + { + try + { + cont->Shutdown(); + } + catch(CORBA::Exception&) + { + INFOS("CORBA::Exception ignored."); + } + } } //redirect stdout and stderr in a file @@ -367,9 +376,7 @@ StartContainer(const Engines::MachineParameters& params, SALOME_ModuleCatalog::Acomponent_var compoInfo = Catalog->GetComponent(compoi); if (CORBA::is_nil (compoInfo)) { - INFOS("ContainerManager Error: Component not found in the catalog" ); - INFOS( compoi ); - return Engines::Container::_nil(); + continue; } SALOME_ModuleCatalog::ImplType impl=compoInfo->implementation_type(); container_exe=compoInfo->implementation_name(); diff --git a/src/Container/SALOME_Container_SignalsHandler.cxx b/src/Container/SALOME_Container_SignalsHandler.cxx index cb1117ed7..6f4d1b6a8 100644 --- a/src/Container/SALOME_Container_SignalsHandler.cxx +++ b/src/Container/SALOME_Container_SignalsHandler.cxx @@ -18,8 +18,10 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +#include #include #include + #include "utilities.h" // CCRT porting diff --git a/src/Container/SALOME_FileRef_i.cxx b/src/Container/SALOME_FileRef_i.cxx index 7dfa311b9..3fda8667f 100644 --- a/src/Container/SALOME_FileRef_i.cxx +++ b/src/Container/SALOME_FileRef_i.cxx @@ -53,8 +53,12 @@ fileRef_i::fileRef_i(Engines::Container_ptr container, _container = Engines::Container::_duplicate(container); _origFileName = origFileName; _machine = GetHostname(); +#if defined(_DEBUG_) || defined(_DEBUG) int OK = addRef(_machine.c_str(), _origFileName.c_str()); SCRUTE(OK); +#else + addRef(_machine.c_str(), _origFileName.c_str()); +#endif } diff --git a/src/Container/Salome_file_i.cxx b/src/Container/Salome_file_i.cxx index d2cbb1d6e..89aae57db 100644 --- a/src/Container/Salome_file_i.cxx +++ b/src/Container/Salome_file_i.cxx @@ -838,8 +838,12 @@ Salome_file_i::getDistributedFile(std::string file_name) aBlock = _fileDistributedSource[file_name]->getBlock(fileId); toFollow = aBlock->length(); CORBA::Octet *buf = aBlock->get_buffer(); +#if defined(_DEBUG_) || defined(_DEBUG) int nbWri = fwrite(buf, sizeof(CORBA::Octet), toFollow, fp); ASSERT(nbWri == toFollow); +#else + fwrite(buf, sizeof(CORBA::Octet), toFollow, fp); +#endif delete aBlock; } fclose(fp); diff --git a/src/DF/testDF.cxx b/src/DF/testDF.cxx index 69dd8920c..ee457316f 100644 --- a/src/DF/testDF.cxx +++ b/src/DF/testDF.cxx @@ -186,9 +186,9 @@ int main (int argc, char * argv[]) cout << "Test started " << endl; DF_Application* appli = new DF_Application; + /* DF_Document* doc1 = appli->NewDocument("doc_1"); - /* DF_Label root1 = doc1->Main(); DF_Label child = root1.FindChild(3, true); //0:1:3 diff --git a/src/DSC/DSC_Python/calcium.i b/src/DSC/DSC_Python/calcium.i index dddf3aa06..90d135d8d 100644 --- a/src/DSC/DSC_Python/calcium.i +++ b/src/DSC/DSC_Python/calcium.i @@ -38,6 +38,7 @@ struct omniORBpyAPI { }; omniORBpyAPI* api; + PyObject* dsc ; %} @@ -60,6 +61,9 @@ struct omniORBpyAPI { PyObject* pyapi = PyObject_GetAttrString(omnipy, (char*)"API"); api = (omniORBpyAPI*)PyCObject_AsVoidPtr(pyapi); Py_DECREF(pyapi); + + PyObject* engines = PyImport_ImportModule("Engines"); + dsc = PyObject_GetAttrString(engines, "DSC"); %} %include @@ -78,6 +82,9 @@ struct omniORBpyAPI { #ifdef WITH_NUMPY /* With Numpy */ +#ifdef HAVE_ISINF +#undef HAVE_ISINF +#endif #include typedef PyArrayObject ArrayObject; @@ -92,7 +99,7 @@ typedef PyArrayObject ArrayObject; /* Given a PyObject, return a string describing its type. */ -char* pytype_string(PyObject* py_obj) { +const char* pytype_string(PyObject* py_obj) { if (py_obj == NULL ) return "C NULL value"; if (PyCallable_Check(py_obj)) return "callable" ; if (PyString_Check( py_obj)) return "string" ; @@ -148,8 +155,8 @@ enum NPY_TYPECHAR { NPY_BOOLLTR = '?', /* Given a Numeric typecode, return a string describing the type. */ -char* typecode_string(int typecode) { - char* type_names[] = {"bool","byte","unsigned byte","short", +const char* typecode_string(int typecode) { + const char* type_names[] = {"bool","byte","unsigned byte","short", "unsigned short","int","unsigned int","long","unsigned long", "longlong","unsigned longlong", "float","double","long double","complex float","complex double","complex long double", @@ -176,16 +183,16 @@ PyArrayObject* obj_to_array_no_conversion(PyObject* input, int typecode) { ary = (PyArrayObject*) input; } else if is_array(input) { - char* desired_type = typecode_string(typecode); - char* actual_type = typecode_string(array_type(input)); + const char* desired_type = typecode_string(typecode); + const char* actual_type = typecode_string(array_type(input)); PyErr_Format(PyExc_TypeError, "Array of type '%s' required. Array of type '%s' given", desired_type, actual_type); ary = NULL; } else { - char * desired_type = typecode_string(typecode); - char * actual_type = pytype_string(input); + const char * desired_type = typecode_string(typecode); + const char * actual_type = pytype_string(input); PyErr_Format(PyExc_TypeError, "Array of type '%s' required. A %s was given", desired_type, actual_type); @@ -418,10 +425,10 @@ struct stringArray %define TYPEMAP_IN3(type,typecode) %typemap(in) type* IN_ARRAY3 (ArrayObject* array=NULL, int is_new_object) { - int size[1] = {-1}; if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,0)) == -1) { %#ifdef WITH_NUMPY + int size[1] = {-1}; array = obj_to_array_contiguous_allow_conversion($input, typecode, &is_new_object); if (!array || !require_dimensions(array,1) || !require_size(array,size,1)) SWIG_fail; $1 = (type*) array->data; @@ -448,10 +455,10 @@ TYPEMAP_IN3(double, PyArray_DOUBLE) /* Specific typemap for complex */ %typemap(in) float* ecpval (ArrayObject* array=NULL, int is_new_object) { - int size[1] = {-1}; if ((SWIG_ConvertPtr($input, (void **) &$1, $1_descriptor,0)) == -1) { %#ifdef WITH_NUMPY + int size[1] = {-1}; array = obj_to_array_contiguous_allow_conversion($input, PyArray_CFLOAT, &is_new_object); if (!array || !require_dimensions(array,1) || !require_size(array,size,1)) SWIG_fail; $1 = (float*) array->data; @@ -468,11 +475,11 @@ TYPEMAP_IN3(double, PyArray_DOUBLE) /* array of strings on input */ %typemap(in) char** eval (ArrayObject* array=NULL, int is_new_object) { - int size[1] = {-1}; stringArray* sarray; if ((SWIG_ConvertPtr($input, (void **) &sarray, $descriptor(stringArray *),0)) == -1) { %#ifdef WITH_NUMPY + int size[1] = {-1}; array = obj_to_array_contiguous_allow_conversion($input, PyArray_STRING, &is_new_object); if (!array || !require_dimensions(array,1) || !require_size(array,size,1)) SWIG_fail; $1 = (char**) malloc(array_size(array,0)*sizeof(char*)); @@ -508,6 +515,7 @@ TYPEMAP_IN3(double, PyArray_DOUBLE) if (!temp || !require_contiguous(temp)) SWIG_fail; $1 = (type*) temp->data; %#else + temp = NULL; SWIG_exception(SWIG_TypeError, "type* expected"); %#endif } @@ -534,6 +542,7 @@ TYPEMAP_INPLACE3(double, PyArray_DOUBLE) if (!temp || !require_contiguous(temp)) SWIG_fail; $1 = (float*) temp->data; %#else + temp = NULL; SWIG_exception(SWIG_TypeError, "complex array expected"); %#endif } @@ -553,6 +562,7 @@ TYPEMAP_INPLACE3(double, PyArray_DOUBLE) for(int i=0;idata+i*temp->strides[0]; %#else + temp = NULL; SWIG_exception(SWIG_TypeError, "string array expected"); %#endif } @@ -570,6 +580,10 @@ TYPEMAP_INPLACE3(double, PyArray_DOUBLE) { $1=(CORBA::Boolean)PyInt_AsLong($input); } +%typemap(out) CORBA::Boolean +{ + $result=PyInt_FromLong($1 ? 1 : 0); +} %define CORBAPTR(type) %typemap(in) type##_ptr @@ -630,17 +644,29 @@ CORBAPTR(PortableServer::POA) } catch(Engines::DSC::PortNotDefined& _e) { Py_BLOCK_THREADS - PyErr_SetString(PyExc_ValueError,"Port not defined"); + PyObject* excc = PyObject_GetAttrString(dsc, "PortNotDefined"); + PyObject* exci = PyEval_CallObject(excc, (PyObject *)NULL); + PyErr_SetObject(excc, exci); + Py_XDECREF(excc); + Py_XDECREF(exci); return NULL; } catch(Engines::DSC::PortNotConnected& _e) { Py_BLOCK_THREADS - PyErr_SetString(PyExc_ValueError,"Port not connected"); + PyObject* excc = PyObject_GetAttrString(dsc, "PortNotConnected"); + PyObject* exci = PyEval_CallObject(excc, (PyObject *)NULL); + PyErr_SetObject(excc, exci); + Py_XDECREF(excc); + Py_XDECREF(exci); return NULL; } catch(Engines::DSC::BadPortType& _e) { Py_BLOCK_THREADS - PyErr_SetString(PyExc_ValueError,"Bad port type"); + PyObject* excc = PyObject_GetAttrString(dsc, "BadPortType"); + PyObject* exci = PyEval_CallObject(excc, (PyObject *)NULL); + PyErr_SetObject(excc, exci); + Py_XDECREF(excc); + Py_XDECREF(exci); return NULL; } catch (SALOME_Exception &e) { @@ -650,6 +676,7 @@ CORBAPTR(PortableServer::POA) } catch (SALOME::SALOME_Exception &e) { Py_BLOCK_THREADS + //This one should be converted into a python corba exception PyErr_SetString(PyExc_RuntimeError,e.details.text); return NULL; } @@ -750,6 +777,7 @@ class PySupervCompo:public Superv_Component_i virtual void add_provides_port(Ports::Port_ptr ref, const char* provides_port_name, Ports::PortProperties_ptr port_prop); virtual void add_uses_port(const char* repository_id, const char* uses_port_name, Ports::PortProperties_ptr port_prop); virtual Engines::DSC::uses_port * get_uses_port(const char* uses_port_name); + CORBA::Boolean is_connected(const char* port_name) throw (Engines::DSC::PortNotDefined); // End of DSC interface for python components diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx index a0e0a3e2f..969b510e8 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumCxxInterface.hxx @@ -54,11 +54,20 @@ struct IsSameType { }; +#include namespace CalciumInterface { /********************* INTERFACE DE DECONNEXION *****************/ + static inline void + ecp_cd (Superv_Component_i & component, std::string & instanceName) + { + /* TODO : Trouver le nom de l'instance SALOME*/ + if (instanceName.empty()) instanceName="UNDEFINED"; + + } + static void ecp_fin (Superv_Component_i & component, bool provideLastGivenValue) { @@ -142,22 +151,6 @@ namespace CalciumInterface { /********************* INTERFACES DE LECTURE *****************/ - // T1 est le type de données - template static void - ecp_lecture ( Superv_Component_i & component, - CalciumTypes::DependencyType dependencyType, - double & ti, - double const & tf, - long & i, - const string & nomVar, - size_t bufferLength, - size_t & nRead, - T1 * &data ) - { - ecp_lecture (component,dependencyType,ti,tf, - i,nomVar,bufferLength,nRead,data); - - } // T1 est le type de données // T2 est un de type Calcium permettant de sélectionner le port CORBA correspondant @@ -166,7 +159,7 @@ namespace CalciumInterface { // le port à utiliser est le port cplx template static void ecp_lecture ( Superv_Component_i & component, - CalciumTypes::DependencyType dependencyType, + int const & dependencyType, double & ti, double const & tf, long & i, @@ -182,7 +175,9 @@ namespace CalciumInterface { typedef typename PortType::DataManipulator DataManipulator; typedef typename DataManipulator::Type CorbaDataType; // Attention != T1 typedef typename DataManipulator::InnerType InnerType; - + CalciumTypes::DependencyType _dependencyType= + static_cast(dependencyType); + CorbaDataType corbaData; #ifdef _DEBUG_ @@ -228,21 +223,21 @@ namespace CalciumInterface { LOC(OSS()<<"Le mode de dépendance de la variable " << nomVar << " est indéfini.")); - if ( ( portDependencyType != dependencyType ) && - ( dependencyType != CalciumTypes::SEQUENCE_DEPENDENCY ) ) + if ( ( portDependencyType != _dependencyType ) && + ( _dependencyType != CalciumTypes::SEQUENCE_DEPENDENCY ) ) throw CalciumException(CalciumTypes::CPITVR, LOC(OSS()<<"Le mode de dépendance de la variable " << nomVar << ": " << portDependencyType << " ne correspond pas au mode demandé.")); - if ( dependencyType == CalciumTypes::TIME_DEPENDENCY ) { + if ( _dependencyType == CalciumTypes::TIME_DEPENDENCY ) { corbaData = port->get(ti,tf, 0); #ifdef _DEBUG_ std::cout << "-------- CalciumInterface(ecp_lecture) MARK 5 ------------------" << std::endl; #endif } - else if ( dependencyType == CalciumTypes::ITERATION_DEPENDENCY ) { + else if ( _dependencyType == CalciumTypes::ITERATION_DEPENDENCY ) { corbaData = port->get(0, i); #ifdef _DEBUG_ std::cout << "-------- CalciumInterface(ecp_lecture) MARK 6 ------------------" << std::endl; @@ -323,53 +318,68 @@ namespace CalciumInterface { return; } + // T1 est le type de données + template static void + ecp_lecture ( Superv_Component_i & component, + int const & dependencyType, + double & ti, + double const & tf, + long & i, + const string & nomVar, + size_t bufferLength, + size_t & nRead, + T1 * &data ) + { + ecp_lecture (component,dependencyType,ti,tf, + i,nomVar,bufferLength,nRead,data); + + } /********************* INTERFACES D'ECRITURE *****************/ - template static void - ecp_ecriture ( Superv_Component_i & component, - CalciumTypes::DependencyType dependencyType, - double const & t, - long const & i, - const string & nomVar, - size_t bufferLength, - T1 & data ) { - ecp_ecriture (component,dependencyType,t,i,nomVar,bufferLength,data); - } - + // T1 : DataType + // T2 : PortType template static void ecp_ecriture ( Superv_Component_i & component, - CalciumTypes::DependencyType dependencyType, + int const & dependencyType, double const & t, long const & i, const string & nomVar, size_t bufferLength, - T1 & data ) + T1 const & data ) { assert(&component); - //typedef typename StarTrait::NonStarType T; - typedef typename UsesPortTraits::PortType PortType; - typedef typename ProvidesPortTraits::PortType ProvidesPortType; - typedef typename ProvidesPortType::DataManipulator DataManipulator; + //typedef typename StarTrait::NonStarType T; + typedef typename boost::remove_all_extents< T2 >::type T2_without_extent; + typedef typename boost::remove_all_extents< T1 >::type T1_without_extent; + + typedef typename UsesPortTraits ::PortType UsesPortType; + typedef typename ProvidesPortTraits::PortType ProvidesPortType;// pour obtenir un manipulateur de données + typedef typename ProvidesPortType::DataManipulator DataManipulator; // Verifier que l'on peut définir UsesPortType::DataManipulator // typedef typename PortType::DataManipulator DataManipulator; - typedef typename DataManipulator::Type CorbaDataType; // Attention != T1 - typedef typename DataManipulator::InnerType InnerType; + typedef typename DataManipulator::Type CorbaDataType; // Attention != T1 + typedef typename DataManipulator::InnerType InnerType; + + T1_without_extent const & _data = data; + + CalciumTypes::DependencyType _dependencyType= + static_cast(dependencyType); #ifdef _DEBUG_ std::cerr << "-------- CalciumInterface(ecriture) MARK 1 ------------------" << std::endl; #endif if ( nomVar.empty() ) throw CalciumException(CalciumTypes::CPNMVR, LOC("Le nom de la variable est ")); - PortType * port; + UsesPortType * port; #ifdef _DEBUG_ std::cout << "-------- CalciumInterface(ecriture) MARK 2 ------------------" << std::endl; #endif try { - port = component.Superv_Component_i::get_port< PortType > (nomVar.c_str()); + port = component.Superv_Component_i::get_port< UsesPortType > (nomVar.c_str()); #ifdef _DEBUG_ std::cout << "-------- CalciumInterface(ecriture) MARK 3 ------------------" << std::endl; #endif @@ -404,12 +414,12 @@ namespace CalciumInterface { // throw (CalciumException(CalciumTypes::CPIT,ex)); // } - if ( dependencyType == CalciumTypes::UNDEFINED_DEPENDENCY ) + if ( _dependencyType == CalciumTypes::UNDEFINED_DEPENDENCY ) throw CalciumException(CalciumTypes::CPIT, LOC(OSS()<<"Le mode de dépendance demandé pour la variable " << nomVar << " est indéfini.")); - if ( dependencyType == CalciumTypes::SEQUENCE_DEPENDENCY ) + if ( _dependencyType == CalciumTypes::SEQUENCE_DEPENDENCY ) throw CalciumException(CalciumTypes::CPIT, LOC(OSS()<<"Le mode de dépendance SEQUENCE_DEPENDENCY pour la variable " << nomVar << " est impossible en écriture.")); @@ -419,7 +429,7 @@ namespace CalciumInterface { // et vice-versa pour informer les provides port du mode dans lequel on est. Sinon il faut // modifier l'interface IDL pour y ajouter un mode de dépendance ! // ----> -// if ( portDependencyType != dependencyType ) +// if ( portDependencyType != _dependencyType ) // throw CalciumException(CalciumTypes::CPITVR, // LOC(OSS()<<"Le mode de dépendance de la variable " // << nomVar << " ne correspond pas au mode demandé.")); @@ -448,7 +458,7 @@ namespace CalciumInterface { // OLD : la séquence locale. Or la méthode put récupère le buffer directement // OLD : qui est alors le buffer utilisateur. Il pourrait alors arriver que : // OLD : * Le recepteur efface le buffer emetteur - // OLD : * Le port lui-même efface le buffer de l'ulisateur ! + // OLD : * Le port lui-même efface le buffer de l'utilisateur ! // OLD : Cette copie est effectuée dans GenericPortUses::put // OLD : en fonction de la collocalisation ou non. // - OLD :En cas de connection multiples d'un port uses distant vers plusieurs port provides @@ -456,10 +466,10 @@ namespace CalciumInterface { // OLD : Il faut effectuer une copie dans le port provides. // OLD : Cette copie est effectuée dans GenericPortUses::put // OLD : en fonction de la collocalisation ou non. - Copy2CorbaSpace::value, DataManipulator >::apply(corbaData,data,bufferLength); + Copy2CorbaSpace::value, DataManipulator >::apply(corbaData,_data,bufferLength); //TODO : GERER LES EXCEPTIONS ICI : ex le port n'est pas connecté - if ( dependencyType == CalciumTypes::TIME_DEPENDENCY ) { + if ( _dependencyType == CalciumTypes::TIME_DEPENDENCY ) { try { port->put(*corbaData,t, -1); @@ -474,7 +484,7 @@ namespace CalciumInterface { std::cout << "-------- CalciumInterface(ecriture) MARK 5 ------------------" << std::endl; #endif } - else if ( dependencyType == CalciumTypes::ITERATION_DEPENDENCY ) { + else if ( _dependencyType == CalciumTypes::ITERATION_DEPENDENCY ) { try { port->put(*corbaData,-1, i); @@ -504,7 +514,18 @@ namespace CalciumInterface { #endif return; - } + }; + + template static void + ecp_ecriture ( Superv_Component_i & component, + int const & dependencyType, + double const & t, + long const & i, + const string & nomVar, + size_t bufferLength, + T1 const & data ) { + ecp_ecriture (component,dependencyType,t,i,nomVar,bufferLength,data); + }; }; diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx index 6f8fd6d97..9d90dfb7f 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumGenericProvidesPort.hxx @@ -58,22 +58,30 @@ public virtual POA_Ports::PortProperties, \ public GenericProvidesPort< __VA_ARGS__ , CalciumCouplingPolicy, calcium_provides_port > { \ private : \ - omni_semaphore _mustnotdisconnectyet; \ + omni_mutex _disconnect_mutex; \ + int _mustnotdisconnect; \ public : \ typedef __VA_ARGS__ DataManipulator; \ typedef DataManipulator::Type CorbaDataType; \ typedef GenericPort< DataManipulator , \ CalciumCouplingPolicy > Port; \ + specificPortName () : _mustnotdisconnect(0) {}; \ \ - specificPortName () :_mustnotdisconnectyet(0) {}; \ - \ virtual ~ specificPortName (); \ \ inline void disconnect(bool provideLastGivenValue) { \ - if (! _mustnotdisconnectyet.trywait() ) { \ - Port::disconnect(provideLastGivenValue); \ - } \ - } \ + _disconnect_mutex.lock(); \ + if(_mustnotdisconnect > 1) \ + { \ + _mustnotdisconnect--; \ + } \ + else if(_mustnotdisconnect == 1) \ + { \ + _mustnotdisconnect--; \ + Port::disconnect(provideLastGivenValue); \ + } \ + _disconnect_mutex.unlock(); \ + } \ inline void setDependencyType(CalciumTypes::DependencyType dependencyType) { \ Port::setDependencyType(dependencyType); \ } \ @@ -139,9 +147,15 @@ virtual void provides_port_changed(int connection_nbr, \ const Engines::DSC::Message message) { \ if ( message == Engines::DSC::AddingConnection) \ - _mustnotdisconnectyet.post(); \ + { \ + _disconnect_mutex.lock(); \ + _mustnotdisconnect++; \ + _disconnect_mutex.unlock(); \ + } \ else if ( message == Engines::DSC::RemovingConnection ) \ - disconnect(false); \ + { \ + disconnect(false); \ + } \ } \ }; \ diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx index 4d0ac6aac..5732b6601 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumInterface.hxx @@ -29,7 +29,7 @@ #ifndef _CALCIUM_INTERFACE_HXX_ #define _CALCIUM_INTERFACE_HXX_ -//Interface C++ +//Interface CALCIUM des utilisateurs en C++ #include "CalciumCxxInterface.hxx" #include "CalciumException.hxx" @@ -37,6 +37,9 @@ #include +//Ce fichier déclare et défini l'interfaçage entre l'API utilisteur C et C++ +//Les procédures déclarées n'ont pas vocation à être utilisées directement (celà est +// cependant possible). //#define _DEBUG_ #ifdef _DEBUG_ @@ -94,30 +97,28 @@ ecp_fin_ (void * component, int code) { double _tf=*tf; \ size_t _nRead=0; \ size_t _bufferLength=bufferLength; \ - CalciumTypes::DependencyType _dependencyType= \ - static_cast(dependencyType); \ \ if ( IsSameType< _name , cplx >::value ) _bufferLength*=2; \ DEBTRACE( "-------- CalciumInterface(lecture Inter Part) MARK 1 ------------------" ) \ try { \ CalciumInterface::ecp_lecture< _type, _name >( *_component, \ - _dependencyType, \ + dependencyType, \ _ti, _tf, *i, \ nomvar, \ _bufferLength, _nRead, *data); \ } catch ( const CalciumException & ex) { \ DEBTRACE( ex.what() ); \ return ex.getInfo(); \ - } catch ( ... ) { \ - std::cerr << "Unexpected exception " << std::endl; \ - return CalciumTypes::CPATAL; \ + } catch ( ... ) { \ + std::cerr << "Unexpected exception " << std::endl; \ + return CalciumTypes::CPATAL; \ } \ if ( IsSameType< _name , cplx >::value ) { *nRead=_nRead/2; \ DEBTRACE( "-------- CalciumInterface(lecture Inter Part) IsSameType cplx -------------" ) \ DEBTRACE( "-------- CalciumInterface(lecture Inter Part) _nRead : " << _nRead ) \ DEBTRACE( "-------- CalciumInterface(lecture Inter Part) *nRead : " << *nRead ) \ } else *nRead = _nRead; \ - if (_dependencyType == CalciumTypes::CP_SEQUENTIEL ) \ + if (dependencyType == CalciumTypes::CP_SEQUENTIEL ) \ *ti=(CalTimeType< _type _qual >::TimeType)(_ti); \ DEBTRACE( "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data ) \ return CalciumTypes::CPOK; \ @@ -142,10 +143,9 @@ ecp_fin_ (void * component, int code) { DEBTRACE( "-------- CalciumInterface(ecriture Inter Part) MARK 1 ------------------" ) \ try { \ /*printf("-------- CalciumInterface(ecriture Inter Part), cp_name : Nom de la var. de type %s : %s\n",#_type,nomvar);*/ \ - std::string essai(nomvar); \ - DEBTRACE( "----------->-" << nomvar ) \ + DEBTRACE( "----------->-" << nomvar ) \ CalciumInterface::ecp_ecriture< _type, _name >( *_component, \ - static_cast(dependencyType), \ + dependencyType, \ _t,i,nomvar,_bufferLength,*data); \ } catch ( const CalciumException & ex) { \ std::cerr << ex.what() << std::endl; \ @@ -195,7 +195,7 @@ CALCIUM_C2CPP_INTERFACE_(str,char*,); // double _tf=*tf; // size_t _nRead=0; // size_t _bufferLength=bufferLength; -// CalciumTypes::DependencyType _dependencyType= +// CalciumTypes::DependencyType dependencyType= // static_cast(dependencyType); // // - GERER POINTEUR NULL : NOTHING TODO @@ -204,7 +204,7 @@ CALCIUM_C2CPP_INTERFACE_(str,char*,); // DEBTRACE( "-------- CalciumInterface(lecture Inter Part) MARK 1 ------------------" ) // try { // CalciumInterface::ecp_lecture< char*, char* >( *_component, -// _dependencyType, +// dependencyType, // _ti, _tf, *i, // nomvar, // _bufferLength, _nRead, *data); @@ -215,7 +215,7 @@ CALCIUM_C2CPP_INTERFACE_(str,char*,); // *nRead = _nRead; -// if (_dependencyType == CalciumTypes::CP_SEQUENTIEL ) +// if (dependencyType == CalciumTypes::CP_SEQUENTIEL ) // *ti=(float)(_ti); // DEBTRACE( "-------- CalciumInterface(lecture Inter Part), Data Ptr :" << *data ) ; diff --git a/src/DSC/DSC_User/Datastream/Calcium/CalciumPortTraits.hxx b/src/DSC/DSC_User/Datastream/Calcium/CalciumPortTraits.hxx index ededf2609..874345e3a 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/CalciumPortTraits.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/CalciumPortTraits.hxx @@ -32,9 +32,10 @@ #include "Superv_Component_i.hxx" // PROVIDES PORT TRAITS -struct UnknownProvidesPortType {}; +template struct UnknownProvidesPortType {}; + template struct ProvidesPortTraits { - typedef UnknownProvidesPortType PortType; + typedef UnknownProvidesPortType PortType; }; template <> struct ProvidesPortTraits { typedef calcium_integer_port_provides PortType; @@ -70,9 +71,9 @@ template < typename T > struct StarTrait< T * > { typedef T NonStarType; }; // USES PORT TRAITS -struct UnknownUsesPortType {}; +template struct UnknownUsesPortType {}; template struct UsesPortTraits { - typedef UnknownUsesPortType PortType; + typedef UnknownUsesPortType PortType; }; template <> struct UsesPortTraits { typedef calcium_integer_port_uses PortType; diff --git a/src/DSC/DSC_User/Datastream/Calcium/Copy2CorbaSpace.hxx b/src/DSC/DSC_User/Datastream/Calcium/Copy2CorbaSpace.hxx index a7210e851..0ff10190d 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/Copy2CorbaSpace.hxx +++ b/src/DSC/DSC_User/Datastream/Calcium/Copy2CorbaSpace.hxx @@ -37,18 +37,21 @@ template struct Copy2CorbaSpace { template - static void apply( T1 * & corbaData, T2 & data, size_t nRead){ + static void apply( T1 * & corbaData, T2 const & data, size_t nRead){ typedef typename ProvidesPortTraits::PortType PortType; //typedef typename UsesPortTraits::PortType PortType; -//ESSAI: typedef typename PortType::DataManipulator DataManipulator; + //ESSAI: typedef typename PortType::DataManipulator DataManipulator; typedef typename DataManipulator::InnerType InnerType; #ifdef _DEBUG_ std::cerr << "-------- Copy2CorbaSpace MARK 1 ------------------" << std::endl; #endif - // Crée le type corba à partir du data sans lui en donner la propriété - corbaData = DataManipulator::create(nRead,&data,false); + // Crée le type corba à partir du data sans lui en donner la propriété. + // Le const_cast supprime le caractère const du type T2 const & de data car + // DataManipulator::create n'a pas le caractère const sur son paramètre data pour le + // cas de figure où la propriété de la donnée lui est donnée. + corbaData = DataManipulator::create(nRead,const_cast (&data),false); #ifdef _DEBUG_ std::cerr << "-------- Copy2CorbaSpace MARK 2 --(dataPtr : " << DataManipulator::getPointer(corbaData,false)<<")----------------" << std::endl; @@ -62,7 +65,7 @@ template struct Copy2CorbaSpace { template - static void apply( T1 * & corbaData, T2 & data, size_t nRead){ + static void apply( T1 * & corbaData, T2 const & data, size_t nRead){ typedef typename ProvidesPortTraits::PortType PortType; // typedef typename UsesPortTraits::PortType PortType; diff --git a/src/DSC/DSC_User/Datastream/Calcium/Makefile.am b/src/DSC/DSC_User/Datastream/Calcium/Makefile.am index 3792dc9a2..da5a20b88 100644 --- a/src/DSC/DSC_User/Datastream/Calcium/Makefile.am +++ b/src/DSC/DSC_User/Datastream/Calcium/Makefile.am @@ -79,7 +79,7 @@ COMMON_CPPFLAGS= -I$(top_srcdir)/src/DSC/DSC_User \ -I$(top_srcdir)/src/Utils \ -I$(top_srcdir)/src/Container \ -I$(top_srcdir)/src/Notification \ - -I$(top_builddir)/salome_adm/unix \ + -I$(top_builddir)/salome_adm/unix -include SALOMEconfig.h \ -I$(top_builddir)/idl \ @CORBA_CXXFLAGS@ @CORBA_INCLUDES@ @BOOST_CPPFLAGS@ diff --git a/src/DSC/DSC_User/Datastream/Palm/test_DataIdContainer.cxx b/src/DSC/DSC_User/Datastream/Palm/test_DataIdContainer.cxx index aea01def9..8f883d1b6 100644 --- a/src/DSC/DSC_User/Datastream/Palm/test_DataIdContainer.cxx +++ b/src/DSC/DSC_User/Datastream/Palm/test_DataIdContainer.cxx @@ -35,7 +35,7 @@ public: std::cout << "------------ TEST1 --------------" << std::endl; - int ret=0; + // int ret=0; CORBA::Long time=1,tag=1; typedef PalmCouplingPolicy::DataIdContainer DataIdContainer; @@ -76,7 +76,7 @@ public: std::cout << "------------ TEST2 --------------" << std::endl; - int ret=0; + // int ret=0; CORBA::Long time=1,tag=1; typedef PalmCouplingPolicy::DataIdContainer DataIdContainer; diff --git a/src/DSC/DSC_User/Datastream/fake.cc b/src/DSC/DSC_User/Datastream/fake.cc index ca947860d..935c717a6 100644 --- a/src/DSC/DSC_User/Datastream/fake.cc +++ b/src/DSC/DSC_User/Datastream/fake.cc @@ -23,5 +23,5 @@ // Author : Eric Fayolle (EDF) // Module : KERNEL void fake_method(void) { -int fake_int; + // int fake_int; }; diff --git a/src/HDFPersist/HDFfile.cc b/src/HDFPersist/HDFfile.cc index e2b898bbb..96c763598 100644 --- a/src/HDFPersist/HDFfile.cc +++ b/src/HDFPersist/HDFfile.cc @@ -125,7 +125,7 @@ void HDFfile::InternalObjectIndentify(int rank, char *object_name) throw HDFexception("Can't identify an internal object"); } -int HDFfile::ExistInternalObject(char *object_name) +int HDFfile::ExistInternalObject(const char *object_name) { int n,i; int ret = 0; diff --git a/src/HDFPersist/HDFfile.hxx b/src/HDFPersist/HDFfile.hxx index 51c9aa7f1..b1d32881f 100644 --- a/src/HDFPersist/HDFfile.hxx +++ b/src/HDFPersist/HDFfile.hxx @@ -51,7 +51,7 @@ public : int nInternalObjects(); void InternalObjectIndentify(int rank, char *object_name); - int ExistInternalObject(char *object_name); + int ExistInternalObject(const char *object_name); hdf_object_type InternalObjectType(char *object_name); int nAttributes(); diff --git a/src/HDFPersist/HDFgroup.cc b/src/HDFPersist/HDFgroup.cc index 2b0f2fb19..d754e0496 100644 --- a/src/HDFPersist/HDFgroup.cc +++ b/src/HDFPersist/HDFgroup.cc @@ -100,7 +100,7 @@ void HDFgroup::InternalObjectIndentify(int rank, char *object_name) throw HDFexception("Can't identify an internal object"); } -int HDFgroup::ExistInternalObject(char *object_name) +int HDFgroup::ExistInternalObject(const char *object_name) { int n,i; int ret = 0; diff --git a/src/HDFPersist/HDFgroup.hxx b/src/HDFPersist/HDFgroup.hxx index 8c0d02b88..07e79e36e 100644 --- a/src/HDFPersist/HDFgroup.hxx +++ b/src/HDFPersist/HDFgroup.hxx @@ -56,7 +56,7 @@ public : int nInternalObjects(); void InternalObjectIndentify(int rank, char *object_name); - int ExistInternalObject(char *object_name); + int ExistInternalObject(const char *object_name); hdf_object_type InternalObjectType(char *object_name); int nAttributes(); diff --git a/src/HDFPersist/HDFnObjects.c b/src/HDFPersist/HDFnObjects.c index ac48c4a41..19e08dbae 100644 --- a/src/HDFPersist/HDFnObjects.c +++ b/src/HDFPersist/HDFnObjects.c @@ -39,7 +39,7 @@ SALOME HDFPersist : implementation of HDF persitent ( save/ restore ) hdf_err Num(hdf_idt id,const char *name, void *data); hdf_err -HDFnObjects(hdf_idt fid,char *path,int *n) +HDFnObjects(hdf_idt fid,const char *path,int *n) { int idx; int m = 0; diff --git a/src/HDFPersist/HDFobject.hxx b/src/HDFPersist/HDFobject.hxx index 3c829822a..9dafc4447 100644 --- a/src/HDFPersist/HDFobject.hxx +++ b/src/HDFPersist/HDFobject.hxx @@ -31,7 +31,7 @@ extern "C" { #include "HDFtypes.h" } -#include +#include "HDFexport.hxx" class HDF_EXPORT HDFobject { protected : diff --git a/src/HDFPersist/HDFobjectIdentify.c b/src/HDFPersist/HDFobjectIdentify.c index e5919d9e8..8e87e3932 100644 --- a/src/HDFPersist/HDFobjectIdentify.c +++ b/src/HDFPersist/HDFobjectIdentify.c @@ -40,7 +40,7 @@ SALOME HDFPersist : implementation of HDF persitent ( save/ restore ) hdf_err RankInfo(hdf_idt id, const char *name, void *data); -hdf_err HDFobjectIdentify(hdf_idt fid,char *path,int i,char *name) +hdf_err HDFobjectIdentify(hdf_idt fid,const char *path,int i,char *name) { int idx; diff --git a/src/HDFPersist/hdfi.h b/src/HDFPersist/hdfi.h index 5bdc62da6..d5115dd20 100644 --- a/src/HDFPersist/hdfi.h +++ b/src/HDFPersist/hdfi.h @@ -115,10 +115,10 @@ void HDFerrorModeLock(); extern hdf_err -HDFnObjects(hdf_idt fid,char *path,int *n); +HDFnObjects(hdf_idt fid,const char *path,int *n); extern -hdf_err HDFobjectIdentify(hdf_idt fid,char *path,int i,char *name); +hdf_err HDFobjectIdentify(hdf_idt fid,const char *path,int i,char *name); extern hdf_err HDFobjectType(hdf_idt id, char *name, hdf_object_type *type); diff --git a/src/Launcher/SALOME_LauncherServer.cxx b/src/Launcher/SALOME_LauncherServer.cxx index 5913d0ffb..a79dc3f91 100644 --- a/src/Launcher/SALOME_LauncherServer.cxx +++ b/src/Launcher/SALOME_LauncherServer.cxx @@ -32,7 +32,7 @@ void AttachDebugger() { std::stringstream exec; exec << "$DEBUGGER SALOME_LauncherServer " << getpid() << "&"; - std::cerr << exec.str() << std::endl; + MESSAGE ( exec.str() ); system(exec.str().c_str()); while(1); } @@ -40,13 +40,13 @@ void AttachDebugger() void terminateHandler(void) { - std::cerr << "Terminate: not managed exception !" << std::endl; + MESSAGE ( "Terminate: not managed exception !" ); AttachDebugger(); } void unexpectedHandler(void) { - std::cerr << "Unexpected: unexpected exception !" << std::endl; + MESSAGE ( "Unexpected: unexpected exception !" ); AttachDebugger(); } diff --git a/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx b/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx index 895c53581..4ce5d8b97 100644 --- a/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_FileTransferCORBA.cxx @@ -183,9 +183,13 @@ string SALOME_FileTransferCORBA::getLocalFile(string localFile) toFollow = aBlock->length(); SCRUTE(toFollow); CORBA::Octet *buf = aBlock->get_buffer(); +#if defined(_DEBUG_) || defined(_DEBUG) int nbWri = fwrite(buf, sizeof(CORBA::Octet), toFollow, fp); - delete aBlock; ASSERT(nbWri == toFollow); +#else + fwrite(buf, sizeof(CORBA::Octet), toFollow, fp); +#endif + delete aBlock; } fclose(fp); MESSAGE("end of transfer"); diff --git a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx index d1b105a37..9b399893d 100644 --- a/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx +++ b/src/LifeCycleCORBA/SALOME_LifeCycleCORBA.cxx @@ -82,7 +82,7 @@ SALOME_LifeCycleCORBA::SALOME_LifeCycleCORBA(SALOME_NamingService *ns) // be sure to have an instance of traceCollector, when used via SWIG // in a Python module int argc = 0; - char *xargv = ""; + char *xargv = (char*)""; char **argv = &xargv; CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); // LocalTraceCollector *myThreadTrace = SALOMETraceCollector::instance(orb); diff --git a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx index 2c724e369..7a047fd38 100644 --- a/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx +++ b/src/LifeCycleCORBA/Test/LifeCycleCORBATest.cxx @@ -64,7 +64,7 @@ LifeCycleCORBATest::setUp() bp1->deleteInstance(bp1); // --- trace on file - char *theFileName = TRACEFILE; + const char *theFileName = TRACEFILE; string s = "file:"; s += theFileName; @@ -84,7 +84,7 @@ LifeCycleCORBATest::setUp() // --- Get or initialize the orb int _argc = 1; - char* _argv[] = {""}; + char* _argv[] = {(char*)""}; ORB_INIT &init = *SINGLETON_::Instance() ; ASSERT(SINGLETON_::IsAlreadyExisting()); _orb = init(_argc , _argv ) ; diff --git a/src/Logger/SALOME_Trace.hxx b/src/Logger/SALOME_Trace.hxx index a03332071..24ef7ba8e 100644 --- a/src/Logger/SALOME_Trace.hxx +++ b/src/Logger/SALOME_Trace.hxx @@ -12,6 +12,7 @@ #define AFX_LOGGER_H__96F2A3AB_F6F8_11D6_BFA6_000476A0958C__INCLUDED_ #include +#include #include "Logger.hh" //these declarations for files don't using OCC includes (for example HDF) diff --git a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx index 87c1f80a9..435951b23 100644 --- a/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx +++ b/src/ModuleCatalog/SALOME_ModuleCatalog_impl.cxx @@ -36,9 +36,9 @@ using namespace std; #include "utilities.h" #ifdef _DEBUG_ -static int MYDEBUG = 1; +static int MYDEBUG = 0; #else -static int MYDEBUG = 1; +static int MYDEBUG = 0; #endif static const char* SEPARATOR = "::"; @@ -688,14 +688,14 @@ SALOME_ModuleCatalogImpl::_parse_xml_file(const char* file, if (aDoc != NULL) handler->ProcessXmlDocument(aDoc); else - INFOS("ModuleCatalog: could not parse file "< splitPath; - int dimension_resultat = _createContextNameDir(Path, + _createContextNameDir(Path, context_name, splitPath, false); @@ -803,7 +803,7 @@ throw(ServiceUnreachable) // SCRUTE(path); CosNaming::Name context_name; vector splitPath; - int dimension_resultat = _createContextNameDir(path.c_str(), + _createContextNameDir(path.c_str(), context_name, splitPath, true); diff --git a/src/NamingService/SALOME_NamingServicePy.py b/src/NamingService/SALOME_NamingServicePy.py index e4a44d309..81ad8d15a 100644 --- a/src/NamingService/SALOME_NamingServicePy.py +++ b/src/NamingService/SALOME_NamingServicePy.py @@ -32,6 +32,7 @@ import sys import time from omniORB import CORBA import CosNaming +import string from string import * from SALOME_utilities import * @@ -88,7 +89,7 @@ class SALOME_NamingServicePy_i(object): #delete first '/' before split Path=Path[1:] - result_resolve_path = split(Path,'/') + result_resolve_path = string.split(Path,'/') if len(result_resolve_path)>1: # A directory is treated (not only an object name) # We had to test if the directory where ObjRef should be recorded @@ -156,7 +157,7 @@ class SALOME_NamingServicePy_i(object): #delete first '/' before split Path=Path[1:] - result_resolve_path = split(Path,'/') + result_resolve_path = string.split(Path,'/') _context_name=[] for i in range(len(result_resolve_path)-1): _context_name.append(CosNaming.NameComponent(result_resolve_path[i],"dir")) @@ -189,7 +190,7 @@ class SALOME_NamingServicePy_i(object): #delete first '/' before split Path=Path[1:] - result_resolve_path = split(Path,'/') + result_resolve_path = string.split(Path,'/') _context_name = [] for i in range(len(result_resolve_path)): _context_name[CosNaming.NameComponent(result_resolve_path[i],"dir")] @@ -204,7 +205,46 @@ class SALOME_NamingServicePy_i(object): MESSAGE ( "Create_Directory : CosNaming.NamingContext.CannotProceed" ) except (CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE): MESSAGE ( "Create_Directory : CORBA.TRANSIENT,CORBA.OBJECT_NOT_EXIST,CORBA.COMM_FAILURE" ) - - - + def Destroy_Name(self,Path): + resolve_path=string.split(Path,'/') + if resolve_path[0] == '': del resolve_path[0] + dir_path=resolve_path[:-1] + context_name=[] + for e in dir_path: + context_name.append(CosNaming.NameComponent(e,"dir")) + context_name.append(CosNaming.NameComponent(resolve_path[-1],"object")) + + try: + self._root_context.unbind(context_name) + except CosNaming.NamingContext.NotFound, ex: + return + except CORBA.Exception,ex: + return + + def Destroy_FullDirectory(self,Path): + context_name=[] + for e in string.split(Path,'/'): + if e == '':continue + context_name.append(CosNaming.NameComponent(e,"dir")) + + try: + context=self._root_context.resolve(context_name) + except CosNaming.NamingContext.NotFound, ex: + return + except CORBA.Exception,ex: + return + + bl,bi=context.list(0) + if bi is not None: + ok,b=bi.next_one() + while(ok): + for s in b.binding_name : + if s.kind == "object": + context.unbind([s]) + elif s.kind == "dir": + context.unbind([s]) + ok,b=bi.next_one() + + context.destroy() + self._root_context.unbind(context_name) diff --git a/src/NamingService/Test/NamingServiceTest.cxx b/src/NamingService/Test/NamingServiceTest.cxx index 2a9e1fca2..690c3dfd7 100644 --- a/src/NamingService/Test/NamingServiceTest.cxx +++ b/src/NamingService/Test/NamingServiceTest.cxx @@ -111,7 +111,7 @@ NamingServiceTest::setUp() bp1->deleteInstance(bp1); // --- trace on file - char *theFileName = TRACEFILE; + const char *theFileName = TRACEFILE; string s = "file:"; s += theFileName; @@ -131,7 +131,7 @@ NamingServiceTest::setUp() // --- Get or initialize the orb int _argc = 1; - char* _argv[] = {""}; + char* _argv[] = {(char*)""}; ORB_INIT &init = *SINGLETON_::Instance() ; ASSERT(SINGLETON_::IsAlreadyExisting()); _orb = init(_argc , _argv ) ; diff --git a/src/Registry/RegistryService.cxx b/src/Registry/RegistryService.cxx index 52a3d1e9a..939c1adc6 100644 --- a/src/Registry/RegistryService.cxx +++ b/src/Registry/RegistryService.cxx @@ -59,15 +59,19 @@ RegistryService::~RegistryService() map::iterator im; for (im=_reg.begin();im!=_reg.end(); im++) { +#if defined(_DEBUG_) || defined(_DEBUG) const client_infos &lesInfos = *(*im).second ; MESSAGE("Deletion") ; SCRUTE( lesInfos._name ) ; +#endif _reg.erase ( im ) ; } ASSERT(_reg.size()==0) ; for (im=_fin.begin();im!=_fin.end(); im++) { +#if defined(_DEBUG_) || defined(_DEBUG) const client_infos &lesInfos = *(*im).second ; MESSAGE("Deletion") ; SCRUTE( lesInfos._name ) ; +#endif _fin.erase ( im ) ; } ASSERT(_fin.size()==0) ; diff --git a/src/Registry/RegistryService.hxx b/src/Registry/RegistryService.hxx index 9b26f41f8..bc6097fcd 100644 --- a/src/Registry/RegistryService.hxx +++ b/src/Registry/RegistryService.hxx @@ -89,7 +89,7 @@ public : void SessionName( const char *sessionName ) ; - void SetOrb( CORBA::ORB_ptr orb ) { _orb = orb; return; } + void SetOrb( CORBA::ORB_ptr orb ) { _orb = CORBA::ORB::_duplicate(orb); return; } void Shutdown() { if(!CORBA::is_nil(_orb)) _orb->shutdown(0); } diff --git a/src/Registry/SALOME_Registry_Server.cxx b/src/Registry/SALOME_Registry_Server.cxx index 50e608f31..8183340c2 100644 --- a/src/Registry/SALOME_Registry_Server.cxx +++ b/src/Registry/SALOME_Registry_Server.cxx @@ -170,6 +170,7 @@ int main( int argc , char **argv ) ptrRegistry->SessionName( ptrSessionName ) ; ptrRegistry->SetOrb(orb); varComponents = ptrRegistry->_this() ; + ptrRegistry->_remove_ref(); //let poa manage registryservice deletion // The RegistryService must not already exist. try diff --git a/src/SALOMEDS/SALOMEDS.cxx b/src/SALOMEDS/SALOMEDS.cxx index 57c00c16f..8ee2138d2 100644 --- a/src/SALOMEDS/SALOMEDS.cxx +++ b/src/SALOMEDS/SALOMEDS.cxx @@ -138,7 +138,7 @@ SALOMEDS_EXPORT PortableServer::ObjectId_var aStudyManager_iid = root_poa->activate_object(aStudyManager_i); //give ownership to the poa : the object will be deleted by the poa aStudyManager_i->_remove_ref(); - aStudyManager_i->register_name("/myStudyManager"); + aStudyManager_i->register_name((char*)"/myStudyManager"); } return new SALOMEDS_StudyManager(); } diff --git a/src/SALOMEDS/SALOMEDS_AttributeUserID.cxx b/src/SALOMEDS/SALOMEDS_AttributeUserID.cxx index 804f4b148..b420c7e72 100644 --- a/src/SALOMEDS/SALOMEDS_AttributeUserID.cxx +++ b/src/SALOMEDS/SALOMEDS_AttributeUserID.cxx @@ -43,7 +43,7 @@ std::string SALOMEDS_AttributeUserID::Value() std::string aValue; if (_isLocal) { SALOMEDS::Locker lock; - char guid[40]; + // char guid[40]; aValue = dynamic_cast(_local_impl)->Value(); } else aValue = SALOMEDS::AttributeUserID::_narrow(_corba_impl)->Value(); diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx index b0666a4d2..56657e5b3 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute.cxx @@ -59,7 +59,7 @@ SALOMEDS_GenericAttribute::SALOMEDS_GenericAttribute(SALOMEDS::GenericAttribute_ CORBA::LongLong addr = theGA->GetLocalImpl(GetHostname().c_str(), pid, _isLocal); if(_isLocal) { - _local_impl = ((SALOMEDSImpl_GenericAttribute*)(addr)); + _local_impl = reinterpret_cast(addr); _corba_impl = SALOMEDS::GenericAttribute::_nil(); } else { diff --git a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx index 6c25a767a..78a3006e5 100644 --- a/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx +++ b/src/SALOMEDS/SALOMEDS_GenericAttribute_i.cxx @@ -82,7 +82,7 @@ char* SALOMEDS_GenericAttribute_i::Type() return CORBA::string_dup(SALOMEDSImpl_GenericAttribute::Impl_GetType(_impl)); } - return ""; + return (char*)""; } char* SALOMEDS_GenericAttribute_i::GetClassType() @@ -92,7 +92,7 @@ char* SALOMEDS_GenericAttribute_i::GetClassType() return CORBA::string_dup(SALOMEDSImpl_GenericAttribute::Impl_GetClassType(_impl)); } - return ""; + return (char*)""; } @@ -122,5 +122,5 @@ CORBA::LongLong SALOMEDS_GenericAttribute_i::GetLocalImpl(const char* theHostnam long pid = (long)getpid(); #endif isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0; - return ((CORBA::LongLong)_impl); + return reinterpret_cast(_impl); } diff --git a/src/SALOMEDS/SALOMEDS_SObject.cxx b/src/SALOMEDS/SALOMEDS_SObject.cxx index b7b6e7410..2110c24dc 100644 --- a/src/SALOMEDS/SALOMEDS_SObject.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject.cxx @@ -63,7 +63,7 @@ SALOMEDS_SObject::SALOMEDS_SObject(SALOMEDS::SObject_ptr theSObject) theSObject->GetLocalImpl(GetHostname().c_str(), pid, _isLocal); if(_isLocal) { - _local_impl = ((SALOMEDSImpl_SObject*)(addr)); + _local_impl = reinterpret_cast(addr); _corba_impl = SALOMEDS::SObject::_duplicate(theSObject); } else { diff --git a/src/SALOMEDS/SALOMEDS_SObject_i.cxx b/src/SALOMEDS/SALOMEDS_SObject_i.cxx index 9af322638..08eddaa70 100644 --- a/src/SALOMEDS/SALOMEDS_SObject_i.cxx +++ b/src/SALOMEDS/SALOMEDS_SObject_i.cxx @@ -332,5 +332,5 @@ CORBA::LongLong SALOMEDS_SObject_i::GetLocalImpl(const char* theHostname, CORBA: long pid = (long)getpid(); #endif isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0; - return ((CORBA::LongLong)(void*)_impl); + return reinterpret_cast(_impl); } diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index 0aa3a240d..3bfebc5b0 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -81,7 +81,7 @@ SALOMEDS_Study::SALOMEDS_Study(SALOMEDS::Study_ptr theStudy) long addr = theStudy->GetLocalImpl(GetHostname().c_str(), pid, _isLocal); if(_isLocal) { - _local_impl = ((SALOMEDSImpl_Study*)(addr)); + _local_impl = reinterpret_cast(addr); _corba_impl = SALOMEDS::Study::_duplicate(theStudy); } else { diff --git a/src/SALOMEDS/SALOMEDS_StudyManager.cxx b/src/SALOMEDS/SALOMEDS_StudyManager.cxx index 1dae939cc..edff1f88f 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager.cxx @@ -59,7 +59,7 @@ SALOMEDS_StudyManager::SALOMEDS_StudyManager(SALOMEDS::StudyManager_ptr theManag CORBA::LongLong addr = theManager->GetLocalImpl(GetHostname().c_str(), pid, _isLocal); if(_isLocal) { - _local_impl = ((SALOMEDSImpl_StudyManager*)(addr)); + _local_impl = reinterpret_cast(addr); _corba_impl = SALOMEDS::StudyManager::_duplicate(theManager); } else { @@ -87,7 +87,7 @@ SALOMEDS_StudyManager::SALOMEDS_StudyManager() CORBA::LongLong addr = theManager->GetLocalImpl(GetHostname().c_str(), pid, _isLocal); if(_isLocal) { - _local_impl = ((SALOMEDSImpl_StudyManager*)(addr)); + _local_impl = reinterpret_cast(addr); _corba_impl = SALOMEDS::StudyManager::_duplicate(theManager); } else { diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx index 7c5abcb94..d40b1d772 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.cxx @@ -98,7 +98,7 @@ SALOMEDS_StudyManager_i::~SALOMEDS_StudyManager_i() * context name */ //============================================================================ -void SALOMEDS_StudyManager_i::register_name(char * name) +void SALOMEDS_StudyManager_i::register_name(const char * name) { SALOMEDS::StudyManager_var aManager(_this()); _name_service->Register(aManager.in(), name); @@ -476,7 +476,7 @@ CORBA::LongLong SALOMEDS_StudyManager_i::GetLocalImpl(const char* theHostname, C long pid = (long)getpid(); #endif isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0; - return ((CORBA::LongLong)(void*)_impl); + return reinterpret_cast(_impl); } //=========================================================================== diff --git a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx index a7ec9b17e..d837acba1 100644 --- a/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx +++ b/src/SALOMEDS/SALOMEDS_StudyManager_i.hxx @@ -72,7 +72,7 @@ public: /*! \param char* arguments, the context to register the study manager in the NS */ - void register_name(char * name); + void register_name(const char * name); //! method to Create a New Study of name study_name /*! diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index 137c34bd5..1f5f2a127 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -889,5 +889,5 @@ CORBA::LongLong SALOMEDS_Study_i::GetLocalImpl(const char* theHostname, CORBA::L long pid = (long)getpid(); #endif isLocal = (strcmp(theHostname, GetHostname().c_str()) == 0 && pid == thePID)?1:0; - return ((CORBA::LongLong)_impl); + return reinterpret_cast(_impl); } diff --git a/src/SALOMEDS/Test/SALOMEDSTest.cxx b/src/SALOMEDS/Test/SALOMEDSTest.cxx index 68de91733..5c8a88280 100644 --- a/src/SALOMEDS/Test/SALOMEDSTest.cxx +++ b/src/SALOMEDS/Test/SALOMEDSTest.cxx @@ -51,7 +51,7 @@ using namespace std; void SALOMEDSTest::setUp() { int argc = 1; - char* argv[] = {""}; + char* argv[] = {(char*)""}; ORB_INIT &init = *SINGLETON_::Instance() ; ASSERT(SINGLETON_::IsAlreadyExisting()); @@ -128,7 +128,7 @@ void SALOMEDSTest::tearDown() void SALOMEDSTest_Embedded::setUp() { int argc = 1; - char* argv[] = {""}; + char* argv[] = {(char*)""}; ORB_INIT &init = *SINGLETON_::Instance() ; ASSERT(SINGLETON_::IsAlreadyExisting()); diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx index b8c88df49..866265851 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeIOR.cxx @@ -68,7 +68,7 @@ void SALOMEDSImpl_AttributeIOR::SetValue(const std::string& theValue) { CheckLocked(); - SALOMEDSImpl_Study* aStudy = SALOMEDSImpl_Study::GetStudy(Label()); + SALOMEDSImpl_Study::GetStudy(Label()); Backup(); myString = theValue; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx index 350dc0b28..8966b054e 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_AttributeTableOfString.cxx @@ -561,7 +561,7 @@ void SALOMEDSImpl_AttributeTableOfString::Load(const string& value) if(aStr[0] == '0') //If the first character of the key is 0, then empty value aValue = ""; else { - long aSize = strtol(v[pos++].c_str(), NULL, 10); + strtol(v[pos++].c_str(), NULL, 10); aValue = v[pos++]; } myTable[aKey] = aValue; diff --git a/src/SALOMELocalTrace/FileTraceCollector.cxx b/src/SALOMELocalTrace/FileTraceCollector.cxx index d64f5eafb..6646fbba6 100644 --- a/src/SALOMELocalTrace/FileTraceCollector.cxx +++ b/src/SALOMELocalTrace/FileTraceCollector.cxx @@ -65,7 +65,7 @@ BaseTraceCollector* FileTraceCollector::instance(const char *fileName) sem_init(&_sem,0,0); // to wait until run thread is initialized pthread_t traceThread; int bid = 0; - int re2 = pthread_create(&traceThread, NULL, + pthread_create(&traceThread, NULL, FileTraceCollector::run, (void *)bid); sem_wait(&_sem); _singleton = myInstance; // _singleton known only when init done @@ -121,7 +121,7 @@ void* FileTraceCollector::run(void *bid) //break; } - int fullBuf = myTraceBuffer->retrieve(myTrace); + myTraceBuffer->retrieve(myTrace); if (myTrace.traceType == ABORT_MESS) { #ifndef WNT diff --git a/src/SALOMELocalTrace/LocalTraceBufferPool.cxx b/src/SALOMELocalTrace/LocalTraceBufferPool.cxx index f41e57593..02fc9839d 100644 --- a/src/SALOMELocalTrace/LocalTraceBufferPool.cxx +++ b/src/SALOMELocalTrace/LocalTraceBufferPool.cxx @@ -87,8 +87,7 @@ LocalTraceBufferPool* LocalTraceBufferPool::instance() DEVTRACE("New buffer pool"); LocalTraceBufferPool* myInstance = new LocalTraceBufferPool(); - DESTRUCTOR_OF *ptrDestroy = - new DESTRUCTOR_OF (*myInstance); + new DESTRUCTOR_OF (*myInstance); _singleton = myInstance; // --- start a trace Collector @@ -101,7 +100,7 @@ LocalTraceBufferPool* LocalTraceBufferPool::instance() } else if (strncmp(traceKind,"file",strlen("file"))==0) { - char *fileName; + const char *fileName; if (strlen(traceKind) > strlen("file")) fileName = &traceKind[strlen("file")+1]; else @@ -223,7 +222,7 @@ int LocalTraceBufferPool::retrieve(LocalTrace_TraceInfo& aTrace) while (ret) { ret = sem_wait(&_fullBufferSemaphore); - if (ret) perror(" LocalTraceBufferPool::retrieve, sem_wait"); + if (ret) MESSAGE (" LocalTraceBufferPool::retrieve, sem_wait"); } // get the next buffer to print diff --git a/src/SALOMELocalTrace/LocalTraceBufferPool.hxx b/src/SALOMELocalTrace/LocalTraceBufferPool.hxx index bd55a1dc2..27dbf891a 100644 --- a/src/SALOMELocalTrace/LocalTraceBufferPool.hxx +++ b/src/SALOMELocalTrace/LocalTraceBufferPool.hxx @@ -26,7 +26,7 @@ #include "SALOME_LocalTrace.hxx" -#define TRACE_BUFFER_SIZE 256 // number of entries in circular buffer +#define TRACE_BUFFER_SIZE 512 // number of entries in circular buffer // must be power of 2 #define MAX_TRACE_LENGTH 1024 // messages are truncated at this size diff --git a/src/SALOMELocalTrace/LocalTraceCollector.cxx b/src/SALOMELocalTrace/LocalTraceCollector.cxx index f34170657..dbd9740c1 100644 --- a/src/SALOMELocalTrace/LocalTraceCollector.cxx +++ b/src/SALOMELocalTrace/LocalTraceCollector.cxx @@ -56,7 +56,7 @@ BaseTraceCollector* LocalTraceCollector::instance() sem_init(&_sem,0,0); // to wait until run thread is initialized pthread_t traceThread; - int re2 = pthread_create(&traceThread, NULL, + pthread_create(&traceThread, NULL, LocalTraceCollector::run, NULL); sem_wait(&_sem); _singleton = myInstance; // _singleton known only when init done @@ -97,7 +97,7 @@ void* LocalTraceCollector::run(void *bid) //break; } - int fullBuf = myTraceBuffer->retrieve(myTrace); + myTraceBuffer->retrieve(myTrace); if (myTrace.traceType == ABORT_MESS) { cout << flush ; diff --git a/src/SALOMELocalTrace/Test/SALOMELocalTraceTest.cxx b/src/SALOMELocalTrace/Test/SALOMELocalTraceTest.cxx index 90bcb4db6..0d2a8ad78 100644 --- a/src/SALOMELocalTrace/Test/SALOMELocalTraceTest.cxx +++ b/src/SALOMELocalTrace/Test/SALOMELocalTraceTest.cxx @@ -64,7 +64,7 @@ void SALOMELocalTraceTest::testSingletonBufferPool() { // --- trace on file - char *theFileName = TRACEFILE; + const char *theFileName = TRACEFILE; string s = "file:"; s += theFileName; @@ -115,7 +115,7 @@ SALOMELocalTraceTest::testLoadBufferPoolLocal() for(t=0;tinsert(NORMAL_MESS, os.str().c_str()); #define MESS_ABORT std::endl; LocalTraceBufferPool::instance()->insert(ABORT_MESS, os.str().c_str()); +// Macroses for messages with separated structure in c++ file in _DUBUG mode +#define MESSAGE_BEGIN(msg) {std::ostringstream ss; ss <<__FILE__ <<" ["<<__LINE__<<"] : "<< msg; LocalTraceBufferPool::instance()->insert(NORMAL_MESS, ss.str().c_str());} +#define MESSAGE_ADD(msg) {std::ostringstream ss; ss << msg; LocalTraceBufferPool::instance()->insert(NORMAL_MESS, ss.str().c_str());} +#define MESSAGE_END(msg) {std::ostringstream ss; ss << msg << std::endl; LocalTraceBufferPool::instance()->insert(NORMAL_MESS, ss.str().c_str());} + // --- Some macros are always defined (without _DEBUG_): for use with release version #define INFOS(msg) {MESS_BEGIN("- Trace ") << msg << MESS_END} diff --git a/src/SALOMETraceCollector/SALOMETraceCollector.cxx b/src/SALOMETraceCollector/SALOMETraceCollector.cxx index b1286b915..aee066270 100644 --- a/src/SALOMETraceCollector/SALOMETraceCollector.cxx +++ b/src/SALOMETraceCollector/SALOMETraceCollector.cxx @@ -70,7 +70,7 @@ BaseTraceCollector* SALOMETraceCollector::instance() sem_init(&_sem,0,0); // to wait until run thread is initialized pthread_t traceThread; int bid = 0; - int re2 = pthread_create(&traceThread, NULL, + pthread_create(&traceThread, NULL, SALOMETraceCollector::run, (void *)bid); sem_wait(&_sem); _singleton = myInstance; // _singleton known only when init done @@ -131,7 +131,7 @@ void* SALOMETraceCollector::run(void *bid) //break; } - int fullBuf = myTraceBuffer->retrieve(myTrace); + myTraceBuffer->retrieve(myTrace); if (!CORBA::is_nil(_orb)) { if (myTrace.traceType == ABORT_MESS) diff --git a/src/SALOMETraceCollector/Test/SALOMETraceCollectorTest.cxx b/src/SALOMETraceCollector/Test/SALOMETraceCollectorTest.cxx index fe6bcfde3..b945328c0 100644 --- a/src/SALOMETraceCollector/Test/SALOMETraceCollectorTest.cxx +++ b/src/SALOMETraceCollector/Test/SALOMETraceCollectorTest.cxx @@ -82,7 +82,7 @@ SALOMETraceCollectorTest::testLoadBufferPoolCORBA() for(t=0;t #include #include diff --git a/src/TestContainer/SALOME_TestComponent_i.cxx b/src/TestContainer/SALOME_TestComponent_i.cxx index 221f60d66..a3a81c616 100644 --- a/src/TestContainer/SALOME_TestComponent_i.cxx +++ b/src/TestContainer/SALOME_TestComponent_i.cxx @@ -73,7 +73,7 @@ char* Engines_TestComponent_i::Coucou(CORBA::Long L) void Engines_TestComponent_i::Setenv() { - bool overwrite = true; + // bool overwrite = true; map::iterator it; MESSAGE("set environment associated with keys in map _fieldsDict"); for (it = _fieldsDict.begin(); it != _fieldsDict.end(); it++) @@ -88,7 +88,7 @@ void Engines_TestComponent_i::Setenv() s+='='; s+=value; //char* cast because 1st arg of linux putenv function is not a const char* !!! - int ret=putenv((char *)s.c_str()); + putenv((char *)s.c_str()); //End of CCRT porting //int ret = setenv(cle.c_str(), value, overwrite); MESSAGE("--- setenv: "<load_component_Library(componenttName.c_str()); // iGenFact->load_component_Library("SalomeTestComponent"); ASSERT(isLib); +#else + iGenFact->load_component_Library(componenttName.c_str()); +#endif CORBA::Object_var obj = // iGenFact->create_component_instance("SalomeTestComponent", iGenFact->create_component_instance(componenttName.c_str(), diff --git a/src/Utils/Test/UtilsTest.cxx b/src/Utils/Test/UtilsTest.cxx index dd0c98891..43bb29a06 100644 --- a/src/Utils/Test/UtilsTest.cxx +++ b/src/Utils/Test/UtilsTest.cxx @@ -47,7 +47,7 @@ UtilsTest::setUp() bp1->deleteInstance(bp1); // --- trace on file - char *theFileName = TRACEFILE; + const char *theFileName = TRACEFILE; string s = "file:"; s += theFileName; diff --git a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx index 61239063a..60c292fb5 100644 --- a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx +++ b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.cxx @@ -36,12 +36,13 @@ extern "C" # include "Utils_DESTRUCTEUR_GENERIQUE.hxx" //# include "utilities.h" +# include "LocalTraceBufferPool.hxx" void Nettoyage(); #ifdef _DEBUG_ -static int MYDEBUG = 0; +// static int MYDEBUG = 0; #else -static int MYDEBUG = 0; +// static int MYDEBUG = 0; #endif using namespace std; @@ -83,6 +84,8 @@ public : DESTRUCTEUR_GENERIQUE_::Destructeurs = new std::list ; // Destructeur alloue dynamiquement (cf. ci-dessous) , // il est utilise puis detruit par la fonction Nettoyage + //To be sure the trace singleton will be the last one to be destroyed initialize it here before calling atexit + LocalTraceBufferPool::instance(); int cr = atexit( Nettoyage ); // execute Nettoyage lors de exit, aprs la destruction des donnees statiques ! assert(cr==0) ; ATEXIT_Done = true ; diff --git a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx index 9ae866266..54e0bcd22 100644 --- a/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx +++ b/src/Utils/Utils_DESTRUCTEUR_GENERIQUE.hxx @@ -140,4 +140,4 @@ private : }; -# endif /* # if !defined( __SINGLETON__H__ ) */ +# endif /* # if !defined( __DESTRUCTEUR_GENERIQUE__H__ ) */ diff --git a/src/Utils/Utils_Identity.cxx b/src/Utils/Utils_Identity.cxx index 41e24858d..d95ea641c 100644 --- a/src/Utils/Utils_Identity.cxx +++ b/src/Utils/Utils_Identity.cxx @@ -51,16 +51,24 @@ const char* duplicate( const char *const str ) ; const struct utsname get_uname( void ) { struct utsname hostid; +#if defined(_DEBUG_) || defined(_DEBUG) const int retour=uname(&hostid); ASSERT(retour>=0); +#else + uname(&hostid); +#endif return hostid ; } const char* get_adip( void ) { struct utsname hostid; +#if defined(_DEBUG_) || defined(_DEBUG) const int retour=uname(&hostid); ASSERT(retour>=0); +#else + uname(&hostid); +#endif const hostent* pour_adip=gethostbyname(hostid.nodename); ASSERT(pour_adip!=NULL); diff --git a/src/Utils/Utils_SALOME_Exception.hxx b/src/Utils/Utils_SALOME_Exception.hxx index 5c9207dbc..979b3e137 100644 --- a/src/Utils/Utils_SALOME_Exception.hxx +++ b/src/Utils/Utils_SALOME_Exception.hxx @@ -34,6 +34,9 @@ # include # include +#ifdef LOCALIZED +#undef LOCALIZED +#endif #ifdef _DEBUG_ # define LOCALIZED(message) #message , __FILE__ , __LINE__ #else diff --git a/src/Utils/Utils_Timer.cxx b/src/Utils/Utils_Timer.cxx index ce11653a7..e15c89a55 100644 --- a/src/Utils/Utils_Timer.cxx +++ b/src/Utils/Utils_Timer.cxx @@ -118,10 +118,12 @@ void Utils_Timer::Reset() { } void Utils_Timer::ShowAbsolute(){ +#if defined(_DEBUG_) || defined(_DEBUG) #ifndef WNT unsigned long Absolute_user = (unsigned long) ((timeval*)RefToCurrentTimeB)->tv_sec ; #else unsigned long Absolute_user = *RefToCurrentTimeB; #endif MESSAGE("Absolute time: " << Absolute_user << " seconds "); +#endif } -- 2.39.2