File size: 411 Bytes
9c48ae2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
from enum import Enum
from datetime import datetime
import json

class MessageType(Enum):
    RunTask = "run_task"
    Interrupt = "interrupt"

def timestamp():
    return datetime.strftime(datetime.now(), "%Y-%m-%d_%H:%M:%S.%f")


def format_message(action = None, data = None, msg = "ok"):
    message = {
        "action": action,
        "data": data,
        "msg": msg
    }
    return json.dumps(message)