mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-23 04:24:00 -07:00
remove Python2 some constructs/docs/comments (#10892)
Some checks are pending
EOL CI / EOL Sanity (Ⓐ2.17) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.10) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.12) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.7) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/3/) (push) Waiting to run
nox / Run extra sanity tests (push) Waiting to run
Some checks are pending
EOL CI / EOL Sanity (Ⓐ2.17) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.10) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.12) (push) Waiting to run
EOL CI / EOL Units (Ⓐ2.17+py3.7) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+alpine319+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+fedora39+py:azp/posix/3/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/1/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/2/) (push) Waiting to run
EOL CI / EOL I (Ⓐ2.17+ubuntu2004+py:azp/posix/3/) (push) Waiting to run
nox / Run extra sanity tests (push) Waiting to run
* remove Python2 some constructs/docs/comments * add changelog frag
This commit is contained in:
parent
5f471b8e5b
commit
633bd6133a
12 changed files with 22 additions and 47 deletions
7
changelogs/fragments/10892-remove-py2.yml
Normal file
7
changelogs/fragments/10892-remove-py2.yml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
minor_changes:
|
||||||
|
- known_hosts module_utils - drop Python 2 support when parsing output of ``urlparse`` (https://github.com/ansible-collections/community.general/pull/10892).
|
||||||
|
- aix_inittab - drop Python 2 support for function ``zip`` (https://github.com/ansible-collections/community.general/pull/10892).
|
||||||
|
- copr - drop support for Python 2 interpreter (https://github.com/ansible-collections/community.general/pull/10892).
|
||||||
|
- dconf - drop support for Python 2 interpreter (https://github.com/ansible-collections/community.general/pull/10892).
|
||||||
|
- irc - drop Python 2 support for SSL context creation (https://github.com/ansible-collections/community.general/pull/10892).
|
||||||
|
- mail - drop Python 2 support for Message-ID domain setting (https://github.com/ansible-collections/community.general/pull/10892).
|
|
@ -60,17 +60,14 @@ def get_fqdn_and_port(repo_url):
|
||||||
elif "://" in repo_url:
|
elif "://" in repo_url:
|
||||||
# this should be something we can parse with urlparse
|
# this should be something we can parse with urlparse
|
||||||
parts = urlparse(repo_url)
|
parts = urlparse(repo_url)
|
||||||
# parts[1] will be empty on python2.4 on ssh:// or git:// urls, so
|
fqdn = parts[1]
|
||||||
# ensure we actually have a parts[1] before continuing.
|
if "@" in fqdn:
|
||||||
if parts[1] != '':
|
fqdn = fqdn.split("@", 1)[1]
|
||||||
fqdn = parts[1]
|
match = ipv6_re.match(fqdn)
|
||||||
if "@" in fqdn:
|
if match:
|
||||||
fqdn = fqdn.split("@", 1)[1]
|
fqdn, port = match.groups()
|
||||||
match = ipv6_re.match(fqdn)
|
elif ":" in fqdn:
|
||||||
if match:
|
fqdn, port = fqdn.split(":")[0:2]
|
||||||
fqdn, port = match.groups()
|
|
||||||
elif ":" in fqdn:
|
|
||||||
fqdn, port = fqdn.split(":")[0:2]
|
|
||||||
return fqdn, port
|
return fqdn, port
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -114,12 +114,6 @@ name:
|
||||||
sample: startmyservice
|
sample: startmyservice
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Import necessary libraries
|
|
||||||
try:
|
|
||||||
# python 2
|
|
||||||
from itertools import izip
|
|
||||||
except ImportError:
|
|
||||||
izip = zip
|
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
|
||||||
|
@ -138,7 +132,7 @@ def check_current_entry(module):
|
||||||
values = out.split(":")
|
values = out.split(":")
|
||||||
# strip non readable characters as \n
|
# strip non readable characters as \n
|
||||||
values = map(lambda s: s.strip(), values)
|
values = map(lambda s: s.strip(), values)
|
||||||
existsdict = dict(izip(keys, values))
|
existsdict = dict(zip(keys, values))
|
||||||
existsdict.update({'exist': True})
|
existsdict.update({'exist': True})
|
||||||
return existsdict
|
return existsdict
|
||||||
|
|
||||||
|
|
|
@ -56,8 +56,6 @@ author:
|
||||||
todo:
|
todo:
|
||||||
notes:
|
notes:
|
||||||
- Concurrently syncing Cobbler is bound to fail with weird errors.
|
- Concurrently syncing Cobbler is bound to fail with weird errors.
|
||||||
- On Python 2.7.8 and older (such as RHEL7) you may need to tweak the Python behaviour to disable certificate validation.
|
|
||||||
More information at L(Certificate verification in Python standard library HTTP clients,https://access.redhat.com/articles/2039753).
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
|
|
|
@ -79,8 +79,6 @@ author:
|
||||||
- Dag Wieers (@dagwieers)
|
- Dag Wieers (@dagwieers)
|
||||||
notes:
|
notes:
|
||||||
- Concurrently syncing Cobbler is bound to fail with weird errors.
|
- Concurrently syncing Cobbler is bound to fail with weird errors.
|
||||||
- On Python 2.7.8 and older (such as RHEL7) you may need to tweak the Python behaviour to disable certificate validation.
|
|
||||||
More information at L(Certificate verification in Python standard library HTTP clients,https://access.redhat.com/articles/2039753).
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
EXAMPLES = r"""
|
EXAMPLES = r"""
|
||||||
|
|
|
@ -129,7 +129,6 @@ def _respawn_dnf():
|
||||||
system_interpreters = (
|
system_interpreters = (
|
||||||
"/usr/libexec/platform-python",
|
"/usr/libexec/platform-python",
|
||||||
"/usr/bin/python3",
|
"/usr/bin/python3",
|
||||||
"/usr/bin/python2",
|
|
||||||
"/usr/bin/python",
|
"/usr/bin/python",
|
||||||
)
|
)
|
||||||
interpreter = respawn.probe_interpreters_for_module(system_interpreters, "dnf")
|
interpreter = respawn.probe_interpreters_for_module(system_interpreters, "dnf")
|
||||||
|
|
|
@ -421,8 +421,7 @@ def main():
|
||||||
msg="%s must be installed and visible from %s." %
|
msg="%s must be installed and visible from %s." %
|
||||||
(glib_module_name, sys.executable))
|
(glib_module_name, sys.executable))
|
||||||
|
|
||||||
interpreters = ['/usr/bin/python3', '/usr/bin/python2',
|
interpreters = ['/usr/bin/python3', '/usr/bin/python']
|
||||||
'/usr/bin/python']
|
|
||||||
|
|
||||||
interpreter = probe_interpreters_for_module(
|
interpreter = probe_interpreters_for_module(
|
||||||
interpreters, glib_module_name)
|
interpreters, glib_module_name)
|
||||||
|
|
|
@ -92,8 +92,6 @@ requirements:
|
||||||
- PyGithub>=1.54
|
- PyGithub>=1.54
|
||||||
notes:
|
notes:
|
||||||
- For Python 3, PyGithub>=1.54 should be used.
|
- For Python 3, PyGithub>=1.54 should be used.
|
||||||
- 'For Python 3.5, PyGithub==1.54 should be used. More information: U(https://pygithub.readthedocs.io/en/latest/changes.html#version-1-54-november-30-2020).'
|
|
||||||
- 'For Python 2.7, PyGithub==1.45 should be used. More information: U(https://pygithub.readthedocs.io/en/latest/changes.html#version-1-45-december-29-2019).'
|
|
||||||
author:
|
author:
|
||||||
- Álvaro Torres Cogollo (@atorrescogollo)
|
- Álvaro Torres Cogollo (@atorrescogollo)
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -234,17 +234,10 @@ def send_msg(msg, server='localhost', port='6667', channel=None, nick_to=None, k
|
||||||
if use_tls:
|
if use_tls:
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
if validate_certs:
|
if validate_certs:
|
||||||
try:
|
context = ssl.create_default_context()
|
||||||
context = ssl.create_default_context()
|
kwargs["server_hostname"] = server
|
||||||
kwargs["server_hostname"] = server
|
|
||||||
except AttributeError:
|
|
||||||
raise Exception('Need at least Python 2.7.9 for SSL certificate validation')
|
|
||||||
else:
|
else:
|
||||||
if getattr(ssl, 'PROTOCOL_TLS', None) is not None:
|
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
||||||
# Supported since Python 2.7.13
|
|
||||||
context = ssl.SSLContext(ssl.PROTOCOL_TLS)
|
|
||||||
else:
|
|
||||||
context = ssl.SSLContext()
|
|
||||||
context.verify_mode = ssl.CERT_NONE
|
context.verify_mode = ssl.CERT_NONE
|
||||||
irc = context.wrap_socket(irc, **kwargs)
|
irc = context.wrap_socket(irc, **kwargs)
|
||||||
irc.connect((server, int(port)))
|
irc.connect((server, int(port)))
|
||||||
|
|
|
@ -137,7 +137,6 @@ options:
|
||||||
message_id_domain:
|
message_id_domain:
|
||||||
description:
|
description:
|
||||||
- The domain name to use for the L(Message-ID header, https://en.wikipedia.org/wiki/Message-ID).
|
- The domain name to use for the L(Message-ID header, https://en.wikipedia.org/wiki/Message-ID).
|
||||||
- Note that this is only available on Python 3+. On Python 2, this value is ignored.
|
|
||||||
type: str
|
type: str
|
||||||
default: ansible
|
default: ansible
|
||||||
version_added: 8.2.0
|
version_added: 8.2.0
|
||||||
|
@ -352,12 +351,7 @@ def main():
|
||||||
msg['From'] = formataddr((sender_phrase, sender_addr))
|
msg['From'] = formataddr((sender_phrase, sender_addr))
|
||||||
msg['Date'] = formatdate(localtime=True)
|
msg['Date'] = formatdate(localtime=True)
|
||||||
msg['Subject'] = Header(subject, charset)
|
msg['Subject'] = Header(subject, charset)
|
||||||
try:
|
msg['Message-ID'] = make_msgid(domain=message_id_domain)
|
||||||
msg['Message-ID'] = make_msgid(domain=message_id_domain)
|
|
||||||
except TypeError:
|
|
||||||
# `domain` is only available in Python 3
|
|
||||||
msg['Message-ID'] = make_msgid()
|
|
||||||
module.warn("The Message-ID domain cannot be set on Python 2; the system's hostname is used")
|
|
||||||
msg.preamble = "Multipart message"
|
msg.preamble = "Multipart message"
|
||||||
|
|
||||||
for header in headers:
|
for header in headers:
|
||||||
|
|
|
@ -174,8 +174,6 @@ options:
|
||||||
requirements:
|
requirements:
|
||||||
- softlayer >= 4.1.1
|
- softlayer >= 4.1.1
|
||||||
notes:
|
notes:
|
||||||
- If using Python 2.7, you must install C(softlayer-python<=5.7.2).
|
|
||||||
- If using Python 3.6, you must install C(softlayer-python<=6.0.0).
|
|
||||||
- The C(softlayer-python) library, at version 6.2.6 (from Jan 2025), only supports Python version 3.8, 3.9 and 3.10.
|
- The C(softlayer-python) library, at version 6.2.6 (from Jan 2025), only supports Python version 3.8, 3.9 and 3.10.
|
||||||
author:
|
author:
|
||||||
- Matt Colton (@mcltn)
|
- Matt Colton (@mcltn)
|
||||||
|
|
|
@ -15,7 +15,7 @@ from ansible_collections.community.internal_test_tools.tests.unit.plugins.module
|
||||||
|
|
||||||
from pytest import importorskip
|
from pytest import importorskip
|
||||||
|
|
||||||
# Skip this test if python 2 so datadog_api_client cannot be installed
|
# Skip this test if datadog_api_client cannot be installed
|
||||||
datadog_api_client = importorskip("datadog_api_client")
|
datadog_api_client = importorskip("datadog_api_client")
|
||||||
Downtime = datadog_api_client.v1.model.downtime.Downtime
|
Downtime = datadog_api_client.v1.model.downtime.Downtime
|
||||||
DowntimeRecurrence = datadog_api_client.v1.model.downtime_recurrence.DowntimeRecurrence
|
DowntimeRecurrence = datadog_api_client.v1.model.downtime_recurrence.DowntimeRecurrence
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue