mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-04-27 05:58:50 +00:00
Reformat everything.
This commit is contained in:
parent
3f2213791a
commit
340ff8586d
1008 changed files with 61301 additions and 58309 deletions
|
|
@ -54,29 +54,31 @@ from ansible.plugins.callback import CallbackBase
|
|||
|
||||
|
||||
class CallbackModule(CallbackBase):
|
||||
|
||||
CALLBACK_VERSION = 2.0
|
||||
CALLBACK_TYPE = 'notification'
|
||||
CALLBACK_NAME = 'community.general.jabber'
|
||||
CALLBACK_TYPE = "notification"
|
||||
CALLBACK_NAME = "community.general.jabber"
|
||||
CALLBACK_NEEDS_WHITELIST = True
|
||||
|
||||
def __init__(self, display=None):
|
||||
|
||||
super().__init__(display=display)
|
||||
|
||||
if not HAS_XMPP:
|
||||
self._display.warning("The required python xmpp library (xmpppy) is not installed. "
|
||||
"pip install git+https://github.com/ArchipelProject/xmpppy")
|
||||
self._display.warning(
|
||||
"The required python xmpp library (xmpppy) is not installed. "
|
||||
"pip install git+https://github.com/ArchipelProject/xmpppy"
|
||||
)
|
||||
self.disabled = True
|
||||
|
||||
self.serv = os.getenv('JABBER_SERV')
|
||||
self.j_user = os.getenv('JABBER_USER')
|
||||
self.j_pass = os.getenv('JABBER_PASS')
|
||||
self.j_to = os.getenv('JABBER_TO')
|
||||
self.serv = os.getenv("JABBER_SERV")
|
||||
self.j_user = os.getenv("JABBER_USER")
|
||||
self.j_pass = os.getenv("JABBER_PASS")
|
||||
self.j_to = os.getenv("JABBER_TO")
|
||||
|
||||
if (self.j_user or self.j_pass or self.serv or self.j_to) is None:
|
||||
self.disabled = True
|
||||
self._display.warning('Jabber CallBack wants the JABBER_SERV, JABBER_USER, JABBER_PASS and JABBER_TO environment variables')
|
||||
self._display.warning(
|
||||
"Jabber CallBack wants the JABBER_SERV, JABBER_USER, JABBER_PASS and JABBER_TO environment variables"
|
||||
)
|
||||
|
||||
def send_msg(self, msg):
|
||||
"""Send message"""
|
||||
|
|
@ -85,7 +87,7 @@ class CallbackModule(CallbackBase):
|
|||
client.connect(server=(self.serv, 5222))
|
||||
client.auth(jid.getNode(), self.j_pass, resource=jid.getResource())
|
||||
message = xmpp.Message(self.j_to, msg)
|
||||
message.setAttr('type', 'chat')
|
||||
message.setAttr("type", "chat")
|
||||
client.send(message)
|
||||
client.disconnect()
|
||||
|
||||
|
|
@ -109,9 +111,9 @@ class CallbackModule(CallbackBase):
|
|||
unreachable = False
|
||||
for h in hosts:
|
||||
s = stats.summarize(h)
|
||||
if s['failures'] > 0:
|
||||
if s["failures"] > 0:
|
||||
failures = True
|
||||
if s['unreachable'] > 0:
|
||||
if s["unreachable"] > 0:
|
||||
unreachable = True
|
||||
|
||||
if failures or unreachable:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue