Skip to content

Searchcommands: add full support for unicode #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion splunklib/searchcommands/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from collections import OrderedDict # must be python 2.7
except ImportError:
from ..ordereddict import OrderedDict
from splunklib.six.moves import cStringIO as StringIO
from splunklib.six.moves import StringIO
from itertools import chain
from splunklib.six.moves import map as imap
from json import JSONDecoder, JSONEncoder
Expand Down
3 changes: 1 addition & 2 deletions splunklib/searchcommands/search_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
except ImportError:
from ..ordereddict import OrderedDict
from copy import deepcopy
from splunklib.six.moves import cStringIO as StringIO
from splunklib.six.moves import StringIO
from itertools import chain, islice
from splunklib.six.moves import filter as ifilter, map as imap, zip as izip
from splunklib import six
Expand Down Expand Up @@ -850,7 +850,6 @@ def _execute(self, ifile, process):

@staticmethod
def _read_chunk(ifile):

# noinspection PyBroadException
try:
header = ifile.readline()
Expand Down
2 changes: 1 addition & 1 deletion splunklib/searchcommands/validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from json.encoder import encode_basestring_ascii as json_encode_string
from collections import namedtuple
from splunklib.six.moves import cStringIO as StringIO
from splunklib.six.moves import StringIO
from io import open
import csv
import os
Expand Down
7 changes: 4 additions & 3 deletions tests/searchcommands/test_search_command.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#!/usr/bin/env python
# coding=utf-8
#
# Copyright 2011-2015 Splunk, Inc.
#
Expand All @@ -22,7 +23,7 @@
from splunklib.searchcommands.search_command import SearchCommand
from splunklib.client import Service

from splunklib.six.moves import cStringIO as StringIO
from splunklib.six.moves import StringIO
from splunklib.six.moves import zip as izip
from json.encoder import encode_basestring as encode_string
from unittest import main, TestCase
Expand Down Expand Up @@ -388,7 +389,7 @@ def test_process_scpv2(self):
'"required_option_1=value_1",'
'"required_option_2=value_2"'
'],'
'"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",'
'"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",'
'"earliest_time": "0",'
'"session_key": "0JbG1fJEvXrL6iYZw9y7tmvd6nHjTKj7ggaE7a4Jv5R0UIbeYJ65kThn^3hiNeoqzMT_LOtLpVR3Y8TIJyr5bkHUElMijYZ8l14wU0L4n^Oa5QxepsZNUIIQCBm^",'
'"owner": "admin",'
Expand Down Expand Up @@ -492,7 +493,7 @@ def test_process_scpv2(self):
self.assertEqual(command_metadata.searchinfo.latest_time, 0.0)
self.assertEqual(command_metadata.searchinfo.owner, 'admin')
self.assertEqual(command_metadata.searchinfo.raw_args, command_metadata.searchinfo.args)
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')
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')
self.assertEqual(command_metadata.searchinfo.session_key, '0JbG1fJEvXrL6iYZw9y7tmvd6nHjTKj7ggaE7a4Jv5R0UIbeYJ65kThn^3hiNeoqzMT_LOtLpVR3Y8TIJyr5bkHUElMijYZ8l14wU0L4n^Oa5QxepsZNUIIQCBm^')
self.assertEqual(command_metadata.searchinfo.sid, '1433261372.158')
self.assertEqual(command_metadata.searchinfo.splunk_version, '20150522')
Expand Down