main.cpp File Reference
#include "Python.h"
#include <iostream>
#include <string>
#include <fstream>
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 7 of file main.cpp.

7  {
8  if (argc < 2 ) {
9  std::cout << "ERROR: insufficient command arguments" << std::endl;
10  return 0;
11  }
12  Py_Initialize();
13  // Get the Python version
14  std::string fullversion = Py_GetVersion();
15  std::string version( fullversion, 0, fullversion.find_first_of(' '));
16  std::string vers(version, 0, version.find_first_of('.',version.find_first_of('.')+1));
17  std::cout << "Python version: [" << vers << "]" << std::endl;
18 
19  // Startup commands
20  PyRun_SimpleString( "print dir()" );
21 
22  std::cout << "Running now: " << argv[1] << std::endl;
24  if ( file ) {
25  std::string buffer;
26  file.seekg(0, std::ios::end);
27  buffer.reserve(file.tellg());
28  file.seekg(0, std::ios::beg);
31  file.close();
32  PyRun_SimpleString( buffer.c_str() );
33  } else {
34  std::cout << "ERROR: could not open file " << argv[1] << std::endl;
35  }
36  std::cout << "Exiting now " << std::endl;
37 
38  return 0 ;
39 }
list argv
Definition: gaudirun.py:227
T endl(T...args)
STL class.
T find_first_of(T...args)
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
list file
Definition: ana.py:160
T assign(T...args)
T c_str(T...args)
STL class.
T reserve(T...args)