Skip to content

Commit fb27bca

Browse files
author
David Noble
committed
DVPL-5428 Add error message when SPLUNK_HOME not defined
We now produce a warning message with a recommendation at the start of SearchCommand.process: {code} if u'SPLUNK_HOME' not in environ: self.logger.warning( u'SPLUNK_HOME environment variable is undefined.\n' u'If you are testing outside of Splunk, consider running under control of the Splunk CLI:\n' u' splunk cmd %s\n' u'If you are running inside of Splunk, SPLUNK_HOME should be defined. Consider troubleshooting your ' u'installation.', self) {code}
1 parent e897436 commit fb27bca

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

splunklib/searchcommands/search_command.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
from splunklib.client import Service
2020

2121
try:
22-
from collections import OrderedDict # python 2.7
22+
from collections import OrderedDict # python 2.7
2323
except ImportError:
24-
from ordereddict import OrderedDict # python 2.6
24+
from ordereddict import OrderedDict # python 2.6
2525

2626
from logging import _levelNames, getLevelName
2727
from inspect import getmembers
28-
from os import path
28+
from os import environ, path
2929
from sys import argv, exit, stdin, stdout
3030
from urlparse import urlsplit
3131
from xml.etree import ElementTree
@@ -51,6 +51,14 @@ def __init__(self):
5151
self.input_header = InputHeader()
5252
self.messages = MessagesHeader()
5353

54+
if u'SPLUNK_HOME' not in environ:
55+
self.logger.warning(
56+
u'SPLUNK_HOME environment variable is undefined.\n'
57+
u'If you are testing outside of Splunk, consider running under control of the Splunk CLI:\n'
58+
u' splunk cmd %s\n'
59+
u'If you are running inside of Splunk, SPLUNK_HOME should be defined. Consider troubleshooting your '
60+
u'installation.', self)
61+
5462
# Variables backing option/property values
5563

5664
self._default_logging_level = self.logger.level

0 commit comments

Comments
 (0)