@@ -131,6 +131,14 @@ class NoSuchCapability(Exception):
131131 """Thrown when the capability that has been referred to doesn't exist."""
132132 pass
133133
134+ class OperationError (Exception ):
135+ """Raised for a failed operation, such as a time out."""
136+ pass
137+
138+ class NotSupportedError (Exception ):
139+ """Raised for operations that are not supported on a given object."""
140+ pass
141+
134142def _trailing (template , * targets ):
135143 """Substring of *template* following all *targets*.
136144
@@ -2479,7 +2487,7 @@ def pause(self):
24792487 self .post ("control" , action = "pause" )
24802488 return self
24812489
2482- def results (self , timeout = None , wait_time = 1 , ** query_params ):
2490+ def results (self , ** query_params ):
24832491 """Returns a streaming handle to this job's search results. To get a
24842492 nice, Pythonic iterator, pass the handle to :class:`splunklib.results.ResultsReader`,
24852493 as in::
@@ -2494,50 +2502,21 @@ def results(self, timeout=None, wait_time=1, **query_params):
24942502 # events are returned as dicts with strings as values.
24952503 print event
24962504
2497- Results are not available until the job has finished. The method's
2498- behavior when called on an unfinished job is controlled by the *timeout*
2499- parameter. If *timeout* is
2500- "None" (the default), ``results`` throws a
2501- ``ValueError`` exception immediately. If *timeout* is an integer,
2502- ``results`` waits up to the value of *timeout* for the job to
2503- finish, and then throws a ``ValueError`` exception.
2505+ Results are not available until the job has finished. If called on
2506+ an unfinished job, the result is an empty event set.
25042507
2505- When *timeout* is "None", this method makes a single roundtrip
2508+ This method makes a single roundtrip
25062509 to the server, plus at most two additional round trips if
25072510 the ``autologin`` field of :func:`connect` is set to ``True``.
2508- With *timeout* set to an integer, this method
2509- polls repeatedly until it times out or the search has finished.
25102511
2511- :param timeout: The timeout period, in seconds, or "None" to fail immediately.
2512- :type timeout: ``float``
2513- :param wait_time: The minimum number of seconds to wait between polls.
2514- :type wait_time: ``float``
2515- :param kwargs: Additional parameters (optional). For a list of valid
2512+ :param query_params: Additional parameters (optional). For a list of valid
25162513 parameters, see `GET search/jobs/{search_id}/results
25172514 <http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#GET_search.2Fjobs.2F.7Bsearch_id.7D.2Fresults>`_.
25182515 :type query_params: ``dict``
25192516
25202517 :return: The ``InputStream`` IO handle to this job's results.
25212518 """
2522- if timeout is None :
2523- response = self .get ("results" , ** query_params )
2524- if response .status == 204 :
2525- raise ValueError ("Job is still running; cannot return any events." )
2526- else :
2527- return response .body
2528- else :
2529- timeout = timedelta (seconds = timeout )
2530- start = datetime .now ()
2531- while True :
2532- response = self .get ("results" , ** query_params )
2533- if response .status == 204 :
2534- if datetime .now () - start < timeout :
2535- sleep (wait_time )
2536- else :
2537- raise ValueError ("Job is still running; cannot return any events." )
2538- else :
2539- return response .body
2540-
2519+ return self .get ("results" , ** query_params ).body
25412520
25422521 def preview (self , ** query_params ):
25432522 """Returns a streaming handle to this job's preview search results.
@@ -3270,18 +3249,9 @@ def delete(self, name):
32703249
32713250 :rtype: The :class:`Roles`
32723251 """
3273-
32743252 return Collection .delete (self , name .lower ())
32753253
32763254
3277- class OperationError (Exception ):
3278- """Raised for a failed operation, such as a time out."""
3279- pass
3280-
3281- class NotSupportedError (Exception ):
3282- """Raised for operations that are not supported on a given object."""
3283- pass
3284-
32853255class Application (Entity ):
32863256 """Represents a locally-installed Splunk app."""
32873257 @property
0 commit comments