ATLAS Offline Software
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
python.FilePeekerLib.FilePeekerSvc Class Reference
Inheritance diagram for python.FilePeekerLib.FilePeekerSvc:
Collaboration diagram for python.FilePeekerLib.FilePeekerSvc:

Public Member Functions

def __init__ (self, name='FilePeekerSvc', **kw)
 
def initialize (self)
 
def finalize (self)
 
def handle (self, incident)
 
virtual StatusCode initialize () override
 Gaudi Service Implementation. More...
 
virtual StatusCode reinitialize () override
 
virtual StatusCode start () override
 
virtual StatusCode stop () override
 
virtual StatusCode finalize () override
 
virtual StatusCode sysInitialize () override
 
const char * typeName () const override
 return the std::type_info name of the underlying py-component This is used by concrete implementations to connect a python component to its C++ counter-part More...
 
virtual PyObjectself () override
 return associated python object. More...
 
virtual void handle (const Incident &incident) override
 callback method for the IIncidentSvc More...
 

Protected Member Functions

virtual bool setPyAttr (PyObject *pyobj) override
 attach the C++ component to its python cousin More...
 

Protected Attributes

PyObjectm_self
 Pointer to self (from the python world) More...
 

Detailed Description

a service to spy for file meta-data and store this collected data into
the pool file, in a python-pickle friendly format

Definition at line 677 of file FilePeekerLib.py.

Constructor & Destructor Documentation

◆ __init__()

def python.FilePeekerLib.FilePeekerSvc.__init__ (   self,
  name = 'FilePeekerSvc',
**  kw 
)

Definition at line 682 of file FilePeekerLib.py.

682  def __init__(self, name='FilePeekerSvc', **kw):
683  kw['name'] = name
684  super(FilePeekerSvc, self).__init__(**kw)
685 
686 

Member Function Documentation

◆ finalize() [1/2]

StatusCode PyAthena::Svc::finalize ( )
overridevirtualinherited

Definition at line 71 of file PyAthenaSvc.cxx.

72 {
73  ATH_MSG_INFO("Finalizing " << name() << "...");
74  return PyAthena::callPyMethod( m_self, "sysFinalize" );
75 }

◆ finalize() [2/2]

def python.FilePeekerLib.FilePeekerSvc.finalize (   self)

Definition at line 701 of file FilePeekerLib.py.

701  def finalize(self):
702  return StatusCode.Success
703 

◆ handle() [1/2]

void PyAthena::Svc::handle ( const Incident &  incident)
overridevirtualinherited

callback method for the IIncidentSvc

Definition at line 122 of file PyAthenaSvc.cxx.

123 {
125  if (0 == PyObject_HasAttrString (m_self, (char*)"handle")) {
126  // python side does not implement 'handle'. Fair enough.
127  // XXX FIXME: could say something though: we have been registered as
128  // listener, so there might be some kind of inconsistency...
129  return;
130  }
131 
132  PyObject *o = TPython::CPPInstance_FromVoidPtr ((void*)(&inc), "Incident");
133  if (0 == o) {
134  Py_XDECREF (o);
136  }
137 
138  PyObject *res = PyObject_CallMethod (m_self,
139  (char*)"handle",
140  (char*)"O", o);
141  if (0 == res) {
142  Py_XDECREF (res);
143  Py_DECREF (o);
145  }
146 
147  Py_DECREF (res);
148  Py_DECREF (o);
149  return;
150 }

◆ handle() [2/2]

def python.FilePeekerLib.FilePeekerSvc.handle (   self,
  incident 
)

Definition at line 704 of file FilePeekerLib.py.

704  def handle(self, incident):
705  tp = incident.type()
706  if tp == 'EndEvent':
707  pass
708  elif tp == 'BeginInputFile':
709  self.msg.info('input file name: [%s]', incident.fileName())
710  pass
711  else:
712  pass
713  return
714 

◆ initialize() [1/2]

StatusCode PyAthena::Svc::initialize ( )
overridevirtualinherited

Gaudi Service Implementation.

Definition at line 57 of file PyAthenaSvc.cxx.

58 {
59  ATH_MSG_INFO("Initializing " << name() << "...");
60  return PyAthena::callPyMethod( m_self, "sysInitialize" );
61 }

◆ initialize() [2/2]

def python.FilePeekerLib.FilePeekerSvc.initialize (   self)

Definition at line 687 of file FilePeekerLib.py.

687  def initialize(self):
688  # register with the incident svc
689  svc = PyAthena.py_svc('IncidentSvc', iface='IIncidentSvc')
690  if not svc:
691  self.msg.error('unable to get the incident svc')
692  return StatusCode.Failure
693 
694  for incident in ('EndEvent',
695  'BeginInputFile',):
696  svc.addListener(self, incident)
697  pass
698 
699  return StatusCode.Success
700 

◆ reinitialize()

StatusCode PyAthena::Svc::reinitialize ( )
overridevirtualinherited

Definition at line 64 of file PyAthenaSvc.cxx.

65 {
66  ATH_MSG_INFO("Re-Initializing " << name() << "...");
67  return PyAthena::callPyMethod( m_self, "sysReinitialize" );
68 }

◆ self()

virtual PyObject* PyAthena::Svc::self ( )
inlineoverridevirtualinherited

return associated python object.

BORROWED reference.

Definition at line 68 of file PyAthenaSvc.h.

68 { return m_self; }

◆ setPyAttr()

bool PyAthena::Svc::setPyAttr ( PyObject pyobj)
overrideprotectedvirtualinherited

attach the C++ component to its python cousin

Definition at line 154 of file PyAthenaSvc.cxx.

155 {
156  // now we tell the PyObject which C++ object it is the cousin of.
158  PyObject* pyobj = TPython::CPPInstance_FromVoidPtr
159  ( (void*)this, this->typeName() );
160  if ( !pyobj ) {
161  PyErr_Clear();
162  // try PyAthena::Svc
163  pyobj = TPython::CPPInstance_FromVoidPtr ((void*)this, "PyAthena::Svc");
165  ("could not dyncast component [" << name() << "] to a python "
166  << "object of type [" << this->typeName() << "] (probably a missing "
167  << "dictionary)" << endmsg
168  << "fallback to [PyAthena::Svc]...");
169  }
170  if ( !pyobj ) {
171  PyErr_Clear();
173  ("Could not dyncast component [" << name() << "] to a pyobject of type ["
174  << this->typeName() << "]");
175  } else {
176  if ( -1 == PyObject_SetAttrString(o, "_cppHandle", pyobj) ) {
177  PyErr_Clear();
179  ("Could not attach C++ handle [" << name() << "] to its python "
180  << "cousin !");
181  if ( -1 == PyObject_SetAttrString(o, "_cppHandle", Py_None) ) {
182  PyErr_Clear();
184  ("could not attach a dummy C++ handle [" << name() << "] to its "
185  << "python cousin !");
186  }
187  } else {
188  return true;
189  }
190  }
191  return false;
192 }

◆ start()

StatusCode PyAthena::Svc::start ( )
overridevirtualinherited

Definition at line 78 of file PyAthenaSvc.cxx.

79 {
80  return PyAthena::callPyMethod( m_self, "sysStart" );
81 }

◆ stop()

StatusCode PyAthena::Svc::stop ( )
overridevirtualinherited

Definition at line 84 of file PyAthenaSvc.cxx.

85 {
86  return PyAthena::callPyMethod( m_self, "sysStop" );
87 }

◆ sysInitialize()

StatusCode PyAthena::Svc::sysInitialize ( )
overridevirtualinherited

Definition at line 90 of file PyAthenaSvc.cxx.

91 {
93  ( "PyAthena::PyComponentMgr/PyComponentMgr", name() );
94  if ( !pyMgr.retrieve().isSuccess() ) {
96  ("Could not retrieve service [" << pyMgr.typeAndName() << "] !!");
97  return StatusCode::FAILURE;
98  }
99 
100  // first retrieve our python object cousin...
101  m_self = pyMgr->pyObject( this );
102 
103  if ( m_self == Py_None ) {
104  ATH_MSG_ERROR("Wrapped PyObject is NONE !");
105  return StatusCode::FAILURE;
106  }
107 
108  // re-route to usual sysInit...
109  return SvcBase_t::sysInitialize();
110 }

◆ typeName()

const char * PyAthena::Svc::typeName ( ) const
overrideinherited

return the std::type_info name of the underlying py-component This is used by concrete implementations to connect a python component to its C++ counter-part

Definition at line 114 of file PyAthenaSvc.cxx.

115 {
116  static const std::string tname = System::typeinfoName(typeid(*this));
117  return tname.c_str();
118 }

Member Data Documentation

◆ m_self

PyObject* PyAthena::Svc::m_self
protectedinherited

Pointer to self (from the python world)

Definition at line 89 of file PyAthenaSvc.h.


The documentation for this class was generated from the following file:
grepfile.info
info
Definition: grepfile.py:38
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
PyAthena::throw_py_exception
void throw_py_exception(bool display=true)
helper function to capture the boilerplate code for user friendly stack trace display
Definition: PyAthenaUtils.cxx:135
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
initialize
void initialize()
Definition: run_EoverP.cxx:894
RootUtils::PyGILStateEnsure
Definition: PyAthenaGILStateEnsure.h:20
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
Athena::typeinfoName
std::string typeinfoName(const std::type_info &ti)
Convert a type_info to a demangled string.
Definition: AthenaKernel/src/ClassName.cxx:23
PyAthena::Svc::typeName
const char * typeName() const override
return the std::type_info name of the underlying py-component This is used by concrete implementation...
Definition: PyAthenaSvc.cxx:114
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
PyAthena::Svc::m_self
PyObject * m_self
Pointer to self (from the python world)
Definition: PyAthenaSvc.h:89
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
error
Definition: IImpactPoint3dEstimator.h:70
PyObject
_object PyObject
Definition: IPyComponent.h:26
ServiceHandle
Definition: ClusterMakerTool.h:37