@@ -118,11 +118,6 @@ class IncomparableException(Exception):
118118 so on) of a type that doesn't support it."""
119119 pass
120120
121- class JobNotReadyException (Exception ):
122- """Thrown when :meth:`Entity.refresh` is called on a job that is not ready,
123- and so can't be refreshed yet."""
124- pass
125-
126121class AmbiguousReferenceException (ValueError ):
127122 """Thrown when the name used to fetch an entity matches more than one entity."""
128123 pass
@@ -2462,13 +2457,10 @@ def is_ready(self):
24622457 :return: ``True`` if the job is ready, ``False`` if not.
24632458 :rtype: ``boolean``
24642459 """
2465- try :
2466- self .refresh ()
2467- self ._is_ready = True
2468- return self ._is_ready
2469- except JobNotReadyException :
2470- self ._is_ready = False
2460+ if self .get ().status == 204 :
24712461 return False
2462+ else :
2463+ return True
24722464
24732465 @property
24742466 def name (self ):
@@ -2487,41 +2479,6 @@ def pause(self):
24872479 self .post ("control" , action = "pause" )
24882480 return self
24892481
2490- def refresh (self , state = None ):
2491- """Refreshes the state of the search job.
2492-
2493- If *state* is provided, this method loads it as the new state for this
2494- job. Otherwise, the method makes a roundtrip to the server (by calling
2495- the :meth:`read` method of ``self``) to fetch an updated state,
2496- plus at most two additional round trips if
2497- the ``autologin`` field of :func:`connect` is set to ``True``.
2498-
2499- :param state: Entity-specific arguments (optional).
2500- :type state: ``dict``
2501- :return: The :class:`Job`.
2502-
2503- **Example**::
2504-
2505- import splunklib.client as client
2506- s = client.connect(...)
2507- search = s.jobs.create('search index=_internal | head 1')
2508- search.refresh()
2509-
2510- """
2511- if state is not None :
2512- self ._state = state
2513- else :
2514- response = self .get ()
2515- if response .status == 204 :
2516- self ._is_ready = False
2517- raise JobNotReadyException ()
2518- else :
2519- self ._is_ready = True
2520- raw_state = self ._load_state (response )
2521- raw_state ['links' ] = dict ([(k , urllib .unquote (v )) for k ,v in raw_state ['links' ].iteritems ()])
2522- self ._state = raw_state
2523- return self
2524-
25252482 def results (self , timeout = None , wait_time = 1 , ** query_params ):
25262483 """Returns a streaming handle to this job's search results. To get a
25272484 nice, Pythonic iterator, pass the handle to :class:`splunklib.results.ResultsReader`,
0 commit comments