From a8bd0fd29364880d9531a0d64d73d7a2dc4d246d Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Feb 22 2019 13:17:57 +0000 Subject: Only print that we are sending to fedmsg/fedora-messaging if we are Signed-off-by: Pierre-Yves Chibon --- diff --git a/pagure/hooks/default.py b/pagure/hooks/default.py index 5d49b07..475969a 100644 --- a/pagure/hooks/default.py +++ b/pagure/hooks/default.py @@ -41,27 +41,31 @@ def send_fedmsg_notifications(project, topic, msg): # Send fedmsg and fedora-messaging notification # (if fedmsg and fedora-messaging are there and set-up) if always_fedmsg or (project.fedmsg_hook and project.fedmsg_hook.active): - try: - print(" - to fedmsg") - import fedmsg - - config = fedmsg.config.load_config([], None) - config["active"] = True - config["endpoints"]["relay_inbound"] = config["relay_inbound"] - fedmsg.init(name="relay_inbound", **config) - - pagure.lib.notify.fedmsg_publish(topic=topic, msg=msg) - except Exception: - _log.exception("Error sending fedmsg notifications on commit push") + if _config.get("FEDMSG_NOTIFICATIONS", True): + try: + print(" - to fedmsg") + import fedmsg + + config = fedmsg.config.load_config([], None) + config["active"] = True + config["endpoints"]["relay_inbound"] = config["relay_inbound"] + fedmsg.init(name="relay_inbound", **config) + + pagure.lib.notify.fedmsg_publish(topic=topic, msg=msg) + except Exception: + _log.exception( + "Error sending fedmsg notifications on commit push" + ) - try: - print(" - to fedora-message") - pagure.lib.notify.fedora_messaging_publish(topic, msg) - except Exception: - _log.exception( - "Error sending fedora-messaging notifications on " - "commit push" - ) + if _config.get("FEDORA_MESSAGING_NOTIFICATIONS", False): + try: + print(" - to fedora-message") + pagure.lib.notify.fedora_messaging_publish(topic, msg) + except Exception: + _log.exception( + "Error sending fedora-messaging notifications on " + "commit push" + ) def send_stomp_notifications(project, topic, msg):