From 49ffa04398bef42910ce08eb0c5c9daf5c62de14 Mon Sep 17 00:00:00 2001 From: prascle Date: Mon, 22 Jan 2007 13:51:27 +0000 Subject: [PATCH] PR: bug 14147 remove traces --- bin/addToKillList.py | 7 ++--- bin/killSalomeWithPort.py | 7 ++--- bin/launchConfigureParser.py | 31 +++++++++++++++++++++- bin/runSalome.py | 25 +++++++++-------- src/Container/SALOME_Container.py | 3 ++- src/Container/SALOME_ContainerPy.py | 3 ++- src/NamingService/SALOME_NamingService.cxx | 2 +- src/SALOMELocalTrace/utilities.h | 8 +++--- src/Utils/SALOME_utilities.py | 12 +++++---- 9 files changed, 69 insertions(+), 29 deletions(-) diff --git a/bin/addToKillList.py b/bin/addToKillList.py index 390ac2aaa..f29cccef7 100755 --- a/bin/addToKillList.py +++ b/bin/addToKillList.py @@ -20,6 +20,7 @@ # import os, sys, pickle, string, signal +from launchConfigureParser import verbose ########## adds to the kill list of SALOME one more process ########## @@ -43,7 +44,7 @@ def findFileDict(): except: pass pass - print "myport = ", my_port + if verbose(): print "myport = ", my_port return my_port def addToKillList(command_pid, command): @@ -60,7 +61,7 @@ def addToKillList(command_pid, command): already_in=0 for process_id in process_ids: - print process_id + if verbose(): print process_id for pid, cmd in process_id.items(): #print "see process %s : %s"% (pid, cmd[0]) if pid == command_pid: @@ -111,5 +112,5 @@ def killList(): if __name__ == "__main__": - print sys.argv + if verbose(): print sys.argv addToKillList(sys.argv[1], sys.argv[2]) diff --git a/bin/killSalomeWithPort.py b/bin/killSalomeWithPort.py index 60e166d15..7a006f845 100755 --- a/bin/killSalomeWithPort.py +++ b/bin/killSalomeWithPort.py @@ -20,6 +20,7 @@ # import os, sys, pickle, signal, commands +from launchConfigureParser import verbose def getPiDict(port,appname='salome',full=True): from Utils_Identity import getShortHostName @@ -96,7 +97,7 @@ def killMyPort(port): for field in prc.split(" ") : if field == "omniNames" : if pidfield != "egrep" : - print 'stop process '+pidfield+' : omniNames' + if verbose(): print 'stop process '+pidfield+' : omniNames' os.system('kill -9 '+pidfield) pidfield = field except: @@ -108,11 +109,11 @@ def killMyPort(port): for process_id in process_ids: for pid, cmd in process_id.items(): - print "stop process %s : %s"% (pid, cmd[0]) + if verbose(): print "stop process %s : %s"% (pid, cmd[0]) try: os.kill(int(pid),signal.SIGKILL) except: - print " ------------------ process %s : %s not found"% (pid, cmd[0]) + if verbose(): print " ------------------ process %s : %s not found"% (pid, cmd[0]) pass pass except: diff --git a/bin/launchConfigureParser.py b/bin/launchConfigureParser.py index 0f7ce8b4f..cddd4b520 100755 --- a/bin/launchConfigureParser.py +++ b/bin/launchConfigureParser.py @@ -140,6 +140,30 @@ def userFile(): last_file = file return last_file +# -- + +_verbose = None + +def verbose(): + global _verbose + # verbose has already been called + if _verbose is not None: + return _verbose + # first time + try: + from os import getenv + _verbose = int(getenv('SALOME_VERBOSE')) + except: + _verbose = 0 + pass + # + return _verbose + +def setVerbose(level): + global _verbose + _verbose = level + return + # ----------------------------------------------------------------------------- ### @@ -150,7 +174,7 @@ section_to_skip = "" class xml_parser: def __init__(self, fileName, _opts ): - print "Configure parser: processing %s ..." % fileName + if verbose(): print "Configure parser: processing %s ..." % fileName self.space = [] self.opts = _opts self.section = section_to_skip @@ -314,6 +338,11 @@ def get_env(): dirs.reverse() # reverse order, like in "path" variable - FILO-style processing + try: + dirs.remove('') # to remove empty dirs if the variable terminate by ":" or if there are "::" inside + except: + pass + _opts = {} # associative array of options to be filled # parse SalomeApp.xml files in directories specified by SalomeAppConfig env variable diff --git a/bin/runSalome.py b/bin/runSalome.py index 0a0455954..16dbf097d 100755 --- a/bin/runSalome.py +++ b/bin/runSalome.py @@ -21,6 +21,7 @@ import sys, os, string, glob, time, pickle import orbmodule +from launchConfigureParser import verbose process_id = {} @@ -236,11 +237,11 @@ def set_env(args, modules_list, modules_root_dir): salome_subdir,"resources","kernel") if "GEOM" in modules_list: - print "GEOM OCAF Resources" + if verbose(): print "GEOM OCAF Resources" os.environ["CSF_GEOMDS_ResourcesDefaults"] \ = os.path.join(modules_root_dir["GEOM"],"share", salome_subdir,"resources","geom") - print "GEOM Shape Healing Resources" + if verbose(): print "GEOM Shape Healing Resources" os.environ["CSF_ShHealingDefaults"] \ = os.path.join(modules_root_dir["GEOM"],"share", salome_subdir,"resources","geom") @@ -320,7 +321,7 @@ class Server: + os.getenv("LD_LIBRARY_PATH")] myargs = myargs +['-T']+self.CMD[:1]+['-e'] + env_ld_library_path command = myargs + self.CMD - print "command = ", command + if verbose(): print "command = ", command pid = os.spawnvp(os.P_NOWAIT, command[0], command) process_id[pid]=self.CMD self.PID = pid @@ -604,7 +605,7 @@ def startSalome(args, modules_list, modules_root_dir): """Launch all SALOME servers requested by args""" init_time = os.times() - print "startSalome ", args + if verbose(): print "startSalome ", args # # Initialisation ORB et Naming Service @@ -624,7 +625,7 @@ def startSalome(args, modules_list, modules_root_dir): # Notify Server launch # - print "Notify Server to launch" + if verbose(): print "Notify Server to launch" myServer=NotifyServer(args,modules_root_dir) myServer.run() @@ -740,7 +741,7 @@ def startSalome(args, modules_list, modules_root_dir): session=clt.waitNSPID("/Kernel/Session",mySessionServ.PID,SALOME.Session) end_time = os.times() - print + if verbose(): print print "Start SALOME, elapsed time : %5.1f seconds"% (end_time[4] - init_time[4]) @@ -810,7 +811,7 @@ def useSalome(args, modules_list, modules_root_dir): pickle.dump(process_ids,fpid) fpid.close() - print """ + 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): python killSalome.py @@ -829,10 +830,12 @@ def useSalome(args, modules_list, modules_root_dir): # if clt != None: - print - print " --- registered objects tree in Naming Service ---" - clt.showNS() - + if verbose(): + print + print " --- registered objects tree in Naming Service ---" + clt.showNS() + pass + # run python scripts, passed via -t option toimport = args['pyscript'] i = 0 diff --git a/src/Container/SALOME_Container.py b/src/Container/SALOME_Container.py index 026b9b7da..362f077e4 100644 --- a/src/Container/SALOME_Container.py +++ b/src/Container/SALOME_Container.py @@ -43,6 +43,7 @@ from SALOME_ComponentPy import * from SALOME_utilities import * from Utils_Identity import getShortHostName +from launchConfigureParser import verbose #============================================================================= @@ -61,7 +62,7 @@ class SALOME_Container_i: self._orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID) self._poa = self._orb.resolve_initial_references("RootPOA") self._containerName = containerName - print "SALOME_Container.SALOME_Container_i : _containerName ",self._containerName + if verbose(): print "SALOME_Container.SALOME_Container_i : _containerName ",self._containerName #self._naming_service = SALOME_NamingServicePy_i(self._orb) self._container = self._orb.string_to_object(containerIORStr) diff --git a/src/Container/SALOME_ContainerPy.py b/src/Container/SALOME_ContainerPy.py index 6eb0110bc..7a96abcc5 100755 --- a/src/Container/SALOME_ContainerPy.py +++ b/src/Container/SALOME_ContainerPy.py @@ -40,6 +40,7 @@ from SALOME_ComponentPy import * from SALOME_utilities import * from Utils_Identity import getShortHostName +from launchConfigureParser import verbose #============================================================================= @@ -61,7 +62,7 @@ class SALOME_ContainerPy_i (Engines__POA.Container): Container_path = "/Containers/" + myMachine + "/" + containerName #self._containerName = containerName self._containerName = Container_path - print "container name ",self._containerName + if verbose(): print "container name ",self._containerName naming_service = SALOME_NamingServicePy_i(self._orb) self._naming_service = naming_service diff --git a/src/NamingService/SALOME_NamingService.cxx b/src/NamingService/SALOME_NamingService.cxx index a7768ec2a..d84b9da80 100644 --- a/src/NamingService/SALOME_NamingService.cxx +++ b/src/NamingService/SALOME_NamingService.cxx @@ -380,7 +380,7 @@ CORBA::Object_ptr SALOME_NamingService::Resolve(const char* Path) CosNaming::Name n = ex.rest_of_name; if (ex.why == CosNaming::NamingContext::missing_node) - INFOS("Resolve() : " << (char *) n[0].id + MESSAGE("Resolve() : " << (char *) n[0].id << " (" << (char *) n[0].kind << ") not found"); if (ex.why == CosNaming::NamingContext::not_context) diff --git a/src/SALOMELocalTrace/utilities.h b/src/SALOMELocalTrace/utilities.h index dab74d492..0c8b3d696 100644 --- a/src/SALOMELocalTrace/utilities.h +++ b/src/SALOMELocalTrace/utilities.h @@ -92,13 +92,14 @@ #error INFOS_COMPILATION already defined #endif -#define INFOS_COMPILATION { MESS_BEGIN("COMPILED with ") << COMPILER \ - << ", " << __DATE__ \ - << " at " << __TIME__ << MESS_END } #ifdef _DEBUG_ // --- the following MACROS are useful at debug time +#define INFOS_COMPILATION { MESS_BEGIN("COMPILED with ") << COMPILER \ + << ", " << __DATE__ \ + << " at " << __TIME__ << MESS_END } + #define MESSAGE(msg) {MESS_BEGIN("- Trace ") << msg << MESS_END} #define SCRUTE(var) {MESS_BEGIN("- Trace ") << #var << "=" << var <