| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

Functions
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;
23 std::ifstream file(argv[1]);
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);
29 buffer.assign((std::istreambuf_iterator<char>{file}),
30 std::istreambuf_iterator<char>{});
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 }
std::istreambuf_iterator
gaudirun.argv
list argv
Definition: gaudirun.py:227
std::endl
T endl(T...args)
std::string
STL class.
std::string::find_first_of
T find_first_of(T...args)
end
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
ana.file
list file
Definition: ana.py:160
std::string::assign
T assign(T...args)
std::string::c_str
T c_str(T...args)
plotBacklogPyRoot.argc
tuple argc
Definition: plotBacklogPyRoot.py:128
std::cout
std::ifstream
STL class.
std::string::reserve
T reserve(T...args)