`ReportingCommand` not compatible with python 3
I'm using a virtual env (similar to how Splunk Scientific Computing app does) to develop Python 3 applications whilst Splunk is still running Python 2.
The splunk-sdk-python says:
The Splunk SDK for Python requires Python 2.7+, including Python 3. The Splunk SDK for Python has been tested with Python v2.7 and v3.5.
However, I don't think this is true for ReportingCommand search commands. Any reporting command with a def map(): function with @Configuration() decorator gives the following error:
f = vars(command)[b'map'] # Function backing the map method
KeyError: b'map'
Which references this line:
https://github.com/splunk/splunk-sdk-python/blob/07278fafb1bef8b65638c2662d8962ecdf35326f/splunklib/searchcommands/reporting_command.py#L256
Tests
Testing shows that the b'map' byte string indexing is not compatible with Python 3.
class Test():
def map():
pass
vars(Test)[b'map']
print('Done!')
Python 3
➜ python --version & python decorator_test.py
Python 3.5.7
Traceback (most recent call last):
File "decorator_test.py", line 5, in <module>
vars(Test)[b'map']
KeyError: b'map'
Python 2
➜ python --version & python decorator_test.py
Python 2.7.9
Done!
Thanks for the bug report @willbowditch, we're open to a PR but currently preparing for .conf and don't have the bandwidth to investigate this further.
@shakeelmohamed submitted a PR https://github.com/splunk/splunk-sdk-python/pull/276
Not familiar with the splunk-sdk but the patch seems to fix the example code here on my development build (Splunk 7.0.1): https://github.com/splunk/splunk-sdk-python/blob/master/examples/searchcommands_app/package/bin/sum.py
Fixed and closed per https://github.com/splunk/splunk-sdk-python/pull/276