Skip to content

Commit 07278fa

Browse files
committed
Release 1.6.8
2 parents e0c515b + 27dd408 commit 07278fa

File tree

6 files changed

+33
-7
lines changed

6 files changed

+33
-7
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Splunk SDK for Python Changelog
22

3+
## Version 1.6.8
4+
5+
### Bug Fix
6+
7+
* Fix custom search command on python 3 on windows
8+
39
## Version 1.6.7
410

511
### Changes

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
# The Splunk Software Development Kit for Python
55

6-
#### Version 1.6.6
6+
#### Version 1.6.8
77

88
The Splunk Software Development Kit (SDK) for Python contains library code and
99
examples designed to enable developers to build applications using Splunk.

examples/searchcommands_app/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ def run(self):
439439
setup(
440440
description='Custom Search Command examples',
441441
name=os.path.basename(project_dir),
442-
version='1.6.7',
442+
version='1.6.8',
443443
author='Splunk, Inc.',
444444
author_email='[email protected]',
445445
url='http://github.com/splunk/splunk-sdk-python',

splunklib/__init__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@
1616

1717
from __future__ import absolute_import
1818
from splunklib.six.moves import map
19-
__version_info__ = (1, 6, 7)
19+
__version_info__ = (1, 6, 8)
2020
__version__ = ".".join(map(str, __version_info__))

splunklib/searchcommands/internals.py

+17-3
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939

4040
csv.field_size_limit(10485760) # The default value is 128KB; upping to 10MB. See SPL-12117 for background on this issue
4141

42-
if sys.platform == 'win32':
42+
# SPL-175233 -- python3 stdout is already binary
43+
if sys.platform == 'win32' and sys.version_info <= (3, 0):
4344
# Work around the fact that on Windows '\n' is mapped to '\r\n'. The typical solution is to simply open files in
4445
# binary mode, but stdout is already open, thus this hack. 'CPython' and 'PyPy' work differently. We assume that
4546
# all other Python implementations are compatible with 'CPython'. This might or might not be a valid assumption.
@@ -339,6 +340,8 @@ class CsvDialect(csv.Dialect):
339340
doublequote = True
340341
skipinitialspace = False
341342
lineterminator = '\r\n'
343+
if sys.version_info >= (3, 0) and sys.platform == 'win32':
344+
lineterminator = '\n'
342345
quoting = csv.QUOTE_MINIMAL
343346

344347

@@ -361,6 +364,10 @@ def read(self, ifile):
361364
name, value = None, None
362365

363366
for line in ifile:
367+
# SPL-175233 -- input is buffered, needs to be decoded
368+
if sys.version_info >= (3, 0):
369+
line = line.decode()
370+
364371
if line == '\n':
365372
break
366373
item = line.split(':', 1)
@@ -658,6 +665,13 @@ class RecordWriterV1(RecordWriter):
658665

659666
def flush(self, finished=None, partial=None):
660667

668+
# SPL-175233
669+
def writeEOL():
670+
if sys.version_info >= (3, 0) and sys.platform == 'win32':
671+
write('\n')
672+
else:
673+
write('\r\n')
674+
661675
RecordWriter.flush(self, finished, partial) # validates arguments and the state of this instance
662676

663677
if self._record_count > 0 or (self._chunk_count == 0 and 'messages' in self._inspector):
@@ -678,9 +692,9 @@ def flush(self, finished=None, partial=None):
678692
write(message_level(level, level))
679693
write('=')
680694
write(text)
681-
write('\r\n')
695+
writeEOL()
682696

683-
write('\r\n')
697+
writeEOL()
684698

685699
elif messages is not None:
686700

splunklib/searchcommands/search_command.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -1054,7 +1054,13 @@ def iteritems(self):
10541054
SearchMetric = namedtuple('SearchMetric', ('elapsed_seconds', 'invocation_count', 'input_count', 'output_count'))
10551055

10561056

1057-
def dispatch(command_class, argv=sys.argv, input_file=sys.stdin, output_file=sys.stdout, module_name=None):
1057+
# SPL-175233, set default stdin to be buffered
1058+
if sys.version_info >= (3, 0) and sys.platform == 'win32':
1059+
stdinput = sys.stdin.buffer
1060+
else:
1061+
stdinput = sys.stdin
1062+
1063+
def dispatch(command_class, argv=sys.argv, input_file=stdinput, output_file=sys.stdout, module_name=None):
10581064
""" Instantiates and executes a search command class
10591065
10601066
This function implements a `conditional script stanza <https://docs.python.org/2/library/__main__.html>`_ based on the value of

0 commit comments

Comments
 (0)