-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathalert_handler.py
More file actions
44 lines (34 loc) · 935 Bytes
/
alert_handler.py
File metadata and controls
44 lines (34 loc) · 935 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from collections import deque
from database_handler import insert_alert
alert_queue = deque()
frame_stack = []
class AlertNode:
def __init__(self, data):
self.data = data
self.next = None
class AlertHistory:
def __init__(self):
self.head = None
def add_alert(self, data):
new_node = AlertNode(data)
new_node.next = self.head
self.head = new_node
def display(self):
current = self.head
while current:
print(current.data)
current = current.next
history = AlertHistory()
def enqueue_alert(alert):
alert_queue.append(alert)
def push_frame(frame):
frame_stack.append(frame)
def undo_last_frame():
if frame_stack:
return frame_stack.pop()
return None
def process_alerts():
while alert_queue:
alert = alert_queue.popleft()
history.add_alert(alert)
insert_alert(alert)