basic.py - Perform Python version check earlier (#79954)

pull/79958/head
Matt Clay 2 years ago committed by GitHub
parent e6900f5cad
commit 2525d0a136
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,2 @@
bugfixes:
- basic.py module_utils - Perform Python version check much earlier to ensure it runs before other errors occur.

@ -5,6 +5,21 @@
from __future__ import absolute_import, division, print_function from __future__ import absolute_import, division, print_function
__metaclass__ = type __metaclass__ = type
import sys
# Used for determining if the system is running a new enough python version
# and should only restrict on our documented minimum versions
_PY3_MIN = sys.version_info >= (3, 5)
_PY2_MIN = (2, 7) <= sys.version_info < (3,)
_PY_MIN = _PY3_MIN or _PY2_MIN
if not _PY_MIN:
print(
'\n{"failed": true, '
'"msg": "ansible-core requires a minimum of Python2 version 2.7 or Python3 version 3.5. Current version: %s"}' % ''.join(sys.version.splitlines())
)
sys.exit(1)
FILE_ATTRIBUTES = { FILE_ATTRIBUTES = {
'A': 'noatime', 'A': 'noatime',
'a': 'append', 'a': 'append',
@ -49,7 +64,6 @@ import shutil
import signal import signal
import stat import stat
import subprocess import subprocess
import sys
import tempfile import tempfile
import time import time
import traceback import traceback
@ -254,18 +268,6 @@ MODE_OPERATOR_RE = re.compile(r'[+=-]')
USERS_RE = re.compile(r'[^ugo]') USERS_RE = re.compile(r'[^ugo]')
PERMS_RE = re.compile(r'[^rwxXstugo]') PERMS_RE = re.compile(r'[^rwxXstugo]')
# Used for determining if the system is running a new enough python version
# and should only restrict on our documented minimum versions
_PY3_MIN = sys.version_info >= (3, 5)
_PY2_MIN = (2, 7) <= sys.version_info < (3,)
_PY_MIN = _PY3_MIN or _PY2_MIN
if not _PY_MIN:
print(
'\n{"failed": true, '
'"msg": "ansible-core requires a minimum of Python2 version 2.7 or Python3 version 3.5. Current version: %s"}' % ''.join(sys.version.splitlines())
)
sys.exit(1)
# #
# Deprecated functions # Deprecated functions

Loading…
Cancel
Save