Skip to content

Commit 2275683

Browse files
author
Frederick Ross
committed
Fixed stail.py in examples to use new ResultsReader interface.
1 parent ce1ba16 commit 2275683

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

examples/stail.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
"""Tails a realtime search using the export endpoint and prints results to
1818
stdout."""
1919

20-
from pprint import pprint
2120
import sys
21+
sys.path.insert(0, '../')
22+
23+
from pprint import pprint
2224

2325
from splunklib.client import connect
24-
import splunklib.results as results
26+
from splunklib.results import ResultsReader
2527

2628
import utils
2729

@@ -43,13 +45,9 @@ def main():
4345
latest_time="rt",
4446
search_mode="realtime")
4547

46-
reader = results.ResultsReader(result.body)
47-
while True:
48-
kind = reader.read()
49-
if kind == None: break
50-
if kind == results.RESULT:
51-
event = reader.value
52-
pprint(event)
48+
for result in ResultsReader(result.body):
49+
if result is not None:
50+
print pprint(result)
5351

5452
except KeyboardInterrupt:
5553
print "\nInterrupted."

0 commit comments

Comments
 (0)