ATLAS Offline Software
TrigPyHelper.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2 
3 
8 
9 from GaudiPython import * # noqa
10 from GaudiPython import gbl, InterfaceCast
11 from GaudiPython.Bindings import Helper, iProperty
12 from AthenaCommon.Logging import logging
13 
14 class TrigApp(object):
15  """Helper class to work with Python bindings in athenaMT/PT"""
16 
17  log = logging.getLogger("TrigApp" )
18 
19  def service(self, name, iface = gbl.IService):
20  """Retrieve service with interface iface.
21  Example: trigApp.service('MessageSvc',gbl.IMessageSvc)"""
22 
23  svc = InterfaceCast(iface)(Helper.service(gbl.Gaudi.svcLocator(), name))
24  return svc
25 
26  def changeJobProperties(self, clientName, propertyName, newValue):
27  """Change the property of a client to a new value. Both client and property
28  can be a regular expression in which case all properties matching will
29  be changed to the new value. Note, this will only change properties that
30  already exist in the JobOptionsCatalogue.
31  Example: trigApp.changeJobProperties('.*', 'OutputLevel', DEBUG)"""
32 
33  jobOptSvc = InterfaceCast(gbl.Gaudi.Interfaces.IOptionsSvc)(Helper.service(gbl.Gaudi.svcLocator(), "JobOptionsSvc"))
34  if not jobOptSvc:
35  self.log.error("Cannot find JobOptionsSvc")
36  return
37 
38  import re
39  reClient = re.compile(clientName)
40  reProp = re.compile(propertyName)
41 
42 
44  for p in jobOptSvc.items():
45  name = p._0
46  value = p._1
47  client, prop = name.rsplit('.',1)
48  if reClient.match(client) and reProp.match(prop):
49  self.log.info("Changing %s.%s from '%s' to '%s'", client, prop, value, newValue)
50  iprop = iProperty(client)
51  setattr(iprop, prop, newValue)
52 
53  return
54 
55 
56 
57 trigApp = TrigApp()
58 
grepfile.info
info
Definition: grepfile.py:38
python.TrigPyHelper.TrigApp.log
log
Definition: TrigPyHelper.py:17
python.TrigPyHelper.TrigApp.changeJobProperties
def changeJobProperties(self, clientName, propertyName, newValue)
Definition: TrigPyHelper.py:26
python.TrigPyHelper.TrigApp.service
def service(self, name, iface=gbl.IService)
Definition: TrigPyHelper.py:19
python.TrigPyHelper.TrigApp
Definition: TrigPyHelper.py:14
pickleTool.object
object
Definition: pickleTool.py:30
error
Definition: IImpactPoint3dEstimator.h:70