Skip to content

Commit

Permalink
Merge pull request #34926 from rallytime/lint-34923
Browse files Browse the repository at this point in the history
Lint #34923
  • Loading branch information
Nicole Thomas committed Jul 25, 2016
2 parents c663c8b + b3514ab commit a7e7ec6
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions salt/states/slack.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
'''
Send a message to Slack
=========================
=======================
This state is useful for sending messages to Slack during state runs.
Expand All @@ -25,6 +25,12 @@
'''

# Import Python libs
from __future__ import absolute_import

# Import Salt libs
from salt.exceptions import SaltInvocationError


def __virtual__():
'''
Expand Down Expand Up @@ -96,18 +102,18 @@ def post_message(name,
ret['comment'] = 'Slack message is missing: {0}'.format(message)
return ret

result = __salt__['slack.post_message'](
channel=channel,
message=message,
from_name=from_name,
api_key=api_key,
icon=icon,
)

if result:
try:
result = __salt__['slack.post_message'](
channel=channel,
message=message,
from_name=from_name,
api_key=api_key,
icon=icon,
)
except SaltInvocationError as sie:
ret['comment'] = 'Failed to send message: {0} ({1})'.format(name, sie)
else:
ret['result'] = True
ret['comment'] = 'Sent message: {0}'.format(name)
else:
ret['comment'] = 'Failed to send message: {0}'.format(name)

return ret

0 comments on commit a7e7ec6

Please sign in to comment.