3604df
From 1632c1a3abbc35c76bfaf932e40d18d078f6abfb Mon Sep 17 00:00:00 2001
3604df
From: Aravinda VK <avishwan@redhat.com>
3604df
Date: Fri, 9 Sep 2016 12:40:38 +0530
3604df
Subject: [PATCH 45/86] eventsapi: Add conditional import for requests library
3604df
3604df
requests lib is used only during publishing event. gf_event python
3604df
imports utils.py, and indirectly imports requests lib even though
3604df
it is not required while sending event to eventsd.
3604df
3604df
Moved "import requests" inside the "plugin_webhook" function.
3604df
3604df
> Reviewed-on: http://review.gluster.org/15439
3604df
> Reviewed-by: Prashanth Pai <ppai@redhat.com>
3604df
> Smoke: Gluster Build System <jenkins@build.gluster.org>
3604df
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
3604df
> Reviewed-by: Kotresh HR <khiremat@redhat.com>
3604df
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
3604df
3604df
BUG: 1351589
3604df
Change-Id: Ie3c8088b43d4d7952d01352731999bf8519c73c4
3604df
Signed-off-by: Aravinda VK <avishwan@redhat.com>
3604df
Reviewed-on: https://code.engineering.redhat.com/gerrit/84748
3604df
Reviewed-by: Milind Changire <mchangir@redhat.com>
3604df
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
3604df
---
3604df
 events/src/utils.py |    4 +++-
3604df
 1 files changed, 3 insertions(+), 1 deletions(-)
3604df
3604df
diff --git a/events/src/utils.py b/events/src/utils.py
3604df
index db8ebfe..dadd9ae 100644
3604df
--- a/events/src/utils.py
3604df
+++ b/events/src/utils.py
3604df
@@ -15,7 +15,6 @@ import logging
3604df
 import fcntl
3604df
 from errno import ESRCH, EBADF
3604df
 
3604df
-import requests
3604df
 from eventsapiconf import (LOG_FILE,
3604df
                            WEBHOOKS_FILE,
3604df
                            DEFAULT_CONFIG_FILE,
3604df
@@ -145,6 +144,9 @@ def publish(ts, event_key, data):
3604df
 
3604df
 
3604df
 def plugin_webhook(message):
3604df
+    # Import requests here since not used in any other place
3604df
+    import requests
3604df
+
3604df
     message_json = json.dumps(message, sort_keys=True)
3604df
     logger.debug("EVENT: {0}".format(message_json))
3604df
     for url, token in _webhooks.items():
3604df
-- 
3604df
1.7.1
3604df