Skip to content

Commit 8af4951

Browse files
Merge pull request #300 from mapswipe/logging
If no Slack configuration exists continure without sending Slack mess…
2 parents 29dcc28 + 21bb2b6 commit 8af4951

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

mapswipe_workers/mapswipe_workers/utils/slack_helper.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
"""Initialize slack client with values provided by the config file"""
22

33
import json
4+
45
import slack
56

6-
from mapswipe_workers.definitions import CONFIG_PATH
7+
from mapswipe_workers.definitions import CONFIG_PATH, logger
78

89

910
def send_slack_message(message_type: str, project_name: str, project_id: str = None):
1011

1112
with open(CONFIG_PATH) as config_file:
1213
config = json.load(config_file)
14+
try:
1315
slack_channel = config["slack"]["channel"]
14-
slack_client = slack.WebClient(token=config["slack"]["token"])
16+
except KeyError:
17+
logger.info(
18+
"No configuration for Slack was found. "
19+
+ "No '{0}' Slack message was sent.".format(message_type)
20+
)
21+
return None
22+
slack_client = slack.WebClient(token=config["slack"]["token"])
1523

1624
if message_type == "success":
1725
message = (

0 commit comments

Comments
 (0)