65 Function in charge of generating a cache busting string.
68 length (int): _description_: The action id.
71 int: _description_: The result of the cache busting.
73 node_text =
"cache_busting"
74 data = str(ascii_letters + digits)
75 data_length = len(data)-1
76 cache_busting = f
"{node_text}_"
77 for i
in range(0, length):
78 cache_busting += data[randint(0, data_length)]
79 cache_busting += f
"_{node_text}"
113 Function in charge of locking an action.
116 node (int): _description_: The action to lock.
119 int: _description_: Returns self.success if it succeeded, self.error otherwise
121 title =
"lock_action"
122 self.
disp.log_debug(f
"Locking action {node}.", title)
124 self.
disp.log_debug(f
"Action {node} already locked.", title)
126 locked = self.
runtime_data.database_link.update_data_in_table(
127 table=CONST.TAB_ACTIONS,
132 if locked == self.
error:
133 msg = f
"Failed to lock action {node} by process {os.getpid()}"
134 self.
disp.log_debug(msg, title)
136 log_type=ACONST.TYPE_SERVICE,
142 msg = f
"Action {node} locked by process {os.getpid()}."
143 self.
disp.log_debug(msg, title)
145 log_type=ACONST.TYPE_SERVICE,
154 Function in charge of unlocking an action.
157 node (int): _description_: The action to unlock.
160 int: _description_: Returns self.success if it succeeded, self.error otherwise
162 title =
"unlock_action"
163 self.
disp.log_debug(f
"Unlocking action {node}.", title)
165 self.
disp.log_debug(f
"Action {node} already unlocked.", title)
167 locked = self.
runtime_data.database_link.update_data_in_table(
168 table=CONST.TAB_ACTIONS,
173 if locked == self.
error:
174 msg = f
"Failed to unlock action {node} by process {os.getpid()}"
175 self.
disp.log_debug(msg, title)
177 log_type=ACONST.TYPE_SERVICE,
183 msg = f
"Action {node} unlocked by process {os.getpid()}."
184 self.
disp.log_debug(msg, title)
186 log_type=ACONST.TYPE_SERVICE,
233 Function in charge of processing a given action.
236 node (int): _description_
241 title =
"process_action_node"
242 variable_scope = f
"action_{node}"
243 action_detail = self.
runtime_data.database_link.get_data_from_table(
244 table=CONST.TAB_ACTIONS,
249 if action_detail == self.
error:
250 msg = f
"Failed to get the action {node} details"
251 msg += f
"for process {os.getpid()}."
252 self.
disp.log_critical(msg, title)
254 log_type=ACONST.TYPE_SERVICE,
261 f
"action_detail = {action_detail}",
264 self.
variables.create_scope(scope_name=variable_scope)
265 self.
variables.clear_variables(scope=variable_scope)
267 node_key = f
"node_data_{node}_{cache_busting}"
270 variable_data=action_detail[0],
271 variable_type=type(action_detail[0]),
281 scope=variable_scope,
283 delay=CONST.API_REQUEST_DELAY
292 scope=variable_scope,
294 delay=CONST.API_REQUEST_DELAY
297 status = trigger_node.run(node_key)
298 except Exception
as e:
300 log_type=ACONST.TYPE_SERVICE_TRIGGER,
302 message=f
"Failed to run the trigger node: {e}",
307 scope=variable_scope,
308 log_type=ACONST.TYPE_SERVICE_TRIGGER
310 self.
variables.clear_variables(scope=variable_scope)
313 if status == self.
error:
315 log_type=ACONST.TYPE_SERVICE_TRIGGER,
317 message=
"Failed to run the trigger node.",
322 scope=variable_scope,
323 log_type=ACONST.TYPE_SERVICE_TRIGGER
325 self.
variables.clear_variables(scope=variable_scope)
329 status = action_node.run(node_key)
330 except Exception
as e:
332 log_type=ACONST.TYPE_SERVICE_ACTION,
334 message=f
"Failed to run the action node: {e}",
339 scope=variable_scope,
340 log_type=ACONST.TYPE_SERVICE_ACTION
344 if status == self.
error:
346 log_type=ACONST.TYPE_SERVICE_ACTION,
348 message=
"Failed to run the action node.",
353 scope=variable_scope,
354 log_type=ACONST.TYPE_SERVICE_ACTION