diff --git a/custom_search_commands/python/customsearchcommands_app/bin/app.py b/custom_search_commands/python/customsearchcommands_app/bin/app.py index dea2478..06a8f39 100644 --- a/custom_search_commands/python/customsearchcommands_app/bin/app.py +++ b/custom_search_commands/python/customsearchcommands_app/bin/app.py @@ -30,15 +30,7 @@ def initialize(): from os import path from sys import modules, path as python_path - import platform - module_dir = path.dirname(path.realpath(__file__)) - system = platform.system() - - for packages in path.join(module_dir, 'packages'), path.join(path.join(module_dir, 'packages', system)): - if not path.isdir(packages): - break - python_path.insert(0, path.join(packages)) configuration_file = path.join(module_dir, '_pydebug_conf.py') diff --git a/custom_search_commands/python/customsearchcommands_app/bin/countmatches.py b/custom_search_commands/python/customsearchcommands_app/bin/countmatches.py index f6ce172..09aaebc 100644 --- a/custom_search_commands/python/customsearchcommands_app/bin/countmatches.py +++ b/custom_search_commands/python/customsearchcommands_app/bin/countmatches.py @@ -16,11 +16,8 @@ # under the License. -import os import sys -splunkhome = os.environ['SPLUNK_HOME'] -sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'customsearchcommands_app', 'lib')) from splunklib.searchcommands import dispatch, StreamingCommand, Configuration, Option, validators try: diff --git a/custom_search_commands/python/customsearchcommands_app/bin/filter.py b/custom_search_commands/python/customsearchcommands_app/bin/filter.py index ccbfb86..e6faee8 100644 --- a/custom_search_commands/python/customsearchcommands_app/bin/filter.py +++ b/custom_search_commands/python/customsearchcommands_app/bin/filter.py @@ -16,11 +16,8 @@ # under the License. -import os import sys -splunkhome = os.environ['SPLUNK_HOME'] -sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'customsearchcommands_app', 'lib')) from splunklib.searchcommands import dispatch, EventingCommand, Configuration, Option diff --git a/custom_search_commands/python/customsearchcommands_app/bin/generatehello.py b/custom_search_commands/python/customsearchcommands_app/bin/generatehello.py index 7f6e1cd..e841456 100644 --- a/custom_search_commands/python/customsearchcommands_app/bin/generatehello.py +++ b/custom_search_commands/python/customsearchcommands_app/bin/generatehello.py @@ -16,12 +16,9 @@ # under the License. -import os import sys import time -splunkhome = os.environ['SPLUNK_HOME'] -sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'customsearchcommands_app', 'lib')) from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration, Option, validators diff --git a/custom_search_commands/python/customsearchcommands_app/bin/generatetext.py b/custom_search_commands/python/customsearchcommands_app/bin/generatetext.py index a9de6ee..e861247 100644 --- a/custom_search_commands/python/customsearchcommands_app/bin/generatetext.py +++ b/custom_search_commands/python/customsearchcommands_app/bin/generatetext.py @@ -15,12 +15,9 @@ # License for the specific language governing permissions and limitations # under the License. -import os import sys import time -splunkhome = os.environ['SPLUNK_HOME'] -sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'customsearchcommands_app', 'lib')) from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration, Option, validators diff --git a/custom_search_commands/python/customsearchcommands_app/bin/simulate.py b/custom_search_commands/python/customsearchcommands_app/bin/simulate.py index 63a995d..a167e82 100644 --- a/custom_search_commands/python/customsearchcommands_app/bin/simulate.py +++ b/custom_search_commands/python/customsearchcommands_app/bin/simulate.py @@ -17,13 +17,10 @@ import csv -import os import random import sys import time -splunkhome = os.environ['SPLUNK_HOME'] -sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'customsearchcommands_app', 'lib')) from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration, Option, validators diff --git a/custom_search_commands/python/customsearchcommands_app/bin/sum.py b/custom_search_commands/python/customsearchcommands_app/bin/sum.py index 598b31e..56fdc46 100644 --- a/custom_search_commands/python/customsearchcommands_app/bin/sum.py +++ b/custom_search_commands/python/customsearchcommands_app/bin/sum.py @@ -15,11 +15,8 @@ # License for the specific language governing permissions and limitations # under the License. -import os import sys -splunkhome = os.environ['SPLUNK_HOME'] -sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'customsearchcommands_app', 'lib')) from splunklib.searchcommands import dispatch, ReportingCommand, Configuration, Option, validators diff --git a/custom_search_commands/python/eventingsearchcommands_app/bin/eventingcsc.py b/custom_search_commands/python/eventingsearchcommands_app/bin/eventingcsc.py index 65214d9..1b277ad 100644 --- a/custom_search_commands/python/eventingsearchcommands_app/bin/eventingcsc.py +++ b/custom_search_commands/python/eventingsearchcommands_app/bin/eventingcsc.py @@ -15,10 +15,9 @@ # License for the specific language governing permissions and limitations # under the License. -import os, sys +import sys -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib")) -from splunklib.searchcommands import dispatch, EventingCommand, Configuration, Option, validators +from splunklib.searchcommands import dispatch, EventingCommand, Configuration, Option @Configuration() diff --git a/custom_search_commands/python/generatingsearchcommands_app/bin/generatingcsc.py b/custom_search_commands/python/generatingsearchcommands_app/bin/generatingcsc.py index e51df92..e9e394e 100644 --- a/custom_search_commands/python/generatingsearchcommands_app/bin/generatingcsc.py +++ b/custom_search_commands/python/generatingsearchcommands_app/bin/generatingcsc.py @@ -15,10 +15,9 @@ # License for the specific language governing permissions and limitations # under the License. -import os, sys +import sys import time -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib")) from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration, Option, validators diff --git a/custom_search_commands/python/reportingsearchcommands_app/bin/reportingcsc.py b/custom_search_commands/python/reportingsearchcommands_app/bin/reportingcsc.py index 491aef8..7d1afa8 100644 --- a/custom_search_commands/python/reportingsearchcommands_app/bin/reportingcsc.py +++ b/custom_search_commands/python/reportingsearchcommands_app/bin/reportingcsc.py @@ -15,9 +15,8 @@ # License for the specific language governing permissions and limitations # under the License. -import os, sys +import sys -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib")) from splunklib.searchcommands import dispatch, ReportingCommand, Configuration, Option, validators diff --git a/custom_search_commands/python/streamingsearchcommands_app/bin/streamingcsc.py b/custom_search_commands/python/streamingsearchcommands_app/bin/streamingcsc.py index f51881f..9425f17 100644 --- a/custom_search_commands/python/streamingsearchcommands_app/bin/streamingcsc.py +++ b/custom_search_commands/python/streamingsearchcommands_app/bin/streamingcsc.py @@ -15,10 +15,9 @@ # License for the specific language governing permissions and limitations # under the License. -import os, sys +import sys -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib")) -from splunklib.searchcommands import dispatch, StreamingCommand, Configuration, Option, validators +from splunklib.searchcommands import dispatch, StreamingCommand, Configuration @Configuration() diff --git a/docker-compose.yml b/docker-compose.yml index 870c8eb..5c6e343 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -14,50 +14,50 @@ services: volumes: # Weather App - ./setup_pages/weather_app_example:/opt/splunk/etc/apps/weather_app_example - - ./lib:/opt/splunk/etc/apps/weather_app_example/vendor + - ./lib/splunklib:/opt/splunk/etc/apps/weather_app_example/bin/splunklib # Dependency checking app example - ./setup_pages/dependency_checking_app_example:/opt/splunk/etc/apps/dependency_checking_app_example - - ./lib:/opt/splunk/etc/apps/dependency_checking_app_example/vendor + - ./lib/splunklib:/opt/splunk/etc/apps/dependency_checking_app_example/bin/splunklib # Setup page simple - ./setup_pages/setup_page_simple:/opt/splunk/etc/apps/setup_page_simple # Custom search commands app - ./custom_search_commands/python/customsearchcommands_app:/opt/splunk/etc/apps/customsearchcommands_app - - ./lib/splunklib:/opt/splunk/etc/apps/customsearchcommands_app/lib/splunklib + - ./lib/splunklib:/opt/splunk/etc/apps/customsearchcommands_app/bin/splunklib # Eventing commands app - ./custom_search_commands/python/eventingsearchcommands_app:/opt/splunk/etc/apps/eventingsearchcommands_app - - ./lib/splunklib:/opt/splunk/etc/apps/eventingsearchcommands_app/lib/splunklib + - ./lib/splunklib:/opt/splunk/etc/apps/eventingsearchcommands_app/bin/splunklib # Generating commands app - ./custom_search_commands/python/generatingsearchcommands_app:/opt/splunk/etc/apps/generatingsearchcommands_app - - ./lib/splunklib:/opt/splunk/etc/apps/generatingsearchcommands_app/lib/splunklib + - ./lib/splunklib:/opt/splunk/etc/apps/generatingsearchcommands_app/bin/splunklib # Reporting commands app - ./custom_search_commands/python/reportingsearchcommands_app:/opt/splunk/etc/apps/reportingsearchcommands_app - - ./lib/splunklib:/opt/splunk/etc/apps/reportingsearchcommands_app/lib/splunklib + - ./lib/splunklib:/opt/splunk/etc/apps/reportingsearchcommands_app/bin/splunklib # Streaming commands app - ./custom_search_commands/python/streamingsearchcommands_app:/opt/splunk/etc/apps/streamingsearchcommands_app - - ./lib/splunklib:/opt/splunk/etc/apps/streamingsearchcommands_app/lib/splunklib + - ./lib/splunklib:/opt/splunk/etc/apps/streamingsearchcommands_app/bin/splunklib # GitHub commits - ./modularinputs/python/github_commits:/opt/splunk/etc/apps/github_commits - - ./lib/splunklib:/opt/splunk/etc/apps/github_commits/lib/splunklib + - ./lib/splunklib:/opt/splunk/etc/apps/github_commits/bin/splunklib # GitHub forks - ./modularinputs/python/github_forks:/opt/splunk/etc/apps/github_forks - - ./lib/splunklib:/opt/splunk/etc/apps/github_forks/lib/splunklib + - ./lib/splunklib:/opt/splunk/etc/apps/github_forks/bin/splunklib # Random numbers - ./modularinputs/python/random_numbers:/opt/splunk/etc/apps/random_numbers - - ./lib/splunklib:/opt/splunk/etc/apps/random_numbers/lib/splunklib + - ./lib/splunklib:/opt/splunk/etc/apps/random_numbers/bin/splunklib # Twitted - ./python/twitted/twitted:/opt/splunk/etc/apps/twitted - - ./lib/splunklib:/opt/splunk/etc/apps/twitted/lib/splunklib + - ./lib/splunklib:/opt/splunk/etc/apps/twitted/bin/splunklib healthcheck: test: ['CMD', 'curl', '-f', 'http://localhost:8000'] diff --git a/modularinputs/python/github_commits/bin/github_commits.py b/modularinputs/python/github_commits/bin/github_commits.py index 2bcdcbb..2f76190 100644 --- a/modularinputs/python/github_commits/bin/github_commits.py +++ b/modularinputs/python/github_commits/bin/github_commits.py @@ -21,12 +21,11 @@ from http import client from datetime import datetime -# NOTE: splunklib must exist within github_commits/lib/splunklib for this -# example to run! To run this locally use `SPLUNK_VERSION=latest docker compose up -d` -# from the root of this repo which mounts this example and the latest splunklib -# code together at /opt/splunk/etc/apps/github_commits +# NOTE: splunklib must exist within github_commits/bin for this example to run! +# To run this locally run `make up` from the root of this repo which mounts +# this example and the latest splunklib code together at /opt/splunk/etc/apps/github_commits + -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib")) from splunklib.modularinput import * diff --git a/modularinputs/python/github_forks/bin/github_forks.py b/modularinputs/python/github_forks/bin/github_forks.py index f1e2880..0b13d78 100755 --- a/modularinputs/python/github_forks/bin/github_forks.py +++ b/modularinputs/python/github_forks/bin/github_forks.py @@ -14,16 +14,13 @@ # License for the specific language governing permissions and limitations # under the License. -import os import sys import json from http import client -# NOTE: splunklib must exist within github_forks/lib/splunklib for this -# example to run! To run this locally use `SPLUNK_VERSION=latest docker compose up -d` -# from the root of this repo which mounts this example and the latest splunklib -# code together at /opt/splunk/etc/apps/github_forks -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib")) +# NOTE: splunklib must exist within github_forks/bin for this example to run! +# To run this locally run `make up` from the root of this repo which mounts +# this example and the latest splunklib code together at /opt/splunk/etc/apps/github_forks from splunklib.modularinput import * diff --git a/modularinputs/python/random_numbers/bin/random_numbers.py b/modularinputs/python/random_numbers/bin/random_numbers.py index 783b3f7..9688788 100755 --- a/modularinputs/python/random_numbers/bin/random_numbers.py +++ b/modularinputs/python/random_numbers/bin/random_numbers.py @@ -16,13 +16,11 @@ import random import sys -import os -# NOTE: splunklib must exist within random_numbers/lib/splunklib for this -# example to run! To run this locally use `SPLUNK_VERSION=latest docker compose up -d` -# from the root of this repo which mounts this example and the latest splunklib -# code together at /opt/splunk/etc/apps/random_numbers -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib")) +# NOTE: splunklib must exist within random_numbers/bin for this example to run! +# To run this locally run `make up` from the root of this repo which mounts +# this example and the latest splunklib code together at /opt/splunk/etc/apps/random_numbers + from splunklib.modularinput import * diff --git a/python/twitted/twitted/bin/hashtags.py b/python/twitted/twitted/bin/hashtags.py index 6ffade4..4f44e75 100644 --- a/python/twitted/twitted/bin/hashtags.py +++ b/python/twitted/twitted/bin/hashtags.py @@ -16,14 +16,10 @@ # under the License. -import os import sys import json -from collections import Counter -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib")) -from splunklib.searchcommands import dispatch, ReportingCommand, Configuration, Option, validators -from splunklib.searchcommands import splunklib_logger +from splunklib.searchcommands import dispatch, ReportingCommand, Configuration @Configuration(requires_preop=True) diff --git a/python/twitted/twitted/bin/tophashtags.py b/python/twitted/twitted/bin/tophashtags.py index 0efaa22..b8b8c5f 100644 --- a/python/twitted/twitted/bin/tophashtags.py +++ b/python/twitted/twitted/bin/tophashtags.py @@ -16,14 +16,11 @@ # under the License. -import os import sys import json from collections import Counter -sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib")) from splunklib.searchcommands import dispatch, ReportingCommand, Configuration, Option, validators -from splunklib.searchcommands import splunklib_logger @Configuration(requires_preop=True) diff --git a/setup_pages/dependency_checking_app_example/bin/weather.py b/setup_pages/dependency_checking_app_example/bin/weather.py index 8c356d4..fdad7e1 100644 --- a/setup_pages/dependency_checking_app_example/bin/weather.py +++ b/setup_pages/dependency_checking_app_example/bin/weather.py @@ -1,12 +1,7 @@ -import os, sys +import sys import requests from urllib.parse import urljoin, urlencode -# Library-loading boilerplate -APP_NAME = 'dependency_checking_app_example' -splunkhome = os.environ['SPLUNK_HOME'] -apphome = os.path.join(splunkhome, 'etc', 'apps', APP_NAME) -sys.path.append(os.path.join(apphome, 'vendor')) # Enterprise SDK imports import splunklib.client as client diff --git a/setup_pages/weather_app_example/bin/weather.py b/setup_pages/weather_app_example/bin/weather.py index 4cca910..1ba4c3e 100644 --- a/setup_pages/weather_app_example/bin/weather.py +++ b/setup_pages/weather_app_example/bin/weather.py @@ -1,12 +1,7 @@ -import os, sys +import sys import requests from urllib.parse import urljoin, urlencode -# Library-loading boilerplate -APP_NAME = 'weather_app_example' -splunkhome = os.environ['SPLUNK_HOME'] -apphome = os.path.join(splunkhome, 'etc', 'apps', APP_NAME) -sys.path.append(os.path.join(apphome, 'vendor')) # Enterprise SDK imports import splunklib.client as client