Blob Blame History Raw
From 1632c1a3abbc35c76bfaf932e40d18d078f6abfb Mon Sep 17 00:00:00 2001
From: Aravinda VK <avishwan@redhat.com>
Date: Fri, 9 Sep 2016 12:40:38 +0530
Subject: [PATCH 45/86] eventsapi: Add conditional import for requests library

requests lib is used only during publishing event. gf_event python
imports utils.py, and indirectly imports requests lib even though
it is not required while sending event to eventsd.

Moved "import requests" inside the "plugin_webhook" function.

> Reviewed-on: http://review.gluster.org/15439
> Reviewed-by: Prashanth Pai <ppai@redhat.com>
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
> Reviewed-by: Kotresh HR <khiremat@redhat.com>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>

BUG: 1351589
Change-Id: Ie3c8088b43d4d7952d01352731999bf8519c73c4
Signed-off-by: Aravinda VK <avishwan@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/84748
Reviewed-by: Milind Changire <mchangir@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 events/src/utils.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/events/src/utils.py b/events/src/utils.py
index db8ebfe..dadd9ae 100644
--- a/events/src/utils.py
+++ b/events/src/utils.py
@@ -15,7 +15,6 @@ import logging
 import fcntl
 from errno import ESRCH, EBADF
 
-import requests
 from eventsapiconf import (LOG_FILE,
                            WEBHOOKS_FILE,
                            DEFAULT_CONFIG_FILE,
@@ -145,6 +144,9 @@ def publish(ts, event_key, data):
 
 
 def plugin_webhook(message):
+    # Import requests here since not used in any other place
+    import requests
+
     message_json = json.dumps(message, sort_keys=True)
     logger.debug("EVENT: {0}".format(message_json))
     for url, token in _webhooks.items():
-- 
1.7.1