splunk / splunk-sdk-python

Splunk Software Development Kit for Python
http://dev.splunk.com
Apache License 2.0
687 stars 369 forks source link

Custom command import fails #358

Closed gitarns closed 3 years ago

gitarns commented 3 years ago

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 commented 3 years ago

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