Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
fe22e6f
Fixed things found in session 1 of the grand Python review.
Nov 27, 2012
b3071c5
Refactored out the one use of Service.namespace, and removed the method.
Nov 29, 2012
a77701d
Fix strangely misplaced methods on Configurations and ConfigurationFile.
Nov 29, 2012
0545eac
Made Stanza.submit accept only dicts, not strings.
Nov 29, 2012
0026ebe
A number of small changes.
Nov 29, 2012
408ce17
Remove contains methods everywhere in client.py.
Nov 30, 2012
c8afd0e
Remove argument from Inputs.kinds, and workaround Python's strange be…
Nov 30, 2012
fa16dda
Fixed a vestigial call to Stanza.submit with a string instead of a dict.
Nov 30, 2012
2232abd
Unwrapped all HTTPErrors except those being turned into KeyErrors in …
Nov 30, 2012
df3d9c2
Removed three more instances of .contains(…) that had escaped the pre…
Nov 30, 2012
86918c4
Renamed _run_method to _run_action everywhere.
Nov 30, 2012
5833bdb
Simplify restrictToHost handling.
Nov 30, 2012
905eb59
Make all Input related calls that take both name and kind have name f…
Nov 30, 2012
7d73dbe
Remove JobNotReadyException.
Nov 30, 2012
9b3025b
Remove timeout logic from Job.events().
Nov 30, 2012
94a5c87
Fix behavior of is_done() -- it needed to refresh, since is_ready is …
Nov 30, 2012
9b6e2a2
Remove refresh calls and throws from grant and revoke on Role.
Nov 30, 2012
7ed6005
Resolve comments from Itay.
Nov 30, 2012
ce1ba16
Fixed test for revoking ungranted capabilities on Role.
Nov 30, 2012
2275683
Fixed stail.py in examples to use new ResultsReader interface.
Nov 30, 2012
d8e4c96
Fix submit.py in examples so it works across platforms. Add test for …
Nov 30, 2012
75ae214
Merge branch 'develop' into fross/review-fixes
Nov 30, 2012
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## 1.0

* The argument order of Inputs.create has been swapped to have name first. This is consistent with
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this actually a change from a released version? I thought we decided it was already like this.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it was kind before name in create on the beta release.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it seems :) my bad.

all other collections and all other operations on Inputs.
* All the .contains methods on collections have been removed. Use Python's `in` operator instead.
* Confs has been renamed to Configurations, and ConfFile to ConfigurationFile.
* Stanza.submit now takes a dictionary of key/value pairs specifying the stanza instead of a raw string.
* Namespace handling has changed subtly. Code that depends on namespace handling in detail may break.
* Added User.role_entities to return a list of the actual entity objects for the
Expand Down
8 changes: 5 additions & 3 deletions examples/analytics/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ def __init__(self, application_name, splunk_info, index = ANALYTICS_INDEX_NAME):
if ANALYTICS_SOURCETYPE not in self.splunk.confs['props']:
self.splunk.confs["props"].create(ANALYTICS_SOURCETYPE)
stanza = self.splunk.confs["props"][ANALYTICS_SOURCETYPE]
stanza.submit("LINE_BREAKER = (%s)" % EVENT_TERMINATOR)
stanza.submit("CHARSET = UTF-8")
stanza.submit("SHOULD_LINEMERGE = false")
stanza.submit({
"LINE_BREAKER": "(%s)" % EVENT_TERMINATOR,
"CHARSET": "UTF-8",
"SHOULD_LINEMERGE": "false"
})
assert(ANALYTICS_SOURCETYPE in self.splunk.confs['props'])

@staticmethod
Expand Down
4 changes: 3 additions & 1 deletion examples/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def create(self, opts):
kvpair = argv[2].split("=")
if len(kvpair) != 2:
error("Creating a k/v pair requires key and value", 2)
else:
key, value = kvpair

if not cpres and not spres:
error("Conf name and stanza name is required for create", 2)
Expand All @@ -58,7 +60,7 @@ def create(self, opts):

# create key/value pair under existing stanza
stanza = conf[stan]
stanza.submit(argv[2])
stanza.submit({key: value})


def delete(self, opts):
Expand Down
6 changes: 3 additions & 3 deletions examples/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def create(self, argv):

name = argv[0]

if self.service.indexes.contains(name):
if name in self.service.indexes:
print "Index '%s' already exists" % name
return

Expand Down Expand Up @@ -131,7 +131,7 @@ def foreach(self, argv, func):
if len(opts.args) == 0:
error("Command requires an index name", 2)
for name in opts.args:
if not self.service.indexes.contains(name):
if name not in self.service.indexes:
error("Index '%s' does not exist" % name, 2)
index = self.service.indexes[name]
func(index)
Expand All @@ -143,7 +143,7 @@ def update(self, argv):
error("Command requires an index name", 2)
name = argv[0]

if not self.service.indexes.contains(name):
if name not in self.service.indexes:
error("Index '%s' does not exist" % name, 2)
index = self.service.indexes[name]

Expand Down
16 changes: 7 additions & 9 deletions examples/stail.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
"""Tails a realtime search using the export endpoint and prints results to
stdout."""

from pprint import pprint
import sys
sys.path.insert(0, '../')

from pprint import pprint

from splunklib.client import connect
import splunklib.results as results
from splunklib.results import ResultsReader

import utils

Expand All @@ -43,13 +45,9 @@ def main():
latest_time="rt",
search_mode="realtime")

reader = results.ResultsReader(result.body)
while True:
kind = reader.read()
if kind == None: break
if kind == results.RESULT:
event = reader.value
pprint(event)
for result in ResultsReader(result.body):
if result is not None:
print pprint(result)

except KeyboardInterrupt:
print "\nInterrupted."
Expand Down
4 changes: 2 additions & 2 deletions examples/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def main(argv):
kwargs_splunk = dslice(opts.kwargs, FLAGS_SPLUNK)
service = client.connect(**kwargs_splunk)

if not service.indexes.contains(index):
if index not in service.indexes:
error("Index '%s' does not exist." % index, 2)

kwargs_submit = dslice(opts.kwargs,
Expand All @@ -69,7 +69,7 @@ def main(argv):
cn = service.indexes[index].attach(**kwargs_submit)
try:
while True:
line = sys.stdin.readline()
line = sys.stdin.readline().rstrip('\r\n')
if len(line) == 0: break
cn.write(line)
finally:
Expand Down
4 changes: 2 additions & 2 deletions examples/twitted/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,15 +245,15 @@ def main():
service = client.connect(**kwargs)

# Create the index if it doesn't exist
if not service.indexes.contains("twitter"):
if 'twitter' not in service.indexes:
if verbose > 0: print "Creating index 'twitter' .."
service.indexes.create("twitter")

# Create the TCP input if it doesn't exist
input_host = kwargs.get("inputhost", DEFAULT_SPLUNK_HOST)
input_port = int(kwargs.get("inputport", DEFAULT_SPLUNK_PORT))
input_name = str(input_port)
if not service.inputs.contains(input_name):
if input_name not in service.inputs:
if verbose > 0: print "Creating input '%s'" % input_name
service.inputs.create(
"tcp", input_port, index="twitter", sourcetype="twitter")
Expand Down
2 changes: 1 addition & 1 deletion examples/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def main(argv):
service = client.connect(**kwargs_splunk)

name = opts.kwargs['index']
if not service.indexes.contains(name):
if name not in service.indexes:
error("Index '%s' does not exist." % name, 2)
index = service.indexes[name]

Expand Down
Loading