Coverage for src/unit_cooler/util.py: 81%
12 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-28 08:08 +0000
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-28 08:08 +0000
1#!/usr/bin/env python3
2import logging
3import os
5import my_lib.notify.slack
8def notify_error(config, message, is_logging=True):
9 if is_logging: 9 ↛ 12line 9 didn't jump to line 12 because the condition on line 9 was always true
10 logging.error(message)
12 if ("slack" not in config) or ( 12 ↛ 16line 12 didn't jump to line 16 because the condition on line 12 was never true
13 (os.environ.get("TEST", "false") != "true") and (os.environ.get("DUMMY_MODE", "false") == "true")
14 ):
15 # NOTE: テストではなく、ダミーモードで実行している時は Slack 通知しない
16 return
18 try:
19 my_lib.notify.slack.error(
20 config["slack"]["bot_token"],
21 config["slack"]["error"]["channel"]["name"],
22 config["slack"]["from"],
23 message,
24 config["slack"]["error"]["interval_min"],
25 )
26 except Exception:
27 logging.exception("Failed to Notify via Slack")