Skip to content

Commit

Permalink
Merge pull request #364 from splunk/release/1.6.15
Browse files Browse the repository at this point in the history
Release v1.6.15
  • Loading branch information
fantavlik authored Jan 29, 2021
2 parents 465522d + ddebf73 commit b36d6eb
Show file tree
Hide file tree
Showing 21 changed files with 307 additions and 133 deletions.
14 changes: 6 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,12 @@ before_install:
- echo password=changed! >> $HOME/.splunkrc
# Set SPLUNK_HOME
- export SPLUNK_HOME="/opt/splunk"
# Pull docker image
- docker pull splunk/splunk-sdk-travis-ci:$SPLUNK_VERSION
# Add DOCKER to iptables, 1/10 times this is needed, force 0 exit status
- sudo iptables -N DOCKER || true
# Start Docker container
- docker run -p 127.0.0.1:8089:8089 -d splunk/splunk-sdk-travis-ci:$SPLUNK_VERSION
# curl Splunk until it returns valid data indicating it has been setup, try 20 times maximum
- for i in `seq 0 20`; do if curl --fail -k https://localhost:8089/services/server/info &> /dev/null; then break; fi; echo $i; sleep 1; done
# Start docker-compose in detached mode
- docker-compose up -d
# Health Check (3 minutes)
- for i in `seq 0 180`; do if docker exec -it splunk /sbin/checkstate.sh &> /dev/null; then break; fi; echo $i; sleep 1; done
# The upload test needs to refer to a file that Splunk has in the docker
# container
- export INPUT_EXAMPLE_UPLOAD=$SPLUNK_HOME/var/log/splunk/splunkd_ui_access.log
Expand All @@ -32,8 +30,8 @@ before_install:
language: python

env:
- SPLUNK_VERSION=7.3-sdk
- SPLUNK_VERSION=8.0-sdk
- SPLUNK_VERSION=7.3
- SPLUNK_VERSION=8.0

python:
- "2.7"
Expand Down
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# Splunk Enterprise SDK for Python Changelog

## Version 1.6.15

### Bug fixes
[#301](https://github.com/splunk/splunk-sdk-python/pull/301) Fix chunk synchronization
[#327](https://github.com/splunk/splunk-sdk-python/pull/327) Rename and cleanup follow-up for chunk synchronization
[#352](https://github.com/splunk/splunk-sdk-python/pull/352) Allow supplying of a key-value body when calling Context.post()

### Minor changes
[#350](https://github.com/splunk/splunk-sdk-python/pull/350) Initial end-to-end tests for streaming, reporting, generating custom search commands
[#348](https://github.com/splunk/splunk-sdk-python/pull/348) Update copyright years to 2020
[#346](https://github.com/splunk/splunk-sdk-python/pull/346) Readme updates to urls, terminology, and formatting
[#317](https://github.com/splunk/splunk-sdk-python/pull/317) Fix deprecation warnings

## Version 1.6.14

### Bug fix
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# The Splunk Enterprise Software Development Kit for Python

#### Version 1.6.14
#### Version 1.6.15

The Splunk Enterprise Software Development Kit (SDK) for Python contains library code and examples designed to enable developers to build applications using the Splunk platform.

Expand All @@ -13,7 +13,7 @@ The Splunk platform is popular with system administrators for aggregation and mo

The Splunk developer platform enables developers to take advantage of the same technology used by the Splunk platform to build exciting new applications.

For more information, see [Splunk Enterprise SDK for Python](https://dev.splunk.com/enterprise/docs/devtools/python/sdk-python/) on the Splunk Developer Portal.
## Getting started with the Splunk SDK for Python


## Get started with the Splunk Enterprise SDK for Python
Expand All @@ -37,7 +37,6 @@ Here's what you need to get going with the Splunk Enterprise SDK for Python.

Get the Splunk Enterprise SDK for Python from [PyPI](https://pypi.org/project/splunk-sdk/). If you want to contribute to the SDK, clone the repository from [GitHub](https://github.com/splunk/splunk-sdk-python).


### Install the SDK

Use the following commands to install the Splunk Enterprise SDK for Python libraries in different ways. However, it's not necessary to install the libraries to run the examples and unit tests from the SDK.
Expand All @@ -58,8 +57,17 @@ Install the sources you cloned from GitHub:

[sudo] python setup.py install

## Testing Quickstart

You'll need `docker` and `docker-compose` to get up and running using this method.

### Run the examples and unit tests
```
make up SPLUNK_VERSION=8.0
make wait_up
make splunkrc_default
make test
make down
```

To run the examples and unit tests, you must put the root of the SDK on your PYTHONPATH. For example, if you downloaded the SDK to your home folder and are running OS X or Linux, add the following line to your **.bash_profile** file:

Expand Down
20 changes: 20 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
version: '3.6'

services:
splunk:
image: "splunk/splunk:${SPLUNK_VERSION}"
container_name: splunk
environment:
- SPLUNK_START_ARGS=--accept-license
- SPLUNK_HEC_TOKEN=11111111-1111-1111-1111-1111111111113
- SPLUNK_PASSWORD=changed!
- SPLUNK_APPS_URL=https://github.com/splunk/sdk-app-collection/releases/download/v1.0.0/sdk-app-collection.tgz
ports:
- 8000:8000
- 8088:8088
- 8089:8089
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:8000']
interval: 5s
timeout: 5s
retries: 20
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@

# General information about the project.
project = u'Splunk SDK for Python'
copyright = u'2014, Splunk Inc'
copyright = u'2020, Splunk Inc'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -95,7 +95,7 @@
# a list of builtin themes.

# agogo, default, epub, haiku, nature, pyramid, scrolls, sphinxdoc, traditional
html_theme = 'default'
html_theme = 'default'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
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.14',
version='1.6.15',
author='Splunk, Inc.',
author_email='[email protected]',
url='http://github.com/splunk/splunk-sdk-python',
Expand Down
4 changes: 2 additions & 2 deletions scripts/build-splunkrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
'host': 'localhost',
'port': '8089',
'username': 'admin',
'password': 'changeme',
'password': 'changed!',
'scheme': 'https',
'version': '6.3'
'version': '8.0'
}

DEFAULT_SPLUNKRC_PATH = os.path.join(str(Path.home()), '.splunkrc')
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, 14)
__version_info__ = (1, 6, 15)
__version__ = ".".join(map(str, __version_info__))
11 changes: 9 additions & 2 deletions splunklib/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,12 @@ def post(self, path_segment, owner=None, app=None, sharing=None, headers=None, *
:type headers: ``list`` of 2-tuples.
:param query: All other keyword arguments, which are used as query
parameters.
:type query: ``string``
:param body: Parameters to be used in the post body. If specified,
any parameters in the query will be applied to the URL instead of
the body. If a dict is supplied, the key-value pairs will be form
encoded. If a string is supplied, the body will be passed through
in the request unchanged.
:type body: ``dict`` or ``str``
:return: The response from the server.
:rtype: ``dict`` with keys ``body``, ``headers``, ``reason``,
and ``status``
Expand Down Expand Up @@ -1223,6 +1228,8 @@ def post(self, url, headers=None, **kwargs):
headers.append(("Content-Type", "application/x-www-form-urlencoded"))

body = kwargs.pop('body')
if isinstance(body, dict):
body = _encode(**body).encode('utf-8')
if len(kwargs) > 0:
url = url + UrlEncoded('?' + _encode(**kwargs), skip_encode=True)
else:
Expand Down Expand Up @@ -1378,7 +1385,7 @@ def request(url, message, **kwargs):
head = {
"Content-Length": str(len(body)),
"Host": host,
"User-Agent": "splunk-sdk-python/1.6.14",
"User-Agent": "splunk-sdk-python/1.6.15",
"Accept": "*/*",
"Connection": "Close",
} # defaults
Expand Down
2 changes: 1 addition & 1 deletion splunklib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1872,7 +1872,7 @@ def delete(self, username, realm=None):
name = UrlEncoded(realm, encode_slash=True) + ":" + UrlEncoded(username, encode_slash=True)

# Append the : expected at the end of the name
if name[-1] is not ":":
if name[-1] != ":":
name = name + ":"
return Collection.delete(self, name)

Expand Down
24 changes: 13 additions & 11 deletions splunklib/searchcommands/generating_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,19 +204,21 @@ def _execute(self, ifile, process):
"""
if self._protocol_version == 2:
result = self._read_chunk(self._as_binary_stream(ifile))
self._execute_v2(ifile, self.generate())
else:
assert self._protocol_version == 1
self._record_writer.write_records(self.generate())
self.finish()

if not result:
def _execute_chunk_v2(self, process, chunk):
count = 0
for row in process:
self._record_writer.write_record(row)
count += 1
if count == self._record_writer._maxresultrows:
self._finished = False
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()
self._finished = True

# endregion

Expand Down
Loading

0 comments on commit b36d6eb

Please sign in to comment.