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

Expect KeyError, but raised AttributeError in client.py def __contains__(self, item)

Open ukison opened this issue 10 years ago • 4 comments

this is my code

job = service.jobs.create(query_to_run, *_kwargs_search) while True: job.refresh() stats = { "isDone": job["isDone"], "doneProgress": float(job["doneProgress"])_100, "scanCount": int(job["scanCount"]) if "scanCount" in job else 0, "eventCount": int(job["eventCount"]) if "eventCount" in job else 0, "resultCount": int(job["resultCount"]) if "resultCount" in job else 0 }

and this is the stack

File "/Users/ukison/sqbu-github.cisco.com/ukison/debug-tools/splunk/GetSplunkResults.py", line 95, in getSplunkResults "scanCount": int(job["scanCount"]) if "scanCount" in job else 0, File "/Library/Python/2.7/site-packages/splunklib/client.py", line 885, in contains self[item] File "/Library/Python/2.7/site-packages/splunklib/client.py", line 928, in getitem return getattr(self, key) File "/Library/Python/2.7/site-packages/splunklib/client.py", line 923, in getattr raise AttributeError(key) AttributeError: scanCount

ukison avatar Dec 19 '15 01:12 ukison

We've just merged a fix to the develop branch. It will be out in the next release.

shakeelmohamed avatar Dec 01 '16 00:12 shakeelmohamed

hi @shakeelmohamed do you know since what version of splunk python sdk is this fix available?

duxing avatar Oct 08 '18 18:10 duxing

@duxing hi, the fix has been available since v1.6.1. See this commit: https://github.com/splunk/splunk-sdk-python/commit/70981e8f294ba78cd2537920813c8ccb0be4ab00

shakeelmohamed avatar Oct 08 '18 19:10 shakeelmohamed

@shakeelmohamed thank you very much!

duxing avatar Oct 08 '18 19:10 duxing