The Gaudi Framework
v26r0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
main.cpp
Go to the documentation of this file.
1
#include "Python.h"
2
#include <iostream>
3
#include <string>
4
#include <fstream>
5
#include <sstream>
6
7
8
int
main
(
int
argc
,
char
**
argv
) {
9
if
(argc < 2 ) {
10
std::cout <<
"ERROR: insufficient command arguments"
<< std::endl;
11
return
0;
12
}
13
Py_Initialize();
14
// Get the Python version
15
std::string fullversion = Py_GetVersion();
16
std::string version( fullversion, 0, fullversion.find_first_of(
' '
));
17
std::string vers(version, 0, version.find_first_of(
'.'
,version.find_first_of(
'.'
)+1));
18
std::cout <<
"Python version: ["
<< vers <<
"]"
<< std::endl;
19
20
// Startup commands
21
PyRun_SimpleString(
"print dir()"
);
22
23
std::cout <<
"Running now: "
<< argv[1] << std::endl;
24
std::ifstream
file
(argv[1]);
25
std::stringstream str;
26
if
( file ) {
27
char
ch;
28
while
( file.get(ch) ) str.put(ch);
29
PyRun_SimpleString( const_cast<char*>(str.str().c_str()) );
30
file.close();
31
}
32
else
{
33
std::cout <<
"ERROR: could not open file "
<< argv[1] << std::endl;
34
}
35
std::cout <<
"Exiting now "
<< std::endl;
36
37
return
0 ;
38
}
39
System::argc
GAUDI_API long argc()
Number of arguments passed to the commandline (==numCmdLineArgs()); just to match argv call...
Definition:
System.cpp:526
gaudirun.argv
list argv
Definition:
gaudirun.py:192
main
int main(int argc, char *argv[])
Definition:
main.cpp:4
ana.file
list file
Definition:
ana.py:160
GaudiPython
src
Embedded
main.cpp
Generated on Tue Jan 20 2015 20:27:13 for The Gaudi Framework by
1.8.7