Gaudi Framework, version v23r4

Home   Generated: Mon Sep 17 2012

main.cpp

Go to the documentation of this file.
00001 #include "Python.h"
00002 #include <iostream>
00003 #include <string>
00004 #include <fstream>
00005 #include <sstream>
00006 
00007 
00008 int main ( int argc, char** argv ) {
00009   if (argc < 2 ) {
00010     std::cout << "ERROR: insufficient command arguments" << std::endl;
00011     return 0;
00012   }
00013   Py_Initialize();
00014   // Get the Python version
00015   std::string fullversion = Py_GetVersion();
00016   std::string version( fullversion, 0, fullversion.find_first_of(' '));
00017   std::string vers(version, 0, version.find_first_of('.',version.find_first_of('.')+1));
00018   std::cout << "Python version: [" << vers << "]" << std::endl;
00019 
00020   // Startup commands
00021   PyRun_SimpleString( "print dir()" );
00022 
00023   std::cout << "Running now: " << argv[1] << std::endl;
00024   std::ifstream file(argv[1]);
00025   std::stringstream str;
00026   if( file ) {
00027     char ch;
00028     while( file.get(ch) ) str.put(ch);
00029     PyRun_SimpleString( const_cast<char*>(str.str().c_str()) );
00030     file.close();
00031   }
00032   else {
00033     std::cout << "ERROR: could not open file " << argv[1] << std::endl;
00034   }
00035   std::cout << "Exiting now " << std::endl;
00036 
00037   return 0 ;
00038 }
00039 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Sep 17 2012 13:49:25 for Gaudi Framework, version v23r4 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004