The Gaudi Framework
v27r1
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
main.cpp
Go to the documentation of this file.
1
#include "Python.h"
2
#include <iostream>
3
#include <string>
4
#include <fstream>
5
6
7
int
main
(
int
argc
,
char
**
argv
) {
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::ifstream::seekg
T seekg(T...args)
std::string
STL class.
main
int main(int argc, char *argv[])
Definition:
main.cpp:4
std::ifstream::close
T close(T...args)
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::ifstream::tellg
T tellg(T...args)
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)
GaudiPython
src
Embedded
main.cpp
Generated on Tue Mar 15 2016 17:04:12 for The Gaudi Framework by
1.8.9.1