-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
root
committed
Oct 20, 2019
1 parent
e1aba39
commit cef33dc
Showing
6 changed files
with
98 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#!/usr/bin/env python | ||
import logging | ||
|
||
from utils import notice | ||
|
||
logger = logging.getLogger("main") | ||
|
||
|
||
def msg_sender(config, msg, docker_info): | ||
# 获取配置 | ||
notice_config = config.get("notice") | ||
if not notice_config: | ||
logger.warn("未发现notice配置") | ||
return | ||
notice_method = notice_config.get("method") | ||
if not notice_method: | ||
logger.warn("未发现notice配置") | ||
return | ||
|
||
if not hasattr(notice, notice_method): | ||
logger.warn("notice方式不存在. 请检查配置") | ||
return | ||
timeout = notice_config.get("timeout", 10) | ||
msg_func = getattr(notice, notice_method) | ||
kwargs = {} | ||
if notice_method == "dingding": | ||
kwargs["timeout"] = timeout | ||
kwargs["token"] = notice_config["token"] | ||
kwargs["msg"] = msg | ||
elif notice_method == "webhook": | ||
docker_info["msg"] = msg | ||
|
||
kwargs["timeout"] = timeout | ||
kwargs["url"] = notice_config["url"] | ||
kwargs["hookinfo"] = docker_info | ||
else: | ||
logger.warn("notice方式不存在. 请检查配置") | ||
return | ||
msg_func(**kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters