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

Custom command import fails

Open gitarns opened this issue 6 years ago • 1 comments

Hello.

Import of the sdk doesn't work.

Simple test.py with:

from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration

sdk installed with (Centos 8): pip3 install -t . splunk-sdk

[root@splunk bin]# /opt/splunk/bin/python3 ./test.py Traceback (most recent call last): File "./test.py", line 1, in from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration File "/opt/splunk/etc/apps/test/bin/splunklib/searchcommands/init.py", line 145, in from .environment import * File "/opt/splunk/etc/apps/test/bin/splunklib/searchcommands/environment.py", line 120, in splunklib_logger, logging_configuration = configure_logging('splunklib') File "/opt/splunk/etc/apps/test/bin/splunklib/searchcommands/environment.py", line 103, in configure_logging fileConfig(filename, {'SPLUNK_HOME': splunk_home}) File "/opt/splunk/lib/python3.7/logging/config.py", line 79, in fileConfig handlers = _install_handlers(cp, formatters) File "/opt/splunk/lib/python3.7/logging/config.py", line 126, in _install_handlers hlist = cp["handlers"]["keys"] File "/opt/splunk/lib/python3.7/configparser.py", line 958, in getitem raise KeyError(key) KeyError: 'handlers'

gitarns avatar Nov 15 '20 00:11 gitarns

Ok. Managed to fix it. The splunk-sdk-python/examples/searchcommands_template/default/logging.conf doesn't work out of the box.

gitarns avatar Nov 15 '20 11:11 gitarns