Skip to content

Commit dd9d266

Browse files
author
Shakeel Mohamed
committed
Comment edits; modinput examples are no authored by Splunk; Script.run simplified.
1 parent c732830 commit dd9d266

File tree

7 files changed

+17
-12
lines changed

7 files changed

+17
-12
lines changed

examples/github_forks/default/app.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ is_visible = 1
66
label = Github Repository Forks
77

88
[launcher]
9-
author=Shakeel Mohamed
9+
author=Splunk
1010
description=Streams events giving the number of forks of a GitHub repository
1111
version = 1.0

examples/github_forks/github_forks.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_scheme(self):
6969
repo_name_argument.required_on_create = True
7070
scheme.add_argument(repo_name_argument)
7171

72-
return scheme # Return the scheme
72+
return scheme
7373

7474
def validate_input(self, validation_definition):
7575
"""In this example we are using external validation to verify that the Github
@@ -141,4 +141,4 @@ def stream_events(self, inputs, ew):
141141
ew.write_event(event)
142142

143143
if __name__ == "__main__":
144-
sys.exit(MyScript().run(sys.argv[1:]))
144+
sys.exit(MyScript().run(sys.argv))

examples/random_numbers/default/app.conf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ is_visible = 1
66
label = Random Numbers
77

88
[launcher]
9-
author=Shakeel Mohamed
9+
author=Splunk
1010
description=Streams events containing a random number
1111
version = 1.0

examples/random_numbers/random_numbers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def get_scheme(self):
6969
max_argument.required_on_create = True
7070
scheme.add_argument(max_argument)
7171

72-
return scheme # Return the scheme
72+
return scheme
7373

7474
def validate_input(self, validation_definition):
7575
"""In this example we are using external validation to verify that min is
@@ -120,4 +120,4 @@ def stream_events(self, inputs, ew):
120120
ew.write_event(event)
121121

122122
if __name__ == "__main__":
123-
sys.exit(MyScript().run(sys.argv[1:]))
123+
sys.exit(MyScript().run(sys.argv))

setup.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def setup_examples():
8383
modinput_dir = os.path.join(splunklib_dir, "modularinput")
8484

8585
for app in app_names:
86-
spl = tarfile.open(os.path.join("build", app+".spl"), "w")
86+
spl = tarfile.open(os.path.join("build", app + ".spl"), "w")
8787

8888
spl.add(
89-
os.path.join("examples", app, app+".py"),
90-
arcname=os.path.join(app, "bin", app+".py")
89+
os.path.join("examples", app, app + ".py"),
90+
arcname=os.path.join(app, "bin", app + ".py")
9191
)
9292

9393
spl.add(

splunklib/modularinput/__init__.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
"""The following imports allow these classes to be imported via
2+
the splunklib.modularinput package like so:
3+
4+
from splunklib.modularinput import *
5+
"""
16
from argument import Argument
27
from event import Event
38
from event_writer import EventWriter

splunklib/modularinput/script.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@ def run_script(self, args, event_writer, input_stream):
5858
"""
5959

6060
try:
61-
if len(args) == 0:
61+
if len(args) == 1:
6262
# This script is running as an input. Input definitions will be passed on stdin
6363
# as XML, and the script will write events on stdout and log entries on stderr.
6464
input_definition = InputDefinition.parse(input_stream)
6565
self.stream_events(input_definition, event_writer)
6666
event_writer.close()
6767
return 0
6868

69-
elif str(args[0]).lower() == "--scheme":
69+
elif str(args[1]).lower() == "--scheme":
7070
# Splunk has requested XML specifying the scheme for this modular input.
7171
# Return it and exit.
7272
scheme = self.get_scheme()
@@ -77,7 +77,7 @@ def run_script(self, args, event_writer, input_stream):
7777
event_writer.write_xml_document(scheme.to_xml())
7878
return 0
7979

80-
elif args[0].lower() == "--validate-arguments":
80+
elif args[1].lower() == "--validate-arguments":
8181
validation_definition = ValidationDefinition.parse(input_stream)
8282
try:
8383
self.validate_input(validation_definition)

0 commit comments

Comments
 (0)