15#include "Framework/Configure/Python.h"
30extern volatile std::sig_atomic_t preemption_received_;
32static void softFinish(
int sig, siginfo_t* siginfo,
void* context) {
33 preemption_received_ = 1;
52int main(
int argc,
char* argv[])
try {
59 for (ptrpy = 1; ptrpy < argc; ptrpy++) {
60 if (strstr(argv[ptrpy],
".py"))
break;
65 std::cout <<
" ** No python configuration script provided (must end in "
71 std::cout <<
"---- LDMXSW: Loading configuration --------" << std::endl;
77 argv + ptrpy + 1, argc - ptrpy - 1)};
78 p = std::make_unique<framework::Process>(config);
84 std::cerr <<
"Configuration Error [" << e.
name() <<
"] : " << e.
message()
86 std::cerr <<
" at " << e.
module() <<
":" << e.
line() <<
" in "
91 std::cout <<
"---- LDMXSW: Configuration load complete --------"
96 memset(&act,
'\0',
sizeof(act));
97 act.sa_sigaction = &softFinish;
98 act.sa_flags = SA_SIGINFO;
101 if (sigaction(SIGUSR2, &act, NULL) < 0) {
102 std::cerr <<
"Error setting up SIGUSR2 handler: " << strerror(errno)
108 if (sigaction(SIGINT, &act, NULL) < 0) {
109 std::cerr <<
"Error setting up SIGINT handler: " << strerror(errno)
114 std::cout <<
"---- LDMXSW: Starting event processing --------" << std::endl;
126 auto the_log_{framework::logging::makeLogger(
"fire")};
127 ldmx_log(fatal) <<
"[" << e.
name() <<
"] : " << e.
message() <<
"\n"
128 <<
" at " << e.
module() <<
":" << e.
line() <<
" in "
131 framework::logging::close();
135 std::cout <<
"---- LDMXSW: Event processing complete --------" << std::endl;
137}
catch (
const std::exception& e) {
138 std::cerr <<
"Unrecognized Exception: " << e.what() << std::endl;
143 std::cout <<
"Usage: fire {configuration_script.py} [arguments to "
144 "configuration script]"
146 std::cout <<
" configuration_script.py (required) python script to "
147 "configure the processing"
149 std::cout <<
" arguments (optional) passed to "
150 "configuration script when run in python"
Class which represents the process under execution.
Class encapsulating parameters for configuring a processor.
Standard base exception class with some useful output information.
const std::string & function() const
Get the function name where the exception occurred.
int line() const
Get the source line number where the exception occurred.
const std::string & message() const
Get the message of the exception.
const std::string & name() const
Get the name of the exception.
const std::string & stackTrace() const
Get the full stack trace.
const std::string & module() const
Get the source filename where the exception occurred.
Parameters run(const std::string &root_object, const std::string &pythonScript, char *args[], int nargs)
run the python script and extract the parameters
std::unique_ptr< Process > ProcessHandle
A handle to the current process Used to pass a process from ConfigurePython to fire....