ATLAS Offline Software
Classes | Functions | Variables
python.PyAthena Namespace Reference

Classes

class  ModuleFacade
 

Functions

def _get_native_libname (libname)
 helpers More...
 
def load_library (libname)
 
def find_library (libname)
 
def reload_module (modname)
 
def py_reload (*args)
 

Variables

string __doc__ = """Module containing a set of Python base classes for PyAthena"""
 
string __version__ = "$Revision: 1.16 $"
 
string __author__ = "Sebastien Binet <binet@cern.ch>"
 
list __all__ = []
 data More...
 
list __pseudo_all__
 
 modname = arg.im_self.__class__.__module__
 print (" ==> moduletype") More...
 
 module = reload (sys.modules[modname])
 
 obj = arg.im_self
 
 klass = getattr (module, obj.__class__.__name__)
 
 fct_name = arg.im_func.__name__
 
 new_fct = getattr (klass, fct_name)
 
 cfg_methods = dir(Configurable)
 
tuple d
 
 v = getattr (klass, k)
 

Function Documentation

◆ _get_native_libname()

def python.PyAthena._get_native_libname (   libname)
private

helpers

return the OS-native name from an OS-indenpendent one 

Definition at line 26 of file PyAthena.py.

26 def _get_native_libname(libname):
27  """ return the OS-native name from an OS-indenpendent one """
28  import sys
29  plat = sys.platform
30  if plat.count('linux')>0:
31  lib_prefix,lib_suffix = 'lib', '.so'
32  elif plat == 'win32':
33  lib_prefix,lib_suffix = '', '.dll'
34  elif plat == 'darwin':
35  lib_prefix,lib_suffix = 'lib','.dylib'
36  else:
37  raise RuntimeError ("sorry platform [%s] is not (yet?) supported"%plat)
38  _sys_libname = libname
39  if not _sys_libname.startswith (lib_prefix):
40  _sys_libname = ''.join([lib_prefix,_sys_libname])
41  if not _sys_libname.endswith (lib_suffix):
42  _sys_libname = ''.join([_sys_libname, lib_suffix])
43  return _sys_libname
44 

◆ find_library()

def python.PyAthena.find_library (   libname)
Helper function to find the (full)path to a library given its natural name.
 @return None on failure
 
usage:
 >>> find_library('AthenaServices')
 '/afs/cern.ch/.../AtlasCore/[release]/InstallArea/.../libAthenaServices.so

Definition at line 63 of file PyAthena.py.

63 def find_library(libname):
64  """
65  Helper function to find the (full)path to a library given its natural name.
66  @return None on failure
67 
68  usage:
69  >>> find_library('AthenaServices')
70  '/afs/cern.ch/.../AtlasCore/[release]/InstallArea/.../libAthenaServices.so
71  """
72  import os
73 
79  _sys_libname = _get_native_libname(libname)
80  # FIXME: REALLY not portable...
81  if os.name != 'posix':
82  raise RuntimeError('sorry OS [%s] is not supported' % os.name)
83 
84  if 'LD_LIBRARY_PATH' in os.environ:
85  for d in os.environ['LD_LIBRARY_PATH'].split(os.pathsep):
86  lib = os.path.join(d, _sys_libname)
87  if os.path.exists(lib):
88  return lib
89  return
90 

◆ load_library()

def python.PyAthena.load_library (   libname)
Helper method to load a library by its natural name, not the OS-native name.
But if the OS-native name is given, it is safely handled too. Note that there's
a problem on MacOSX, for which the OS-native name ends with .dylib, but for
which ATLAS builds .so libraries. Override the OS-native name (which should probably
be replaced by two attempts; one with the .dylib and the other with .so)
usage:
 >>> load_library ('AthenaServices')
 >>> load_library ('AthenaServicesDict')

Definition at line 45 of file PyAthena.py.

45 def load_library (libname):
46  """
47  Helper method to load a library by its natural name, not the OS-native name.
48  But if the OS-native name is given, it is safely handled too. Note that there's
49  a problem on MacOSX, for which the OS-native name ends with .dylib, but for
50  which ATLAS builds .so libraries. Override the OS-native name (which should probably
51  be replaced by two attempts; one with the .dylib and the other with .so)
52  usage:
53  >>> load_library ('AthenaServices')
54  >>> load_library ('AthenaServicesDict')
55  """
56  _sys_libname = _get_native_libname(libname)
57  from sys import platform
58  if platform == 'darwin':
59  _sys_libname = _sys_libname.replace('.dylib', '.so')
60  import ctypes
61  return ctypes.cdll.LoadLibrary (_sys_libname)
62 

◆ py_reload()

def python.PyAthena.py_reload ( args)
simple minded function to reload objects, methods and modules

example of usage:
>>> # edit and modify the execute methods of some PyAthena.Alg
... # class, then load back that definition
>>> PyAthena.py_reload (alg1.execute, alg2.execute)
>>> PyAthena.py_reload (alg1.execute)
>>> alg1.execute() # will use the new definition
>>> theApp.nextEvent() # will also use the new definitions
... # of both alg1 and alg2

Definition at line 109 of file PyAthena.py.

109 def py_reload (*args):
110  """simple minded function to reload objects, methods and modules
111 
112  example of usage:
113  >>> # edit and modify the execute methods of some PyAthena.Alg
114  ... # class, then load back that definition
115  >>> PyAthena.py_reload (alg1.execute, alg2.execute)
116  >>> PyAthena.py_reload (alg1.execute)
117  >>> alg1.execute() # will use the new definition
118  >>> theApp.nextEvent() # will also use the new definitions
119  ... # of both alg1 and alg2
120  """
121  import types, sys
122  from imp import reload
123  for i,arg in enumerate(args):
124  if isinstance (arg, types.ModuleType):

◆ reload_module()

def python.PyAthena.reload_module (   modname)
Helper method to reload a python module by name.
This is useful in the usual following case:
 >>> from Foo import MyAlg
 >>> assert (not 'Foo' in dir())
 >>> reload(Foo) # won't work
 >>> PyAthena.reload_module ('Foo') # will work
 >>> PyAthena.reload_module (Foo)   # will work too

Definition at line 91 of file PyAthena.py.

91 def reload_module (modname):
92  """
93  Helper method to reload a python module by name.
94  This is useful in the usual following case:
95  >>> from Foo import MyAlg
96  >>> assert (not 'Foo' in dir())
97  >>> reload(Foo) # won't work
98  >>> PyAthena.reload_module ('Foo') # will work
99  >>> PyAthena.reload_module (Foo) # will work too
100  """
101  import sys, types
102  from imp import reload
103  if isinstance (modname, types.ModuleType):
104  modname = modname.__name__
105  if modname in sys.modules:
106  return reload (sys.modules[modname])
107  raise ValueError('no module [%s] could be found'%modname)
108 

Variable Documentation

◆ __all__

list python.PyAthena.__all__ = []
private

data

Definition at line 14 of file PyAthena.py.

◆ __author__

string python.PyAthena.__author__ = "Sebastien Binet <binet@cern.ch>"
private

Definition at line 11 of file PyAthena.py.

◆ __doc__

string python.PyAthena.__doc__ = """Module containing a set of Python base classes for PyAthena"""
private

Definition at line 9 of file PyAthena.py.

◆ __pseudo_all__

list python.PyAthena.__pseudo_all__
private
Initial value:
1 = [ 'StatusCode',
2  'Alg',
3  'Svc',
4  'AlgTool',
5  'Aud',
6  'AthFilterAlgorithm',
7  'services',
8  'algs'
9  ]

Definition at line 15 of file PyAthena.py.

◆ __version__

string python.PyAthena.__version__ = "$Revision: 1.16 $"
private

Definition at line 10 of file PyAthena.py.

◆ cfg_methods

python.PyAthena.cfg_methods = dir(Configurable)

Definition at line 152 of file PyAthena.py.

◆ d

tuple python.PyAthena.d
Initial value:
1 = (k for k in dir(klass)
2  if not k.startswith('__') and k not in cfg_methods)

Definition at line 153 of file PyAthena.py.

◆ fct_name

python.PyAthena.fct_name = arg.im_func.__name__

Definition at line 138 of file PyAthena.py.

◆ klass

python.PyAthena.klass = getattr (module, obj.__class__.__name__)

Definition at line 136 of file PyAthena.py.

◆ modname

python.PyAthena.modname = arg.im_self.__class__.__module__

print (" ==> moduletype")

print ("-->fct:",new_fct.im_func)

print (" ==> methodtype") reload module holding the class' definition

print (" ==> classtype") reload module holding the class' definition

Definition at line 133 of file PyAthena.py.

◆ module

python.PyAthena.module = reload (sys.modules[modname])

Definition at line 134 of file PyAthena.py.

◆ new_fct

python.PyAthena.new_fct = getattr (klass, fct_name)

Definition at line 139 of file PyAthena.py.

◆ obj

python.PyAthena.obj = arg.im_self

Definition at line 135 of file PyAthena.py.

◆ v

python.PyAthena.v = getattr (klass, k)

Definition at line 157 of file PyAthena.py.

python.PyAthena._get_native_libname
def _get_native_libname(libname)
helpers
Definition: PyAthena.py:26
python.PyAthena.find_library
def find_library(libname)
Definition: PyAthena.py:63
python.PyAthena.load_library
def load_library(libname)
Definition: PyAthena.py:45
beamspotman.dir
string dir
Definition: beamspotman.py:623
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.PyAthena.py_reload
def py_reload(*args)
Definition: PyAthena.py:109
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
python.PyAthena.reload_module
def reload_module(modname)
Definition: PyAthena.py:91