forked from morpheus65535/bazarr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdev_event_handler.py
More file actions
40 lines (30 loc) · 916 Bytes
/
dev_event_handler.py
File metadata and controls
40 lines (30 loc) · 916 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
# coding=utf-8
from .app import socketio
def event_stream(type, action="update", payload=None):
"""
:param type: The type of element.
:type type: str
:param action: The action type of element from update and delete.
:type action: str
:param payload: The payload to send, can be anything
"""
try:
payload = int(payload)
except (ValueError, TypeError):
pass
socketio.emit("data", {"type": type, "action": action, "payload": payload})
def show_message(msg):
event_stream(type="message", payload=msg)
def show_progress(id, header, name, value, count):
event_stream(
type="progress",
payload={
"id": id,
"header": header,
"name": name,
"value": value,
"count": count,
},
)
def hide_progress(id):
event_stream(type="progress", action="delete", payload=id)