splunk-sdk-python icon indicating copy to clipboard operation
splunk-sdk-python copied to clipboard

ResultsReader iterator error

Open bobwalden opened this issue 11 years ago • 4 comments

Using Splunk 6.2.1 and splunk-sdk-python 1.31

the following code throws an exception on the for loop:

    resultSet = job.events(**{"offset" : offset, "count" : total})
    events = results.ResultsReader(resultSet)
    for event in events:
        print event["_raw"]

+++++++++++++++++++++++++++++++++++++ Throws exception:

Traceback (most recent call last): File "monitor.py", line 35, in for event in events: File "/opt/home/bob/splunk-sdk-python/splunklib/results.py", line 205, in next return self._gen.next() File "/opt/home/bob/splunk-sdk-python/splunklib/results.py", line 249, in _parse_results text = "".join(elem.itertext()) AttributeError: itertext

++++++++++++++++++++++++++++++++++++++

this is code from a classroom example that has been unchanged for at least a year. not sure if the upgrade of 6.2.0 to 6.2.1 or the new version of the sdk is the problem. the resultSet is verified--ie, the search results from the events() method is valid, contains normal data, etc.

this same error also happens if we let the job finish and then access results from the results() method.

bobwalden avatar Jul 21 '15 21:07 bobwalden

@bobwalden does this still work with the latest 6.2.0?

Also, what version of Python are you using?

itay avatar Jul 21 '15 21:07 itay

I've talked to @bobwalden offline. This is a bug we introduced a while back for Python 2.6.x, we've already fixed it with 867dd46486fa2283a9f6a4c7b750808685dba49f on the develop branch.

shakeelmohamed avatar Jul 21 '15 21:07 shakeelmohamed

confirmed--i was on 2.6.9, updating python to 2.7.9 fixes the problem. should not have let the p-version get so far behind. sorry for the false alarm and thanks Shakeel for the fast support!

bobwalden avatar Jul 21 '15 22:07 bobwalden

Hi @bobwalden we've just released v1.4.0 that addresses this, if you want to revert to Python 2.6.x

shakeelmohamed avatar Aug 05 '15 00:08 shakeelmohamed