<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Python -&amp;gt; ResultsReader -&amp;gt; AttributeError: 'module' object has no attribute 'ParseError' in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Python-gt-ResultsReader-gt-AttributeError-module-object-has-no/m-p/195120#M2625</link>
    <description>&lt;P&gt;Hello lpolo,&lt;/P&gt;

&lt;P&gt;The line of code you're hitting in results.py is masking the problem you've encountered. It's the result of a bug in the Python SDK. We will release a fix to this issue soon.&lt;/P&gt;

&lt;P&gt;I'd also like to understand the problem you've encountered and address it. Can you do the following?&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;At file "splunklib/results.py", line 258, in _parse_results, change&lt;/P&gt;

&lt;P&gt;except et.ParseError as pe:&lt;BR /&gt;
except et.ParseError as pe:&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;except SyntaxError as pe:
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;Rerun your script.&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Send me two things: The traceback and--if possible--the saved search you're running or--if that's not possible--some other search that produces the same result.&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
David Noble&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 16:11:54 GMT</pubDate>
    <dc:creator>David_Noble_at_</dc:creator>
    <dc:date>2020-09-28T16:11:54Z</dc:date>
    <item>
      <title>Python -&gt; ResultsReader -&gt; AttributeError: 'module' object has no attribute 'ParseError'</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-gt-ResultsReader-gt-AttributeError-module-object-has-no/m-p/195116#M2621</link>
      <description>&lt;P&gt;I need to call a saved search using resultsReader class using the python splunk sdk. The result set of the saved search is greater than 50K events. &lt;BR /&gt;
I might not be using correctly the API or there is a bug in the API. The problem I am facing is that after some events are returned I am getting the following exception in results.py.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Traceback (most recent call last):
  File "mysavedsearch.py", line 64, in &amp;lt;module&amp;gt;
    for re in results.ResultsReader(blocksearch_results):
  File "/opt/splunk/bin/scripts/splunk-sdk-python-1.2.2/examples/../splunklib/results.py", line 205, in next
    return self._gen.next()
  File "/opt/splunk/bin/scripts/splunk-sdk-python-1.2.2/examples/../splunklib/results.py", line 258, in _parse_results
    except et.ParseError as pe:
AttributeError: 'module' object has no attribute 'ParseError'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This is my code:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import urllib2,sys,csv,results,json
from time import sleep
import splunklib.client as client
import splunklib.results as results

HOST = "hello.com"
PORT = 8089
USERNAME = "user_id"
PASSWORD = "mypwd"
OWNER = "owner"
APP = "appname"

# Create a Service instance and log in
service = client.connect(
    host=HOST,
    port=PORT,
    username=USERNAME,
    password=PASSWORD,
    app=APP,
    owner=OWNER)
mysavedsearch = service.saved_searches["saved_search_name"]

# Run the saved search
job = mysavedsearch.dispatch()


# Wait for the job to finish
while True:
    job.refresh()
    stats = {"isDone": job["isDone"],
             "doneProgress": float(job["doneProgress"])*100,
              "scanCount": int(job["scanCount"]),
              "eventCount": int(job["eventCount"]),
              "resultCount": int(job["resultCount"])}
    status = ("\r%(doneProgress)03.1f%%   %(scanCount)d scanned   "
              "%(eventCount)d matched   %(resultCount)d results") % stats
    if stats["isDone"] == "1":
        break

count = 100
offset = 0

while (offset &amp;lt; int(resultCount)):
    kwargs_paginate = {"count": count,
                       "offset": offset}

    # Get the search results
    blocksearch_results = job.results(**kwargs_paginate)

    for re in results.ResultsReader(blocksearch_results):
        print re

    # Increase the offset to get the next set of results
    offset += count

job.cancel()
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Lp&lt;/P&gt;

&lt;P&gt;Note:&lt;BR /&gt;
The issue has been fixed in the next Python SDK version. &lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2014 16:59:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-gt-ResultsReader-gt-AttributeError-module-object-has-no/m-p/195116#M2621</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2014-03-19T16:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Python -&gt; ResultsReader -&gt; AttributeError: 'module' object has no attribute 'ParseError'</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-gt-ResultsReader-gt-AttributeError-module-object-has-no/m-p/195117#M2622</link>
      <description>&lt;P&gt;Hi @lpolo&lt;/P&gt;

&lt;P&gt;Can you give us some details on the environment.&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;What version of Python?&lt;/LI&gt;
&lt;LI&gt;What version of the SDK.&lt;/LI&gt;
&lt;LI&gt;Which OS/version are you using?&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2014 18:37:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-gt-ResultsReader-gt-AttributeError-module-object-has-no/m-p/195117#M2622</guid>
      <dc:creator>gblock_splunk</dc:creator>
      <dc:date>2014-03-19T18:37:37Z</dc:date>
    </item>
    <item>
      <title>Re: Python -&gt; ResultsReader -&gt; AttributeError: 'module' object has no attribute 'ParseError'</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-gt-ResultsReader-gt-AttributeError-module-object-has-no/m-p/195118#M2623</link>
      <description>&lt;P&gt;1) python2.6&lt;BR /&gt;
2) I tried with the latest SDK "splunk-sdk-python-1.2.2" and the same problem.&lt;BR /&gt;
3) RedHat. 2.6.32-358.23.2.el6.x86_64 #1 SMP Wed Oct 16 18:37:12 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Lp&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:11:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-gt-ResultsReader-gt-AttributeError-module-object-has-no/m-p/195118#M2623</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2020-09-28T16:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Python -&gt; ResultsReader -&gt; AttributeError: 'module' object has no attribute 'ParseError'</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-gt-ResultsReader-gt-AttributeError-module-object-has-no/m-p/195119#M2624</link>
      <description>&lt;P&gt;HI @lpolo.&lt;/P&gt;

&lt;P&gt;We've looked in to this and it is indeed a bug. We're going to fix it and we'll get it out there. &lt;/P&gt;

&lt;P&gt;Thanks for reporting this and for using the SDK!&lt;/P&gt;

&lt;P&gt;Glenn&lt;/P&gt;</description>
      <pubDate>Wed, 19 Mar 2014 18:53:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-gt-ResultsReader-gt-AttributeError-module-object-has-no/m-p/195119#M2624</guid>
      <dc:creator>gblock_splunk</dc:creator>
      <dc:date>2014-03-19T18:53:52Z</dc:date>
    </item>
    <item>
      <title>Re: Python -&gt; ResultsReader -&gt; AttributeError: 'module' object has no attribute 'ParseError'</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-gt-ResultsReader-gt-AttributeError-module-object-has-no/m-p/195120#M2625</link>
      <description>&lt;P&gt;Hello lpolo,&lt;/P&gt;

&lt;P&gt;The line of code you're hitting in results.py is masking the problem you've encountered. It's the result of a bug in the Python SDK. We will release a fix to this issue soon.&lt;/P&gt;

&lt;P&gt;I'd also like to understand the problem you've encountered and address it. Can you do the following?&lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;At file "splunklib/results.py", line 258, in _parse_results, change&lt;/P&gt;

&lt;P&gt;except et.ParseError as pe:&lt;BR /&gt;
except et.ParseError as pe:&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;to:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;except SyntaxError as pe:
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;OL&gt;
&lt;LI&gt;&lt;P&gt;Rerun your script.&lt;/P&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;P&gt;Send me two things: The traceback and--if possible--the saved search you're running or--if that's not possible--some other search that produces the same result.&lt;/P&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
David Noble&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:11:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-gt-ResultsReader-gt-AttributeError-module-object-has-no/m-p/195120#M2625</guid>
      <dc:creator>David_Noble_at_</dc:creator>
      <dc:date>2020-09-28T16:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: Python -&gt; ResultsReader -&gt; AttributeError: 'module' object has no attribute 'ParseError'</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Python-gt-ResultsReader-gt-AttributeError-module-object-has-no/m-p/195121#M2626</link>
      <description>&lt;P&gt;1) Line 258 changed.&lt;/P&gt;

&lt;P&gt;2) Script returned:&lt;/P&gt;

&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;
  File "feed_xcal_undefined_topN_daily.py.back", line 64, in &lt;MODULE&gt;&lt;BR /&gt;
    for re in results.ResultsReader(blocksearch_results):&lt;BR /&gt;
  File "/opt/splunk/bin/scripts/splunk-sdk-python-1.2.2/examples/../splunklib/results.py", line 205, in next&lt;BR /&gt;
    return self._gen.next()&lt;BR /&gt;
  File "/opt/splunk/bin/scripts/splunk-sdk-python-1.2.2/examples/../splunklib/results.py", line 249, in _parse_results&lt;BR /&gt;
    values.append(elem.text.encode('utf8'))&lt;BR /&gt;
AttributeError: 'NoneType' object has no attribute 'encode'&lt;/MODULE&gt;&lt;/P&gt;

&lt;P&gt;3) Query pasted in case 160361.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 16:11:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Python-gt-ResultsReader-gt-AttributeError-module-object-has-no/m-p/195121#M2626</guid>
      <dc:creator>lpolo</dc:creator>
      <dc:date>2020-09-28T16:11:57Z</dc:date>
    </item>
  </channel>
</rss>

