From e33d919e4c03796916d0a06e26284c983976d27f Mon Sep 17 00:00:00 2001 From: Jonathan Sundqvist Date: Mon, 10 Feb 2025 16:35:16 +0100 Subject: [PATCH 1/8] Use relative imports for splunk-sdk --- splunklib/binding.py | 4 ++-- splunklib/client.py | 8 ++++---- splunklib/modularinput/event.py | 2 +- splunklib/modularinput/event_writer.py | 2 +- splunklib/searchcommands/search_command.py | 4 +--- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/splunklib/binding.py b/splunklib/binding.py index 25a09948..c5f361b8 100644 --- a/splunklib/binding.py +++ b/splunklib/binding.py @@ -39,8 +39,8 @@ from http import client from http.cookies import SimpleCookie from xml.etree.ElementTree import XML, ParseError -from splunklib.data import record -from splunklib import __version__ +from .data import record +from . import __version__ logger = logging.getLogger(__name__) diff --git a/splunklib/client.py b/splunklib/client.py index ee390c9e..c78ea88d 100644 --- a/splunklib/client.py +++ b/splunklib/client.py @@ -68,9 +68,9 @@ from time import sleep from urllib import parse -from splunklib import data -from splunklib.data import record -from splunklib.binding import (AuthenticationError, Context, HTTPError, UrlEncoded, +from . import data +from .data import record +from .binding import (AuthenticationError, Context, HTTPError, UrlEncoded, _encode, _make_cookie_header, _NoAuthenticationToken, namespace) @@ -3999,4 +3999,4 @@ def batch_save(self, *documents): data = json.dumps(documents) return json.loads( - self._post('batch_save', headers=KVStoreCollectionData.JSON_HEADER, body=data).body.read().decode('utf-8')) \ No newline at end of file + self._post('batch_save', headers=KVStoreCollectionData.JSON_HEADER, body=data).body.read().decode('utf-8')) diff --git a/splunklib/modularinput/event.py b/splunklib/modularinput/event.py index 7ee7266a..bebd61e4 100644 --- a/splunklib/modularinput/event.py +++ b/splunklib/modularinput/event.py @@ -15,7 +15,7 @@ from io import TextIOBase import xml.etree.ElementTree as ET -from splunklib.utils import ensure_str +from ..utils import ensure_str class Event: diff --git a/splunklib/modularinput/event_writer.py b/splunklib/modularinput/event_writer.py index 7be3845a..7ea37ca8 100644 --- a/splunklib/modularinput/event_writer.py +++ b/splunklib/modularinput/event_writer.py @@ -15,7 +15,7 @@ import sys import traceback -from splunklib.utils import ensure_str +from ..utils import ensure_str from .event import ET diff --git a/splunklib/searchcommands/search_command.py b/splunklib/searchcommands/search_command.py index 7e8f771e..e66f70c3 100644 --- a/splunklib/searchcommands/search_command.py +++ b/splunklib/searchcommands/search_command.py @@ -34,11 +34,8 @@ from urllib.parse import urlsplit from warnings import warn from xml.etree import ElementTree -from splunklib.utils import ensure_str - # Relative imports -import splunklib from . import Boolean, Option, environment from .internals import ( CommandLineParser, @@ -53,6 +50,7 @@ RecordWriterV2, json_encode_string) from ..client import Service +from ..utils import ensure_str # ---------------------------------------------------------------------------------------------------------------------- From 75e9a43c6aed2633dca67663c74e11e5aea342f5 Mon Sep 17 00:00:00 2001 From: Jakub Ramatowski Date: Thu, 3 Apr 2025 08:44:30 +0200 Subject: [PATCH 2/8] Test fix pipeline --- .github/workflows/test.yml | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index dc8bd208..e65cf0f6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,13 +9,36 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: - - ubuntu-latest - python: [ 3.7, 3.9, 3.13] - splunk-version: - - "8.1" - - "8.2" - - "latest" + include: + - os: ubuntu-22.04 # Only for Python 3.7 + python: 3.7 + splunk-version: "8.1" + - os: ubuntu-22.04 + python: 3.7 + splunk-version: "8.2" + - os: ubuntu-22.04 + python: 3.7 + splunk-version: "latest" + + - os: ubuntu-latest # For newer Python versions + python: 3.9 + splunk-version: "8.1" + - os: ubuntu-latest + python: 3.9 + splunk-version: "8.2" + - os: ubuntu-latest + python: 3.9 + splunk-version: "latest" + + - os: ubuntu-latest + python: 3.13 + splunk-version: "8.1" + - os: ubuntu-latest + python: 3.13 + splunk-version: "8.2" + - os: ubuntu-latest + python: 3.13 + splunk-version: "latest" fail-fast: false steps: From ef8a3b4b69597bd1ea9116c776b437304896f8f1 Mon Sep 17 00:00:00 2001 From: Jakub Ramatowski Date: Thu, 3 Apr 2025 12:09:00 +0200 Subject: [PATCH 3/8] Test fix pipeline --- .github/workflows/test.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e65cf0f6..7837c27a 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,36 +9,31 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: + splunk-version: + - "8.1" + - "8.2" + - "latest" include: - os: ubuntu-22.04 # Only for Python 3.7 python: 3.7 - splunk-version: "8.1" - os: ubuntu-22.04 python: 3.7 - splunk-version: "8.2" - os: ubuntu-22.04 python: 3.7 - splunk-version: "latest" - os: ubuntu-latest # For newer Python versions python: 3.9 - splunk-version: "8.1" - os: ubuntu-latest python: 3.9 - splunk-version: "8.2" - os: ubuntu-latest python: 3.9 - splunk-version: "latest" - os: ubuntu-latest python: 3.13 - splunk-version: "8.1" - os: ubuntu-latest python: 3.13 - splunk-version: "8.2" - os: ubuntu-latest python: 3.13 - splunk-version: "latest" fail-fast: false steps: From e25fc1b999cc6feb5d1ecca0117f615bb6192163 Mon Sep 17 00:00:00 2001 From: Jakub Ramatowski Date: Thu, 3 Apr 2025 12:16:55 +0200 Subject: [PATCH 4/8] Test fix pipeline --- .github/workflows/test.yml | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7837c27a..e5ff1e2b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,31 +9,24 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: + os: + - ubuntu-latest + python: [ 3.7, 3.9, 3.13 ] splunk-version: - "8.1" - "8.2" - "latest" include: - - os: ubuntu-22.04 # Only for Python 3.7 + - os: ubuntu-22.04 python: 3.7 + splunk-version: "8.1" - os: ubuntu-22.04 python: 3.7 + splunk-version: "8.2" - os: ubuntu-22.04 python: 3.7 + splunk-version: "latest" - - os: ubuntu-latest # For newer Python versions - python: 3.9 - - os: ubuntu-latest - python: 3.9 - - os: ubuntu-latest - python: 3.9 - - - os: ubuntu-latest - python: 3.13 - - os: ubuntu-latest - python: 3.13 - - os: ubuntu-latest - python: 3.13 fail-fast: false steps: From 2586111432a10c89494fae97af0dde6eb1cb098a Mon Sep 17 00:00:00 2001 From: Jakub Ramatowski Date: Thu, 3 Apr 2025 12:17:47 +0200 Subject: [PATCH 5/8] Test fix pipeline --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index e5ff1e2b..9ef02c94 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -11,7 +11,7 @@ jobs: matrix: os: - ubuntu-latest - python: [ 3.7, 3.9, 3.13 ] + python: [ 3.9, 3.13 ] splunk-version: - "8.1" - "8.2" From 7418861064a7c4aa8fab3f4fdf3296d0e2c04f10 Mon Sep 17 00:00:00 2001 From: Jakub Ramatowski Date: Thu, 3 Apr 2025 12:21:03 +0200 Subject: [PATCH 6/8] Test fix pipeline --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9ef02c94..329c686c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,7 @@ name: Python CI on: - [ push, pull_request, workflow_dispatch ] + [ push, workflow_dispatch ] jobs: build: From 3b6d974dca26fd4bf29b5bf316f56b5f87b6bd90 Mon Sep 17 00:00:00 2001 From: szymonjas <166526821+szymonjas@users.noreply.github.com> Date: Wed, 9 Apr 2025 10:01:21 +0200 Subject: [PATCH 7/8] Revert "Fix pipeline" --- .github/workflows/test.yml | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 329c686c..dc8bd208 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,7 +1,7 @@ name: Python CI on: - [ push, workflow_dispatch ] + [ push, pull_request, workflow_dispatch ] jobs: build: @@ -11,22 +11,11 @@ jobs: matrix: os: - ubuntu-latest - python: [ 3.9, 3.13 ] + python: [ 3.7, 3.9, 3.13] splunk-version: - "8.1" - "8.2" - "latest" - include: - - os: ubuntu-22.04 - python: 3.7 - splunk-version: "8.1" - - os: ubuntu-22.04 - python: 3.7 - splunk-version: "8.2" - - os: ubuntu-22.04 - python: 3.7 - splunk-version: "latest" - fail-fast: false steps: From de9f0f8685c9106d6145efc7bfae3147b0c18441 Mon Sep 17 00:00:00 2001 From: szymonjas <166526821+szymonjas@users.noreply.github.com> Date: Wed, 9 Apr 2025 10:03:20 +0200 Subject: [PATCH 8/8] Revert "Use relative imports for splunk-sdk" --- splunklib/binding.py | 4 ++-- splunklib/client.py | 8 ++++---- splunklib/modularinput/event.py | 2 +- splunklib/modularinput/event_writer.py | 2 +- splunklib/searchcommands/search_command.py | 4 +++- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/splunklib/binding.py b/splunklib/binding.py index c5f361b8..25a09948 100644 --- a/splunklib/binding.py +++ b/splunklib/binding.py @@ -39,8 +39,8 @@ from http import client from http.cookies import SimpleCookie from xml.etree.ElementTree import XML, ParseError -from .data import record -from . import __version__ +from splunklib.data import record +from splunklib import __version__ logger = logging.getLogger(__name__) diff --git a/splunklib/client.py b/splunklib/client.py index c78ea88d..ee390c9e 100644 --- a/splunklib/client.py +++ b/splunklib/client.py @@ -68,9 +68,9 @@ from time import sleep from urllib import parse -from . import data -from .data import record -from .binding import (AuthenticationError, Context, HTTPError, UrlEncoded, +from splunklib import data +from splunklib.data import record +from splunklib.binding import (AuthenticationError, Context, HTTPError, UrlEncoded, _encode, _make_cookie_header, _NoAuthenticationToken, namespace) @@ -3999,4 +3999,4 @@ def batch_save(self, *documents): data = json.dumps(documents) return json.loads( - self._post('batch_save', headers=KVStoreCollectionData.JSON_HEADER, body=data).body.read().decode('utf-8')) + self._post('batch_save', headers=KVStoreCollectionData.JSON_HEADER, body=data).body.read().decode('utf-8')) \ No newline at end of file diff --git a/splunklib/modularinput/event.py b/splunklib/modularinput/event.py index bebd61e4..7ee7266a 100644 --- a/splunklib/modularinput/event.py +++ b/splunklib/modularinput/event.py @@ -15,7 +15,7 @@ from io import TextIOBase import xml.etree.ElementTree as ET -from ..utils import ensure_str +from splunklib.utils import ensure_str class Event: diff --git a/splunklib/modularinput/event_writer.py b/splunklib/modularinput/event_writer.py index 7ea37ca8..7be3845a 100644 --- a/splunklib/modularinput/event_writer.py +++ b/splunklib/modularinput/event_writer.py @@ -15,7 +15,7 @@ import sys import traceback -from ..utils import ensure_str +from splunklib.utils import ensure_str from .event import ET diff --git a/splunklib/searchcommands/search_command.py b/splunklib/searchcommands/search_command.py index e66f70c3..7e8f771e 100644 --- a/splunklib/searchcommands/search_command.py +++ b/splunklib/searchcommands/search_command.py @@ -34,8 +34,11 @@ from urllib.parse import urlsplit from warnings import warn from xml.etree import ElementTree +from splunklib.utils import ensure_str + # Relative imports +import splunklib from . import Boolean, Option, environment from .internals import ( CommandLineParser, @@ -50,7 +53,6 @@ RecordWriterV2, json_encode_string) from ..client import Service -from ..utils import ensure_str # ----------------------------------------------------------------------------------------------------------------------