# -*- coding: utf-8 -*-
import os
import sys

root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
if root_dir not in sys.path:
    sys.path.append(root_dir)

from my_config import set_config
from my_utils import send_msg_to_feishu
from log import Log
import datetime
config_, _ = set_config()
log_ = Log()

server_robot = {
    'webhook': 'https://open.feishu.cn/open-apis/bot/v2/hook/8de4de35-30ed-4692-8854-7a154e89b2f2',
    'key_word': '服务报警'
}
def _monitor(dt, hh, msg):
    """rov模型预测列表"""
    if hh > 6:
        msg_text = f"\n- 所属项目: rov-offline" \
                   f"\n- 告警名称: 离线更新数据不符合预期" \
                   f"\n- 所属环境: {config_.ENV_TEXT}" \
                   f"\n- now_date: {dt}" \
                   f"\n- now_h: {hh}" \
                   f"\n- 告警描述: {msg}"
        log_.info(f"msg_text = {msg_text}")
        send_msg_to_feishu(
            webhook=server_robot.get('webhook'),
            key_word=server_robot.get('key_word'),
            msg_text=msg_text
        )

if __name__ == '__main__':
    dt = datetime.datetime.today().strftime('%Y%m%d')
    hh = datetime.datetime.now().hour
    msg = sys.argv[1]
    _monitor(dt, hh, msg)
    log_.info("end")
