Main Page
Namespaces
Classes
Package Documentation
FWCore
PythonFramework
src
PythonModule.cc
Go to the documentation of this file.
1
#ifndef FWCore_PythonFramework_PythonModule_h
2
#define FWCore_PythonFramework_PythonModule_h
3
4
#include "
FWCore/PythonParameterSet/interface/BoostPython.h
"
5
#include "
FWCore/PythonParameterSet/interface/PythonProcessDesc.h
"
6
7
#include "
FWCore/PythonFramework/interface/PythonEventProcessor.h
"
8
#include "
FWCore/Utilities/interface/Exception.h
"
9
10
// This is to give some special handling to cms::Exceptions thrown
11
// in C++ code called by python. Only at the very top level do
12
// we need the exception message returned by the function "what".
13
// We only need the central message here as this will get converted
14
// back into a cms::Exception again when control rises back into
15
// the C++ code. If necessary it would probably be possible to
16
// improve these messages even more by adding something in the python
17
// to add module type and label context to the messages being caught
18
// here. At this point we did not think it worth the time to implement.
19
namespace
{
20
void
translator(
cms::Exception
const
& ex) {
21
PyErr_SetString(PyExc_RuntimeError, ex.
message
().c_str());
22
}
23
}
24
25
BOOST_PYTHON_MODULE
(libFWCorePythonFramework)
26
{
27
boost::python::register_exception_translator<cms::Exception>(translator);
28
29
boost::python::class_<PythonEventProcessor, boost::noncopyable>(
"PythonEventProcessor"
, boost::python::init<PythonProcessDesc const&>())
30
.def(
"run"
, &
PythonEventProcessor::run
)
31
.def(
"totalEvents"
, &
PythonEventProcessor::totalEvents
)
32
.def(
"totalEventsPassed"
, &
PythonEventProcessor::totalEventsPassed
)
33
.def(
"totalEventsFailed"
, &
PythonEventProcessor::totalEventsFailed
)
34
;
35
}
36
#endif
BOOST_PYTHON_MODULE
BOOST_PYTHON_MODULE(libFWCorePythonFramework)
Definition:
PythonModule.cc:25
PythonEventProcessor::totalEvents
int totalEvents() const
Definition:
PythonEventProcessor.h:39
cms::Exception::message
std::string message() const
Definition:
Exception.cc:187
PythonEventProcessor.h
PythonProcessDesc.h
PythonEventProcessor::run
void run()
Definition:
PythonEventProcessor.cc:79
Exception.h
cms::Exception
Definition:
Exception.h:68
BoostPython.h
PythonEventProcessor::totalEventsPassed
int totalEventsPassed() const
Definition:
PythonEventProcessor.h:45
PythonEventProcessor::totalEventsFailed
int totalEventsFailed() const
Definition:
PythonEventProcessor.h:51
Generated for CMSSW Reference Manual by
1.8.11