| # Gaudi Framework, version v21r7 |

Home |  | Generated: 22 Jan 2010

# main.cpp File Reference

`#include "Python.h"`
`#include <iostream>`
`#include <string>`
`#include <fstream>`
`#include <sstream>`

Include dependency graph for main.cpp:

Go to the source code of this file.

## Functions
int | main (int argc, char **argv)

## Function Documentation

int main | ( | int | argc,
|  | char ** | argv |
| ) |  |  |

Definition at line 11 of file main.cpp.

    00011                                    {
    00012   if (argc < 2 ) {
    00013     std::cout << "ERROR: insufficient command arguments" << std::endl;
    00014     return 0;
    00015   }
    00016   Py_Initialize();
    00017   // Get the Python version
    00018   std::string fullversion = Py_GetVersion();
    00019   std::string version( fullversion, 0, fullversion.find_first_of(' '));
    00020   std::string vers(version, 0, version.find_first_of('.',version.find_first_of('.')+1));
    00021   std::cout << "Python version: [" << vers << "]" << std::endl;
    00022
    00023   // Startup commands
    00024   PyRun_SimpleString( "print dir()" );
    00025
    00026   std::cout << "Running now: " << argv[1] << std::endl;
    00027   std::ifstream file(argv[1]);
    00028   std::stringstream str;
    00029   if( file ) {
    00030     char ch;
    00031     while( file.get(ch) ) str.put(ch);
    00032     PyRun_SimpleString( const_cast<char*>(str.str().c_str()) );
    00033     file.close();
    00034   }
    00035   else {
    00036     std::cout << "ERROR: could not open file " << argv[1] << std::endl;
    00037   }
    00038   std::cout << "Exiting now " << std::endl;
    00039 }