Skip to content

Commit c6b7457

Browse files
Merge pull request #222 from splunk/bugfix/search-commands-unicode
Searchcommands: add full support for unicode
2 parents f989819 + 6894ef5 commit c6b7457

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

splunklib/searchcommands/internals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
from collections import OrderedDict # must be python 2.7
2323
except ImportError:
2424
from ..ordereddict import OrderedDict
25-
from splunklib.six.moves import cStringIO as StringIO
25+
from splunklib.six.moves import StringIO
2626
from itertools import chain
2727
from splunklib.six.moves import map as imap
2828
from json import JSONDecoder, JSONEncoder

splunklib/searchcommands/search_command.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
except ImportError:
2828
from ..ordereddict import OrderedDict
2929
from copy import deepcopy
30-
from splunklib.six.moves import cStringIO as StringIO
30+
from splunklib.six.moves import StringIO
3131
from itertools import chain, islice
3232
from splunklib.six.moves import filter as ifilter, map as imap, zip as izip
3333
from splunklib import six
@@ -850,7 +850,6 @@ def _execute(self, ifile, process):
850850

851851
@staticmethod
852852
def _read_chunk(ifile):
853-
854853
# noinspection PyBroadException
855854
try:
856855
header = ifile.readline()

splunklib/searchcommands/validators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
from json.encoder import encode_basestring_ascii as json_encode_string
2020
from collections import namedtuple
21-
from splunklib.six.moves import cStringIO as StringIO
21+
from splunklib.six.moves import StringIO
2222
from io import open
2323
import csv
2424
import os

tests/searchcommands/test_search_command.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
2+
# coding=utf-8
23
#
34
# Copyright 2011-2015 Splunk, Inc.
45
#
@@ -22,7 +23,7 @@
2223
from splunklib.searchcommands.search_command import SearchCommand
2324
from splunklib.client import Service
2425

25-
from splunklib.six.moves import cStringIO as StringIO
26+
from splunklib.six.moves import StringIO
2627
from splunklib.six.moves import zip as izip
2728
from json.encoder import encode_basestring as encode_string
2829
from unittest import main, TestCase
@@ -388,7 +389,7 @@ def test_process_scpv2(self):
388389
'"required_option_1=value_1",'
389390
'"required_option_2=value_2"'
390391
'],'
391-
'"search": "%7C%20inputlookup%20tweets%20%7C%20countmatches%20fieldname%3Dword_count%20pattern%3D%22%5Cw%2B%22%20text%20record%3Dt%20%7C%20export%20add_timestamp%3Df%20add_offset%3Dt%20format%3Dcsv%20segmentation%3Draw",'
392+
'"search": "%7C%20inputlookup%20tweets%20%7C%20countmatches%20fieldname%3Dword_count%20pattern%3D%22%5Cw%2B%22%20text%20record%3Dt%20%7C%20export%20add_timestamp%3Df%20add_offset%3Dt%20format%3Dcsv%20segmentation%3Draw",'
392393
'"earliest_time": "0",'
393394
'"session_key": "0JbG1fJEvXrL6iYZw9y7tmvd6nHjTKj7ggaE7a4Jv5R0UIbeYJ65kThn^3hiNeoqzMT_LOtLpVR3Y8TIJyr5bkHUElMijYZ8l14wU0L4n^Oa5QxepsZNUIIQCBm^",'
394395
'"owner": "admin",'
@@ -492,7 +493,7 @@ def test_process_scpv2(self):
492493
self.assertEqual(command_metadata.searchinfo.latest_time, 0.0)
493494
self.assertEqual(command_metadata.searchinfo.owner, 'admin')
494495
self.assertEqual(command_metadata.searchinfo.raw_args, command_metadata.searchinfo.args)
495-
self.assertEqual(command_metadata.searchinfo.search, '| inputlookup tweets | countmatches fieldname=word_count pattern="\\w+" text record=t | export add_timestamp=f add_offset=t format=csv segmentation=raw')
496+
self.assertEqual(command_metadata.searchinfo.search, '| inputlookup tweets | countmatches fieldname=word_count pattern="\\w+" text record=t | export add_timestamp=f add_offset=t format=csv segmentation=raw')
496497
self.assertEqual(command_metadata.searchinfo.session_key, '0JbG1fJEvXrL6iYZw9y7tmvd6nHjTKj7ggaE7a4Jv5R0UIbeYJ65kThn^3hiNeoqzMT_LOtLpVR3Y8TIJyr5bkHUElMijYZ8l14wU0L4n^Oa5QxepsZNUIIQCBm^')
497498
self.assertEqual(command_metadata.searchinfo.sid, '1433261372.158')
498499
self.assertEqual(command_metadata.searchinfo.splunk_version, '20150522')

0 commit comments

Comments
 (0)