-
Notifications
You must be signed in to change notification settings - Fork 371
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #341 from splunk/csc-multibyte
Custom search command support for multibyte characters in Python 3
- Loading branch information
Showing
11 changed files
with
108 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import io | ||
import gzip | ||
import sys | ||
|
||
from os import path | ||
|
||
from splunklib import six | ||
from splunklib.searchcommands import StreamingCommand, Configuration | ||
|
||
|
||
def build_test_command(): | ||
@Configuration() | ||
class TestSearchCommand(StreamingCommand): | ||
def stream(self, records): | ||
for record in records: | ||
yield record | ||
|
||
return TestSearchCommand() | ||
|
||
|
||
def get_input_file(name): | ||
return path.join( | ||
path.dirname(path.dirname(__file__)), 'data', 'custom_search', name + '.gz') | ||
|
||
|
||
def test_multibyte_chunked(): | ||
data = gzip.open(get_input_file("multibyte_input")) | ||
if not six.PY2: | ||
data = io.TextIOWrapper(data) | ||
cmd = build_test_command() | ||
cmd._process_protocol_v2(sys.argv, data, sys.stdout) | ||
|
||
|
||
def test_v1_searchcommand(): | ||
data = gzip.open(get_input_file("v1_search_input")) | ||
if not six.PY2: | ||
data = io.TextIOWrapper(data) | ||
cmd = build_test_command() | ||
cmd._process_protocol_v1(["test_script.py", "__EXECUTE__"], data, sys.stdout) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters