ATLAS Offline Software
Loading...
Searching...
No Matches
psc::Utils Namespace Reference

Classes

class  ScopeTimer
 Very simple timer class. More...

Functions

bool execPython (const std::string &pyCmd)
 Execute a python command in the python interpreter.
bool execPython (const std::vector< std::string > &pyCmds)
 Execute a set of python commands in the python interpreter.
bool pyInclude (const std::string &pyFileName)
 Include a python file via AthenaCommon.Include.
bool execFile (const std::string &pyFileName)
 Execute a python file (via include or import)

Function Documentation

◆ execFile()

bool psc::Utils::execFile ( const std::string & pyFileName)

Execute a python file (via include or import)

Parameters
pyFileNameFile name
Returns
Success/Failure

Definition at line 54 of file HLT/Trigger/TrigControl/TrigPSC/src/Utils.cxx.

55{
56 if (pyFileName.find(".py")!=std::string::npos)
57 return pyInclude(pyFileName);
58 else
59 return psc::Utils::execPython("import " + pyFileName);
60}
bool pyInclude(const std::string &pyFileName)
Include a python file via AthenaCommon.Include.
bool execPython(const std::string &pyCmd)
Execute a python command in the python interpreter.

◆ execPython() [1/2]

bool psc::Utils::execPython ( const std::string & pyCmd)

Execute a python command in the python interpreter.

Parameters
pyCmdpython statement
Returns
Success/Failure

Definition at line 24 of file HLT/Trigger/TrigControl/TrigPSC/src/Utils.cxx.

25{
26 ERS_DEBUG(1, pyCmd );
27 if ( PyRun_SimpleString(const_cast<char*>(pyCmd.c_str())) != 0 ) {
28 ERS_PSC_ERROR("Error executing " << pyCmd);
29 return false;
30 }
31 return true;
32}
#define ERS_PSC_ERROR(message)
Definition PscIssues.h:51

◆ execPython() [2/2]

bool psc::Utils::execPython ( const std::vector< std::string > & pyCmds)

Execute a set of python commands in the python interpreter.

Parameters
pyCmdsvector of python statements
Returns
Success/Failure

Definition at line 35 of file HLT/Trigger/TrigControl/TrigPSC/src/Utils.cxx.

36{
37 std::vector<std::string>::const_iterator iter;
38 for (iter = pyCmds.begin(); iter != pyCmds.end(); ++iter) {
39 if ( !psc::Utils::execPython(*iter) ) return false;
40 }
41 return true;
42}

◆ pyInclude()

bool psc::Utils::pyInclude ( const std::string & pyFileName)

Include a python file via AthenaCommon.Include.

Parameters
pyFileNameFile name
Returns
Success/Failure

Definition at line 45 of file HLT/Trigger/TrigControl/TrigPSC/src/Utils.cxx.

46{
47 std::ostringstream oss;
48 oss << "from AthenaCommon.Include import include" << std::endl;
49 oss << "include(\"" << pyFileName << "\")";
50 return psc::Utils::execPython(oss.str());
51}