40 std::vector<std::string> streams;
48 ATH_MSG_DEBUG(
"A trigger in stream " << tag.type() <<
"_" << tag.name() <<
" was fired in this event.");
49 std::string stream_fullname = tag.type() +
"_" + tag.name();
52 ATH_MSG_WARNING(
"You have not requested any specific streams, going to allow all streams");
53 streams.emplace_back(stream_fullname);
59 streams.emplace_back(stream_fullname);
61 bool isPublic =
false;
68 PyObject* pProjectTag = PyUnicode_FromString(tag.c_str());
72 ATH_MSG_WARNING(
"Failed to create Python Unicode object from project tag");
75 PyObject* pHelper = PyImport_ImportModule(
"EventDisplaysOnline.EventDisplaysOnlineHelpers");
79 ATH_MSG_WARNING(
"Failed to import EventDisplaysOnline.EventDisplaysOnlineHelpers module");
82 PyObject* EventCanBeSeenByPublic = PyObject_GetAttrString(pHelper,
"EventCanBeSeenByPublic");
83 if (!EventCanBeSeenByPublic || !PyCallable_Check(EventCanBeSeenByPublic)) {
85 ATH_MSG_WARNING(
"Could not find or call EventCanBeSeenByPublic function in EventDisplaysOnline.EventDisplaysOnlineHelpers module");
88 PyObject*
result = PyObject_CallFunctionObjArgs(EventCanBeSeenByPublic, pProjectTag, NULL);
94 isPublic = PyObject_IsTrue(
result);
98 Py_XDECREF(EventCanBeSeenByPublic);
101 Py_DECREF(pProjectTag);
104 streams.emplace_back(
"Public");
109 for (
const std::string& stream : streams){
110 ATH_MSG_DEBUG(
"streams where a trigger fired and in your desired streams list: " << stream);
112 std::random_shuffle(streams.begin(), streams.end());
114 if(!streams.empty()){
136 PyObject* pDirectory = PyUnicode_FromString(cString);
137 PyObject* pArgs = PyTuple_Pack(4, pDirectory, pMaxEvents, pCheckPair,pBeamSplash);
138 PyObject* pModule = PyImport_ImportModule(
const_cast< char*
>(
"EventDisplaysOnline.EventUtils"));
139 if(!pCheckPair || !pBeamSplash || !pMaxEvents || !pDirectory || !pArgs){
144 ATH_MSG_WARNING(
"Failed to import EventDisplaysOnline.EventUtils module");
146 ATH_MSG_DEBUG(
"Successfully imported EventDisplaysOnline.EventUtils module");
149 PyObject* cleanDirectory = PyObject_GetAttrString(pModule,
"cleanDirectory");
150 if (!cleanDirectory || !PyCallable_Check(cleanDirectory)) {
151 ATH_MSG_WARNING(
"Could not find or call cleanDirectory function in EventDisplaysOnline.EventUtils module");
153 ATH_MSG_DEBUG(
"Found cleanDirectory function in EventDisplaysOnline.EventUtils module");
156 PyObject_CallObject(cleanDirectory, pArgs);
157 if (PyErr_Occurred()) {
161 if (anyNullPtr(cleanDirectory)){
162 throw std::runtime_error(
"OnlineEventDisplaysSvc::endEvent: Py_DECREF on nullptr argument");
164 Py_DECREF(cleanDirectory);
167 if (anyNullPtr(pModule, pArgs, pCheckPair, pMaxEvents, pDirectory)){
168 throw std::runtime_error(
"OnlineEventDisplaysSvc::endEvent: Py_DECREF on nullptr argument");
172 Py_DECREF(pCheckPair);
173 Py_DECREF(pMaxEvents);
174 Py_DECREF(pDirectory);
190 const char* char_dir = directory.c_str();
193 if (access(char_dir, F_OK) == 0) {
194 struct stat directoryStat;
197 if (stat(char_dir, &directoryStat) == 0 && S_ISDIR(directoryStat.st_mode) &&
198 access(char_dir, W_OK) == 0) {
199 ATH_MSG_DEBUG(
"Going to write file to existing directory: " << directory);
200 if (directoryStat.st_gid != zpgid) {
201 ATH_MSG_DEBUG(
"Setting group to 'zp' for directory: " << directory);
202 chown(char_dir, -1, zpgid);
205 ATH_MSG_WARNING(
"Directory '" << directory <<
"' is not usable, trying next alternative");
209 auto rc = mkdir(char_dir, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
213 rc = chown(char_dir, -1, zpgid);
218 }
catch (
const std::system_error& err) {
219 ATH_MSG_ERROR(
"Failed to create output directory " << directory << err.what());