Skip to content
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
12 changes: 12 additions & 0 deletions splunklib/searchcommands/generating_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ def _execute(self, ifile, process):
:return: `None`.

"""
if self._protocol_version == 2:
result = self._read_chunk(ifile)

if not result:
return

metadata, body = result
action = getattr(metadata, 'action', None)

if action != 'execute':
raise RuntimeError('Expected execute action, not {}'.format(action))

self._record_writer.write_records(self.generate())
self.finish()

Expand Down
10 changes: 8 additions & 2 deletions splunklib/searchcommands/search_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
# Absolute imports

from collections import namedtuple

try:
from collections import OrderedDict # must be python 2.7
except ImportError:
Expand All @@ -27,6 +28,7 @@
from cStringIO import StringIO
from itertools import chain, ifilter, imap, islice, izip
from logging import _levelNames, getLevelName, getLogger

try:
from shutil import make_archive
except ImportError:
Expand All @@ -47,7 +49,7 @@

# Relative imports

from . internals import (
from .internals import (
CommandLineParser,
CsvDialect,
InputHeader,
Expand All @@ -63,6 +65,7 @@
from . import Boolean, Option, environment
from ..client import Service


# ----------------------------------------------------------------------------------------------------------------------

# P1 [ ] TODO: Log these issues against ChunkedExternProcessor
Expand All @@ -89,6 +92,7 @@ class SearchCommand(object):
""" Represents a custom search command.

"""

def __init__(self):

# Variables that may be used, but not altered by derived classes
Expand Down Expand Up @@ -873,8 +877,10 @@ def _read_chunk(ifile):
# if body_length <= 0:
# return metadata, ''

body = ""
try:
body = ifile.read(body_length)
if body_length > 0:
body = ifile.read(body_length)
except Exception as error:
raise RuntimeError('Failed to read body of length {}: {}'.format(body_length, error))

Expand Down
Binary file not shown.
Loading