Merge pull request #34926 from rallytime/lint-34923

Lint #34923
This commit is contained in:
Nicole Thomas 2016-07-25 08:53:41 -06:00 committed by GitHub
commit a7e7ec6d25

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
'''
Send a message to Slack
=========================
=======================
This state is useful for sending messages to Slack during state runs.
@ -25,6 +25,12 @@ The api key can be specified in the master or minion configuration like below:
'''
# Import Python libs
from __future__ import absolute_import
# Import Salt libs
from salt.exceptions import SaltInvocationError
def __virtual__():
'''
@ -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