Skip to content

Commit

Permalink
Merge pull request #1 from pkeeper/master
Browse files Browse the repository at this point in the history
Add sleep before result check; bind some vars to make them visible in…
  • Loading branch information
ryancurrah committed Nov 8, 2017
2 parents 58c43e4 + 61e643a commit f0543b6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions searchsplunk/searchsplunk.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import re
import warnings
import requests
from time import sleep
from xml.dom import minidom
from xml.parsers.expat import ExpatError
from .exceptions import SplunkInvalidCredentials
Expand Down Expand Up @@ -118,6 +119,7 @@ def search(self, search_query):

search_done = False
while not search_done:
sleep(1)
if self.__search_status(sid):
search_done = True
return self.__search_result(sid)
Expand All @@ -137,9 +139,9 @@ def __start_search(self, search_query):

s = self.request(method, uri, body={'search': search_query})

return minidom.parseString(
s.text
).getElementsByTagName('sid')[0].childNodes[0].nodeValue
xml_result = minidom.parseString(s.text)
sid = xml_result.getElementsByTagName('sid')[0].childNodes[0].nodeValue
return sid

def __search_status(self, sid):
"""
Expand Down

0 comments on commit f0543b6

Please sign in to comment.