Skip to content

Commit

Permalink
Release 1.6.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ljiang1 committed Sep 16, 2019
2 parents e0c515b + 27dd408 commit 07278fa
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Splunk SDK for Python Changelog

## Version 1.6.8

### Bug Fix

* Fix custom search command on python 3 on windows

## Version 1.6.7

### Changes
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The Splunk Software Development Kit for Python

#### Version 1.6.6
#### Version 1.6.8

The Splunk Software Development Kit (SDK) for Python contains library code and
examples designed to enable developers to build applications using Splunk.
Expand Down
2 changes: 1 addition & 1 deletion examples/searchcommands_app/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def run(self):
setup(
description='Custom Search Command examples',
name=os.path.basename(project_dir),
version='1.6.7',
version='1.6.8',
author='Splunk, Inc.',
author_email='devinfo@splunk.com',
url='http://github.com/splunk/splunk-sdk-python',
Expand Down
2 changes: 1 addition & 1 deletion splunklib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@

from __future__ import absolute_import
from splunklib.six.moves import map
__version_info__ = (1, 6, 7)
__version_info__ = (1, 6, 8)
__version__ = ".".join(map(str, __version_info__))
20 changes: 17 additions & 3 deletions splunklib/searchcommands/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@

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

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


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

for line in ifile:
# SPL-175233 -- input is buffered, needs to be decoded
if sys.version_info >= (3, 0):
line = line.decode()

if line == '\n':
break
item = line.split(':', 1)
Expand Down Expand Up @@ -658,6 +665,13 @@ class RecordWriterV1(RecordWriter):

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

# SPL-175233
def writeEOL():
if sys.version_info >= (3, 0) and sys.platform == 'win32':
write('\n')
else:
write('\r\n')

RecordWriter.flush(self, finished, partial) # validates arguments and the state of this instance

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

write('\r\n')
writeEOL()

elif messages is not None:

Expand Down
8 changes: 7 additions & 1 deletion splunklib/searchcommands/search_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,13 @@ def iteritems(self):
SearchMetric = namedtuple('SearchMetric', ('elapsed_seconds', 'invocation_count', 'input_count', 'output_count'))


def dispatch(command_class, argv=sys.argv, input_file=sys.stdin, output_file=sys.stdout, module_name=None):
# SPL-175233, set default stdin to be buffered
if sys.version_info >= (3, 0) and sys.platform == 'win32':
stdinput = sys.stdin.buffer
else:
stdinput = sys.stdin

def dispatch(command_class, argv=sys.argv, input_file=stdinput, output_file=sys.stdout, module_name=None):
""" Instantiates and executes a search command class
This function implements a `conditional script stanza <https://docs.python.org/2/library/__main__.html>`_ based on the value of
Expand Down

0 comments on commit 07278fa

Please sign in to comment.