ATLAS Offline Software
Loading...
Searching...
No Matches
python.PyAthena Namespace Reference

Classes

class  ModuleFacade

Functions

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

Variables

str __doc__ = """Module containing a set of Python base classes for PyAthena"""
str __author__ = "Sebastien Binet <binet@cern.ch>"
list __all__ = []
 data
list __pseudo_all__
 modname = arg.im_self.__class__.__module__
 print (" ==> moduletype")
 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()

python.PyAthena._get_native_libname ( libname)
protected

helpers

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

Definition at line 22 of file PyAthena.py.

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

◆ find_library()

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 59 of file PyAthena.py.

59def find_library(libname):
60 """
61 Helper function to find the (full)path to a library given its natural name.
62 @return None on failure
63
64 usage:
65 >>> find_library('AthenaServices')
66 '/afs/cern.ch/.../AtlasCore/[release]/InstallArea/.../libAthenaServices.so
67 """
68 import os
69
75 _sys_libname = _get_native_libname(libname)
76 # FIXME: REALLY not portable...
77 if os.name != 'posix':
78 raise RuntimeError('sorry OS [%s] is not supported' % os.name)
79
80 if 'LD_LIBRARY_PATH' in os.environ:
81 for d in os.environ['LD_LIBRARY_PATH'].split(os.pathsep):
82 lib = os.path.join(d, _sys_libname)
83 if os.path.exists(lib):
84 return lib
85 return
86
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:179

◆ load_library()

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 41 of file PyAthena.py.

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

◆ py_reload()

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 105 of file PyAthena.py.

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

◆ reload_module()

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 87 of file PyAthena.py.

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

Variable Documentation

◆ __all__

list python.PyAthena.__all__ = []
private

data

Definition at line 11 of file PyAthena.py.

◆ __author__

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

Definition at line 8 of file PyAthena.py.

◆ __doc__

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

Definition at line 7 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 'services',
7 'algs'
8 ]

Definition at line 12 of file PyAthena.py.

◆ cfg_methods

python.PyAthena.cfg_methods = dir(Configurable)

Definition at line 148 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 149 of file PyAthena.py.

◆ fct_name

python.PyAthena.fct_name = arg.im_func.__name__

Definition at line 134 of file PyAthena.py.

◆ klass

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

Definition at line 132 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 129 of file PyAthena.py.

◆ module

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

Definition at line 130 of file PyAthena.py.

◆ new_fct

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

Definition at line 135 of file PyAthena.py.

◆ obj

python.PyAthena.obj = arg.im_self

Definition at line 131 of file PyAthena.py.

◆ v

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

Definition at line 153 of file PyAthena.py.