| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Attributes | List of all members
PythonConfig Class Reference

`#include <src/JobOptionsSvc/PythonConfig.h>`

Collaboration diagram for PythonConfig:
[legend]

## Public Member Functions
| PythonConfig (IJobOptionsSvc *jos)
StatusCode | evaluateConfig (const std::string &filename, const std::string &preAction, const std::string &postAction)

## Private Attributes
SmartIF< IJobOptionsSvc > | m_IJobOptionsSvc

## Detailed Description

Definition at line 25 of file PythonConfig.h.

## Constructor & Destructor Documentation

PythonConfig::PythonConfig | ( | IJobOptionsSvc * | jos | ) |
| inline

Definition at line 28 of file PythonConfig.h.

28 : m_IJobOptionsSvc( jos ){};
PythonConfig::m_IJobOptionsSvc
SmartIF< IJobOptionsSvc > m_IJobOptionsSvc
Definition: PythonConfig.h:32

## Member Function Documentation

StatusCode PythonConfig::evaluateConfig | ( | const std::string & | filename,
|  | const std::string & | preAction,
|  | const std::string & | postAction
| ) |  |

Definition at line 8 of file PythonConfig.cpp.

10 {
11 try {
12 // Prepare a Python environment
13 Py_Initialize();
14 object main_module( ( handle<>( borrowed( PyImport_AddModule( "__main__" ) ) ) ) );
15 object main_namespace = main_module.attr( "__dict__" );
16
17 // make the translator class known to Python
18 main_namespace["PythonAdaptor"] = class_<PythonAdaptor>( "PythonAdaptor", boost::python::init<IJobOptionsSvc*>() )
19 .def( "addPropertyToJobOptions", &PythonAdaptor::addPropertyToJobOptions );
20
21 // create an instance of it and pass it to Python
22 PythonAdaptor adaptor( m_IJobOptionsSvc );
23 main_namespace["adaptor"] = ptr( &adaptor );
24
25 // some python helper
26 std::string command( preAction );
27 command += "\nfor name in '";
28 command += filename + "'.split(','): execfile(name)\n";
29 command += "from GaudiKernel.Configurable import expandvars\nfrom GaudiKernel.Proxy.Configurable import "
30 "applyConfigurableUsers\napplyConfigurableUsers()\n";
31 command += postAction;
32 command += "\nfor n, c in Configurable.allConfigurables.items():\n for p, v in c.getValuedProperties().items() "
33 ":\n v = expandvars(v)\n if type(v) == str : v = '\"%s\"' % v # need double quotes\n elif "
34 "type(v) == long: v = '%d' % v # prevent pending 'L'\n adaptor.addPropertyToJobOptions(n,p,str(v))";
35
36 // Now fire off the translation
37 handle<> ignored( ( PyRun_String( command.c_str(), Py_file_input, main_namespace.ptr(), main_namespace.ptr() ) ) );
38 } catch ( error_already_set ) {
39 std::cout << "Error in python script:" << std::endl;
40 PyErr_Print();
41 return StatusCode::FAILURE;
42 }
43
44 return StatusCode::SUCCESS;
45 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
std::endl
T endl(T...args)
PythonAdaptor::addPropertyToJobOptions
void addPropertyToJobOptions(const std::string &client, const std::string &name, const std::string &value)
Definition: PythonConfig.h:15
std::string
STL class.
brunelWrapper.command
string command
Definition: brunelWrapper.py:94
PythonAdaptor
Definition: PythonConfig.h:11
PythonConfig::m_IJobOptionsSvc
SmartIF< IJobOptionsSvc > m_IJobOptionsSvc
Definition: PythonConfig.h:32
std::cout

## Member Data Documentation

SmartIF<IJobOptionsSvc> PythonConfig::m_IJobOptionsSvc
| private

Definition at line 32 of file PythonConfig.h.

The documentation for this class was generated from the following files:

- GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.h
- GaudiCoreSvc/src/JobOptionsSvc/PythonConfig.cpp