from msgbus import (
    TK_SYS_NAK,
    TK_EVT_EVENT,
)
from .. import logger
from .. import mb_context
from model.customexception import CleanRuptureException


def clean_rupture_on_open_day():
    # type: (...) -> None
    try:
        dest_name = "Ruptura"
        data = '\0CleanRupture\0OnOpenDay'
        msg = mb_context.MB_EasySendMessage(
            dest_name=dest_name,
            token=TK_EVT_EVENT,
            data=data,
        )
        if msg.token == TK_SYS_NAK:
            raise CleanRuptureException(msg.data)
    except (Exception, CleanRuptureException) as e:
        logger.exception('[clean_rupture] Exception {}'.format(e))
