How to use dumpProperties method in fMBT

Best Python code snippet using fMBT_python

DumpProperties.py

Source:DumpProperties.py Github

copy

Full Screen

1# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration2# File: AthenaCommon/python/DumpProperties.py3# Author: Wim Lavrijsen (WLavrijsen@lbl.gov)4"""Dump all properties from Gaudi objects in a given namespace."""5import os, sys, re, types6import GaudiPython7### data ---------------------------------------------------------------------8__version__ = '1.2.0'9__author__ = 'Wim Lavrijsen (WLavrijsen@lbl.gov)'10__all__ = [ 'pprint', 'dump', 'dumpSet', 'dumpAlgorithms', 'dumpServices' ]11indent = ' '12### logging and messages -----------------------------------------------------13import logging14log = logging.getLogger( 'DumpProperties' )15### helper -------------------------------------------------------------------16def _printFromLookup( ns, listing, lookup, extra, klass ):17 """<internal>"""18 19 if not ns.has_key( 'theApp' ):20 log.error( 'given namespace does not contain "theApp"' )21 return22 if not ns.has_key( lookup ):23 log.error( 'given namespace does not contain "%s" lookup', lookup )24 return25 app = ns[ 'theApp' ]26 if app.state() != app.State.CONFIGURED:27 listing = []28 for name, obj in ns.items():29 if isinstance( obj, klass ):30 listing.append( name )31 else:32 listing = getattr( app, listing )()33 if extra and type(extra) != list:34 extra = getattr( app, extra )35 extra = [ e for e in extra if not e in listing ]36 lookup = ns[ lookup ]37 for name in listing:38 pprint( lookup( name ) )39 for name in extra:40 pprint( klass( name ) )41### function pprint ---------------------------------------------------------42def pprint( obj, stream = sys.stdout ):43 """Pretty print the properties of the given Gaudi object."""44 from Configurable import Configurable45 if isinstance( obj, Configurable ):46 stream.write( str(obj) )47 stream.write( '\n' )48 return49 try:50 stream.write( obj.name() + os.linesep )51 except TypeError:52 print obj53 for prop, value in obj.properties().items():54 if not obj._ip:55 try:56 value = eval( value )57 except:58 pass59 if value and type(value) == list:60 stream.write( indent + '%s = [\n' % prop )61 nv = len(value)62 for i in range(nv):63 v = value[i]64 if type(v) == str:65 v = '"%s"' % v66 stream.write( 2*indent + str(v) + ( i == nv-1 and "\n" or ",\n" ) )67 stream.write( indent + ']\n' )68 continue69 if hasattr( value, 'value' ) and callable( value.value ):70 value = value.value()71 if type(value) == str:72 value = '"%s"' % value73 stream.write( indent + '%-20s = %s\n' % (prop,value) )74 stream.write( os.linesep )75### function dump -----------------------------------------------------------76def dump( opt = [ 'set' ], ns = None ):77 """Dump properties of Gaudi objects; opt can be 'set', 'algorithms', 'services',78'all', or a list of a combination of these. The given namespace must contain the79application manager."""80 if ns == None:81 import __main__82 ns = __main__.__dict__ 83 if hasattr( opt, 'properties' ) and hasattr( opt, 'name' ):84 pprint( opt )85 return86 if type(opt) == str:87 opt = [ opt ]88 if 'set' in opt:89 log.info( ' ***** dumping properties of configured objects ***** ' )90 dumpSet( ns )91 all = 'all' in opt92 if all or 'algorithms' in opt:93 log.info( ' ***** dumping algorithm properties ***** ' )94 dumpAlgorithms( ns )95 if all or 'services' in opt:96 log.info( ' ***** dumping service properties ***** ' )97 dumpServices( ns )98 99### selected dump functions -------------------------------------------------100def dumpSet( ns = None ):101 """Dump all Gaudi objects that have had their properties set. The namespace must102contain the application manager."""103 if ns == None:104 import __main__105 ns = __main__.__dict__106 for name, obj in ns.items():107 if isinstance( obj, GaudiPython.Bindings.iProperty ) or name == "StoreGate":108 pprint( obj )109def dumpAlgorithms( ns = None ):110 """Dump all algorithm properties. The namespace must contain the application mgr."""111 if ns == None:112 import __main__113 ns = __main__.__dict__114 _printFromLookup( ns, 'algorithms', 'Algorithm', 'TopAlg', GaudiPython.Bindings.iAlgorithm )115def dumpServices( ns = None ):116 """Dump all service properties. The namespace must contain the application mgr."""117 if ns == None:118 import __main__119 ns = __main__.__dict__...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fMBT automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful