Salome HOME
Log files in /tmp/logs/${USER}/ : ASV
authorrahuel <rahuel@opencascade.com>
Wed, 8 Dec 2004 13:45:07 +0000 (13:45 +0000)
committerrahuel <rahuel@opencascade.com>
Wed, 8 Dec 2004 13:45:07 +0000 (13:45 +0000)
src/Supervision/Graph_Impl.cxx

index 3af8ebd8201379064293c8b7cb6353d1bbb49ff1..15cd0d4eea45c5c9e69b66ff39e9ab5fa5a906dc 100644 (file)
@@ -34,6 +34,8 @@ using namespace std;
 
 //#include "utilities.h"
 
+#include "SALOME_Container_i.hxx"
+
 #include "StreamGraph_Impl.hxx"
 
 #include "DataFlowEditor_DataFlow.hxx"
@@ -46,11 +48,7 @@ static void CreateEditor( CORBA::ORB_ptr orb ,
                           const SUPERV::KindOfNode aKindOfNode ,
                           string & dbgfile ,
                           GraphEditor::DataFlow **  aDataFlowEditor ) {
-//    string dbgfile = "/tmp/" ;
   bool aXmlFile = false ;
-  dbgfile = "/tmp/" ;
-  dbgfile += instanceName ;
-  dbgfile += "_" ;
   int lenname = strlen( aDataFlowName ) ;
   char * theDataFlowName = new char [ lenname+1 ] ;
   strcpy( theDataFlowName , aDataFlowName ) ;
@@ -72,12 +70,28 @@ static void CreateEditor( CORBA::ORB_ptr orb ,
       strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
     }
   }
+  
   string theDataFlowInstanceName = theDataFlowName ;
-//  if ( !aXmlFile ) {
-//    theDataFlowInstanceName = theAutomaton->GraphInstanceName( theDataFlowName ) ;
-//  }
+
+  // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir. 
+  // "/tmp/logs/$USER" was created by  runSalome.py -> orbmodule.py.
+  dbgfile = "/tmp/logs/" ;
+  dbgfile += getenv( "USER" ) ;
+  dbgfile += "/" ;
+  dbgfile += instanceName ;
+  dbgfile += "_" ;
   dbgfile += theDataFlowInstanceName ;
   dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() + ".log" ;
+  FILE* f = fopen ( dbgfile.c_str(), "a" );
+  if ( f ) { // check if file can be opened for writing
+    fclose( f );
+  } 
+  else { // if file can't be opened - use a guaranteed temp file name
+    char* aTempNam = tempnam( NULL, NULL );
+    dbgfile = aTempNam;
+    free ( aTempNam );
+  }
+
   SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
   *aDataFlowEditor = new GraphEditor::DataFlow( orb , NamingService ,
                                                 theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
@@ -94,29 +108,43 @@ static void CreateExecutor( CORBA::ORB_ptr orb ,
                           const SUPERV::KindOfNode aKindOfNode ,
                           string & dbgfile ,
                           GraphExecutor::DataFlow **  aDataFlowExecutor ) {
-//    string dbgfile = "/tmp/" ;
-  dbgfile = "/tmp/" ;
-  dbgfile += instanceName ;
-  dbgfile += "_" ;
   int lenname = strlen( aDataFlowName ) ;
   char * theDataFlowName = new char [ lenname+1 ] ;
   strcpy( theDataFlowName , aDataFlowName ) ;
   if ( aDataFlowName ) {
     strcpy( theDataFlowName , &aDataFlowName[ 0 ] ) ;
   }
+
   string theDataFlowInstanceName = theDataFlowName ;
+
+  // asv : 16.11.04 : creation of log file in /tmp/logs/$USER dir. 
+  // "/tmp/logs/$USER" was created by  runSalome.py -> orbmodule.py.
+  dbgfile = "/tmp/logs/" ;
+  dbgfile += getenv( "USER" ) ;
+  dbgfile += "/" ;
+  dbgfile += instanceName ;
+  dbgfile += "_" ;
   dbgfile += theDataFlowInstanceName ;
   dbgfile = dbgfile + "_" + theAutomaton->DbgFileNumber() ;
-
   ostringstream astr ;
   astr << theAutomaton->ExecNumber() ;
   dbgfile += astr.str() ;
   dbgfile += string( "_Exec.log" ) ;
+  FILE* f = fopen ( dbgfile.c_str(), "a" );
+  if ( f ) { // check if file can be opened for writing
+    fclose( f );
+  } 
+  else { // if file can't be opened - use a guaranteed temp file name
+    char* aTempNam = tempnam( NULL, NULL );
+    dbgfile = aTempNam;
+    free ( aTempNam );
+  }
 
   SALOME_NamingService * NamingService = new SALOME_NamingService( orb ) ;
   *aDataFlowExecutor = new GraphExecutor::DataFlow( orb , NamingService ,
                                                     theDataFlowInstanceName.c_str() , dbgfile.c_str() ,
                                                     aKindOfNode ) ;
+
   MESSAGE( "CreateExecutor " << theDataFlowName << " " << theDataFlowInstanceName << " created with "
            << dbgfile.c_str() ) ;
 
@@ -1619,7 +1647,10 @@ bool Graph_Impl::IsValid() {
 bool Graph_Impl::IsExecutable() {
 //  beginService( "Graph_Impl::IsExecutable" );
   bool RetVal = false ;
-  if ( !IsMacro() ) {
+
+  // asv : 15.11.04 : added "&& GraphMacroLevel() == 0" -> 
+  // subgraphs are not executable by themselves, RetVal = false..
+  if ( !IsMacro() && DataFlowEditor()->Graph()->GraphMacroLevel() == 0 ) {
     RetVal = DataFlowEditor()->IsExecutable() ;
   }
 //  endService( "Graph_Impl::IsExecutable" );