4 #include "GaudiKernel/MsgStream.h"
5 #include "GaudiKernel/ISvcLocator.h"
6 #include "GaudiKernel/SmartIF.h"
27 declareProperty(
"StartupScript", m_startupScript =
"" );
48 auto prpMgr = serviceLocator()->as<
IProperty>();
51 tmp.
assign(prpMgr->getProperty(
"JobOptionsType"));
52 if ( tmp.
value( ) ==
"NONE" ) {
53 tmp.
assign(prpMgr->getProperty(
"JobOptionsPath"));
59 char* progName[] = {
const_cast<char*
>(
"GaudiPython") };
64 PySys_SetArgv( 1, progName );
66 std::string fullversion = Py_GetVersion();
67 std::string version( fullversion, 0, fullversion.find_first_of(
' '));
68 std::string vers(version, 0, version.find_first_of(
'.',version.find_first_of(
'.')+1));
75 std::string libname =
"libpython" + vers +
".so";
76 dlopen(libname.c_str(), RTLD_GLOBAL | RTLD_LAZY);
81 PyRun_SimpleString(
"from gaudimodule import *" );
82 PyRun_SimpleString(
"g = AppMgr()" );
84 PyRun_SimpleString(
"theApp = g" );
85 PyRun_SimpleString(
"def Service(n): return g.service(n)" );
86 PyRun_SimpleString(
"def Algorithm(n): return g.algorithm(n)" );
87 PyRun_SimpleString(
"def Property(n): return g.service(n)" );
89 #if !defined( _WIN32 )
90 PyRun_SimpleString(
"import rlcompleter");
91 PyRun_SimpleString(
"rlcompleter.readline.parse_and_bind('tab: complete')");
116 std::stringstream stream;
120 buffer.reserve(
file.tellg());
121 file.seekg(0, std::ios::beg);
122 buffer.assign((std::istreambuf_iterator<char>{
file}),
123 std::istreambuf_iterator<char>{});
125 PyRun_SimpleString( buffer.c_str() );
130 PyRun_InteractiveLoop(stdin,
"\0");
Definition of the MsgStream class used to transmit messages.
StatusCode initialize() override
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
StatusCode finalize() override
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual StatusCode finalize()
Finalize the service. [IService::finalize()].
bool isFailure() const
Test for a status code of FAILURE.
#define DECLARE_COMPONENT(type)
auto end(reverse_wrapper< T > &w)
This class is used for returning status codes from appropriate routines.
std::string m_startupScript
Startup script.
This service handles scripting implemented using Python.
virtual ~PythonScriptingSvc()
Destructor.
const TYPE & value() const
explicit conversion
bool assign(const Property &source) override
get the value from another property
Base class used to extend a class implementing other interfaces.
virtual StatusCode run()
Run the service by taking full control. [IRunable::run()].
The IProperty is the basic interface for all components which have properties that can be set or get...
virtual StatusCode initialize()
Initialize the service. [IService::initialize()].