From 538f112bc17a511b0117ccac31f6c2e5ff0ee97a Mon Sep 17 00:00:00 2001
From: Karsten Hopp <karsten@redhat.com>
Date: Fri, 8 Nov 2019 22:34:47 +0100
Subject: [PATCH 14/14] add callbacks for fedora-messaging

Signed-off-by: Karsten Hopp <karsten@redhat.com>
---
 callback_plugins/fedora_messaging_callback.py  | 16 ++++++----------
 callback_plugins/fedora_messaging_callback2.py | 17 +++++++----------
 2 files changed, 13 insertions(+), 20 deletions(-)

diff --git a/callback_plugins/fedora_messaging_callback.py b/callback_plugins/fedora_messaging_callback.py
index c83785e9b..31e918dde 100644
--- a/callback_plugins/fedora_messaging_callback.py
+++ b/callback_plugins/fedora_messaging_callback.py
@@ -29,10 +29,11 @@ except ImportError:
     # Ansible v1 compat
     CallbackBase = object
 
+
 def getlogin():
     try:
         user = os.getlogin()
-    except OSError, e:
+    except OSError as e:
         user = pwd.getpwuid(os.geteuid())[0]
     return user
 
@@ -45,11 +46,10 @@ class CallbackModule(CallbackBase):
     def __init__(self):
         pass
 
-
     def playbook_on_play_start(self, pattern):
         # This gets called once for each play.. but we just issue a message once
         # for the first one.  One per "playbook"
-        play = getattr(self, 'play', None)
+        play = getattr(self, "play", None)
         if play:
             # figure out where the playbook FILE is
             path = os.path.abspath(play.playbook.filename)
@@ -60,7 +60,7 @@ class CallbackModule(CallbackBase):
 
             if not self.playbook_path:
                 msg = Message(
-                    topic='ansible.playbook.start',
+                    topic="ansible.playbook.start",
                     body=dict(
                         playbook=path,
                         userid=getlogin(),
@@ -79,11 +79,7 @@ class CallbackModule(CallbackBase):
 
         results = dict([(h, stats.summarize(h)) for h in stats.processed])
         msg = Message(
-            topic='ansible.playbook.complete',
-            body=dict(
-                playbook=self.playbook_path,
-                userid=getlogin(),
-                results=results,
-            ),
+            topic="ansible.playbook.complete",
+            body=dict(playbook=self.playbook_path, userid=getlogin(), results=results),
         )
         publish(msg)
diff --git a/callback_plugins/fedora_messaging_callback2.py b/callback_plugins/fedora_messaging_callback2.py
index 733e159a7..3d1e357ac 100644
--- a/callback_plugins/fedora_messaging_callback2.py
+++ b/callback_plugins/fedora_messaging_callback2.py
@@ -34,10 +34,11 @@ try:
 except ImportError:
     from ansible.utils import md5 as secure_hash
 
+
 def getlogin():
     try:
         user = os.getlogin()
-    except OSError, e:
+    except OSError as e:
         user = pwd.getpwuid(os.geteuid())[0]
     return user
 
@@ -45,8 +46,8 @@ def getlogin():
 class CallbackModule(CallbackBase):
     """ Publish playbook starts and stops to fedora_messaging. """
 
-    CALLBACK_NAME = 'fedora_messaging_callback2'
-    CALLBACK_TYPE = 'notification'
+    CALLBACK_NAME = "fedora_messaging_callback2"
+    CALLBACK_TYPE = "notification"
     CALLBACK_VERSION = 2.0
     CALLBACK_NEEDS_WHITELIST = True
 
@@ -77,7 +78,7 @@ class CallbackModule(CallbackBase):
 
             if not self.playbook_path:
                 msg = Message(
-                    topic='ansible.playbook.start',
+                    topic="ansible.playbook.start",
                     body=dict(
                         playbook=path,
                         userid=getlogin(),
@@ -96,11 +97,7 @@ class CallbackModule(CallbackBase):
 
         results = dict([(h, stats.summarize(h)) for h in stats.processed])
         msg = Message(
-            topic='ansible.playbook.complete',
-            body=dict(
-                playbook=self.playbook_path,
-                userid=getlogin(),
-                results=results,
-            ),
+            topic="ansible.playbook.complete",
+            body=dict(playbook=self.playbook_path, userid=getlogin(), results=results),
         )
         publish(msg)
-- 
2.21.0

