]> Creatis software - bbtk.git/commitdiff
Feature #1676
authorDaniel Gonzalez <Daniel.Gonzalez@creatis.insa-lyon.fr>
Thu, 11 Oct 2012 10:49:43 +0000 (10:49 +0000)
committerDaniel Gonzalez <Daniel.Gonzalez@creatis.insa-lyon.fr>
Thu, 11 Oct 2012 10:49:43 +0000 (10:49 +0000)
Plug Package BBS Implemented With error codes

kernel/appli/bbPlugPackage/bbPlugPackage.cpp
packages/std/src/bbstdExecSystemCommand.cxx
packages/std/src/bbstdExecSystemCommand.h
packages/toolsbbtk/bbs/appli/GUIPlugPackage.bbg
packages/toolsbbtk/bbs/appli/GUIPlugPackage.bbs

index ba1e9dd71ce98099ef99af1e2920268a2b731209..e8fd7f905b7eeb224acb136636e7d57bcf7ba8c6 100644 (file)
@@ -11,7 +11,7 @@ int main(int argc, char **argv)
   if (argc!=2)
     {
       std::cout << "usage : bbPlugPackage <path_to_package>" << std::endl;
-      return 0;
+      return (int)1;
     }
 
   std::string path(argv[1]);
@@ -19,9 +19,8 @@ int main(int argc, char **argv)
 
   if ( ! Utilities::FileExists( fname ) )
     {
-      std::cout << "* ERROR : The directory '"<<path<<"' does not contain a 'bbtkPackage' file"
-               << std::endl;
-      return 1; 
+      std::cout << "* ERROR : The directory '"<<path<<"' does not contain a 'bbtkPackage' file"        << std::endl;
+      return (int)2; 
     }
        
   std::ifstream f;
@@ -77,7 +76,7 @@ if ( system ( command.c_str() ) )
                << command << "'" << std::endl;
       //return 1; Feature #1676 - DFGO
     }
-  return 0;
+  return (int)0;
 }
 //==========================================================================
 
index f01fcb2941d3ef95b1db59c83def4fa0d2c159c4..598d70223403068ab5790a991612f4d7b59fe31c 100755 (executable)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbstdExecSystemCommand.cxx,v $
   Language:  C++
-  Date:      $Date: 2011/07/12 16:31:00 $
-  Version:   $Revision: 1.10 $
+  Date:      $Date: 2012/10/11 10:49:45 $
+  Version:   $Revision: 1.11 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -56,13 +56,14 @@ namespace bbstd
     int pos1=0,pos2;
     pos2 = bbGetInputIn().find(";",pos1);
     std::string ccommand;
+    int result = 0;
     while (ok)
-      {
-       if (pos2==-1) 
+    {
+         if (pos2==-1) 
          {
            ok=false;
            ccommand=bbGetInputIn().substr(pos1,bbGetInputIn().length()-pos1 );
-          } else {
+         } else {
            ccommand=bbGetInputIn().substr(pos1,pos2-pos1);
          }
          for (unsigned int i=0 ; i < ccommand.length() ; i++)
@@ -71,16 +72,30 @@ namespace bbstd
            {
                  ccommand[i]=34;
         }
-     }
-#if defined(_WIN32)
-       ccommand="start /b "+ccommand;
-#endif // defined(_WIN32)      
-       std::cout << "*** Executing system command : '"<<ccommand<<"'"<<std::endl;
-       system ( ccommand.c_str() );
-       pos1=pos2+1;
-       pos2 = bbGetInputIn().find(";",pos2+1);
       }
-
+      #if defined(_WIN32)
+           ccommand="start /b "+ccommand;
+      #endif // defined(_WIN32)        
+         std::cout << "*** Executing system command : '"<<ccommand<<"'"<<std::endl;
+         
+         result = system ( ccommand.c_str() );
+         
+         std::cout << "DFGO - ExecSystemCommand::DoProcess result=" << result << std::endl;
+         
+         //DFGO - if return code is different than 0 result is equal 1
+         
+         if(result)
+         {
+        result = 1;
+           ok = false;
+         }
+         pos1=pos2+1;
+         pos2 = bbGetInputIn().find(";",pos2+1);
+   }
+   
+   bbSetOutputReturn(result);
+   //std::cout << "DFGO - ExecSystemCommand::DoProcess result=" << result << std::endl;
+   
     /* Grrr  not works in windows
       int i;
       char *str = (char*)bbGetInputIn().c_str();
index d10c26cb89868fca400e3a135f791bb7b0243e85..f86821b1c86de06120d51fce603d0bf75d41b332 100755 (executable)
@@ -2,8 +2,8 @@
   Program:   bbtk
   Module:    $RCSfile: bbstdExecSystemCommand.h,v $
   Language:  C++
-  Date:      $Date: 2009/05/14 14:43:38 $
-  Version:   $Revision: 1.7 $
+  Date:      $Date: 2012/10/11 10:49:45 $
+  Version:   $Revision: 1.8 $
 =========================================================================*/
 
 /* ---------------------------------------------------------------------
@@ -45,6 +45,7 @@ namespace bbstd
   public:
     BBTK_BLACK_BOX_INTERFACE(ExecSystemCommand,bbtk::AtomicBlackBox);
     BBTK_DECLARE_INPUT(In,std::string)
+    BBTK_DECLARE_OUTPUT(Return,int);
     BBTK_PROCESS(DoProcess);
     void DoProcess();
   };
@@ -53,7 +54,8 @@ namespace bbstd
   BBTK_NAME("ExecSystemCommand");
   BBTK_AUTHOR("eduardo.davila@creatis.insa-lyon.fr");
   BBTK_DESCRIPTION("Executes system (O.S.) commands");
-  BBTK_INPUT(ExecSystemCommand,In,"system (O.S.) commands separated by ';' , use '' to indicate strings ex. help 'graph' ",std::string,"");  
+  BBTK_INPUT(ExecSystemCommand,In,"system (O.S.) commands separated by ';' , use '' to indicate strings ex. help 'graph' ",std::string,"");
+  BBTK_OUTPUT(ExecSystemCommand,Return,"result (0 if no error or error number of the first error",int,"");
   BBTK_END_DESCRIBE_BLACK_BOX(ExecSystemCommand);
 
 } // EO namespace bbstd
index e03b89b49be35993fa7f9603d60b47aff5681f05..922524f159e0c66e10b6ffae3c48503456699bda 100644 (file)
@@ -6,7 +6,7 @@
 APP_START
 CATEGORY:Core Script
 DESCRIPTION:Plug Package script
-AUTHOR:Daniel Gonzalez
+AUTHOR:Daniel Gonzalez
 COMPLEXBOX:FALSE
 BOXES:7
 BOX
index 1acfd887aa77bbc02effd1a16a2a53f68faf4a3a..4fb5a19114984e52139805efec7c150e2696b703 100644 (file)
@@ -11,7 +11,7 @@ include itkvtk
 include wx
 include std
 
-author "Daniel Gonzalez"
+author "Daniel Gonzalez"
 description "Plug Package script"
 category "Core Script"