Skip to content

Commit

Permalink
Avoid using the deprecated selectors compat module utils.
Browse files Browse the repository at this point in the history
  • Loading branch information
felixfontein committed May 24, 2024
1 parent 7867390 commit 05bc0f7
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 4 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/871-selectors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- "docker and nsenter connection plugins, docker_container_exec module - avoid using the deprecated ``ansible.module_utils.compat.selectors`` module util with Python 3 (https://github.com/ansible-collections/community.docker/issues/870, https://github.com/ansible-collections/community.docker/pull/871)."
2 changes: 1 addition & 1 deletion plugins/connection/docker.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@
import subprocess
import re

from ansible.compat import selectors
from ansible.errors import AnsibleError, AnsibleFileNotFound
from ansible.module_utils.six.moves import shlex_quote
from ansible.module_utils.common.process import get_bin_path
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
from ansible.plugins.connection import ConnectionBase, BUFSIZE
from ansible.utils.display import Display

from ansible_collections.community.docker.plugins.module_utils.selectors import selectors
from ansible_collections.community.docker.plugins.module_utils.version import LooseVersion

display = Display()
Expand Down
4 changes: 3 additions & 1 deletion plugins/connection/nsenter.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,15 @@

import ansible.constants as C
from ansible.errors import AnsibleError
from ansible.module_utils.compat import selectors
from ansible.module_utils.six import binary_type, text_type
from ansible.module_utils.common.text.converters import to_bytes, to_native, to_text
from ansible.plugins.connection import ConnectionBase
from ansible.utils.display import Display
from ansible.utils.path import unfrackpath

from ansible_collections.community.docker.plugins.module_utils.selectors import selectors


display = Display()


Expand Down
21 changes: 21 additions & 0 deletions plugins/module_utils/selectors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# -*- coding: utf-8 -*-

# Copyright (c) 2024, Felix Fontein <[email protected]>
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

"""Provide selectors import."""

from __future__ import absolute_import, division, print_function
__metaclass__ = type


# Once we drop support for ansible-core 2.16, we can remove the try/except.

from sys import version_info as _python_version_info


if _python_version_info < (3, 4):
from ansible.module_utils.compat import selectors
else:
import selectors
3 changes: 2 additions & 1 deletion plugins/modules/docker_container_exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,15 @@
import traceback

from ansible.module_utils.common.text.converters import to_text, to_bytes, to_native
from ansible.module_utils.compat import selectors
from ansible.module_utils.six import string_types

from ansible_collections.community.docker.plugins.module_utils.common_api import (
AnsibleDockerClient,
RequestException,
)

from ansible_collections.community.docker.plugins.module_utils.selectors import selectors

from ansible_collections.community.docker.plugins.module_utils.socket_handler import (
DockerSocketHandlerModule,
)
Expand Down
2 changes: 1 addition & 1 deletion plugins/plugin_utils/socket_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__metaclass__ = type


from ansible.compat import selectors
from ansible_collections.community.docker.plugins.module_utils.selectors import selectors

from ansible_collections.community.docker.plugins.module_utils.socket_handler import (
DockerSocketHandlerBase,
Expand Down

0 comments on commit 05bc0f7

Please sign in to comment.