18 {
19 try {
20
21 Py_Initialize();
22 object main_module( ( handle<>( borrowed( PyImport_AddModule( "__main__" ) ) ) ) );
23 object main_namespace = main_module.attr( "__dict__" );
24
25
26 main_namespace["PythonAdaptor"] =
27 class_<PythonAdaptor>( "PythonAdaptor", boost::python::init<Gaudi::Interfaces::IOptionsSvc*>() )
29
30
32 main_namespace["adaptor"] = ptr( &adaptor );
33
34
35 std::string
command( preAction );
38 command +=
" with open(name) as f:\n";
39 command +=
" code = compile(f.read(), name, 'exec')\n";
41 command +=
"from GaudiKernel.Configurable import expandvars\nfrom GaudiKernel.Proxy.Configurable import "
42 "applyConfigurableUsers\napplyConfigurableUsers()\n";
44 command +=
"\nfor n, c in Configurable.allConfigurables.items():\n for p, v in c.getValuedProperties().items() "
45 ":\n v = expandvars(v)\n if type(v) == str : v = repr(v) # need double quotes\n elif "
46 "type(v) == long: v = '%d' % v # prevent pending 'L'\n adaptor.addPropertyToJobOptions(n,p,str(v))";
47
48
49 handle<> ignored( ( PyRun_String(
command.c_str(), Py_file_input, main_namespace.ptr(), main_namespace.ptr() ) ) );
50 } catch ( const error_already_set& ) {
51 std::cout << "Error in python script:" << std::endl;
52 PyErr_Print();
54 }
55
57}
void addPropertyToJobOptions(const std::string &client, const std::string &name, const std::string &value)
constexpr static const auto SUCCESS
constexpr static const auto FAILURE