mirror of
https://github.com/ansible/awx.git
synced 2026-07-29 08:59:55 -02:30
AAP-59874: Update to Python 3.12 (#16208)
* update to Python 3.12 * remove use of utcnow * switch to timezone.utc datetime.UTC is an alias of datetime.timezone.utc. if we're doing the double import for datetime it's more straightforward to just import timezone as well and get it directly * debug python env version issue * change python version * pin to SHA and remove debug portion
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
# Copyright (c) 2015 Ansible, Inc.
|
||||
# All Rights Reserved
|
||||
import sys
|
||||
from distutils.util import strtobool
|
||||
from argparse import RawTextHelpFormatter
|
||||
|
||||
from django.core.management.base import BaseCommand
|
||||
@@ -9,6 +8,24 @@ from django.conf import settings
|
||||
from awx.main.models import CredentialType, Credential, ExecutionEnvironment
|
||||
|
||||
|
||||
def strtobool(val):
|
||||
"""Convert a string representation of truth to true (1) or false (0).
|
||||
|
||||
True values are 'y', 'yes', 't', 'true', 'on', and '1'.
|
||||
False values are 'n', 'no', 'f', 'false', 'off', and '0'.
|
||||
Raises ValueError if 'val' is anything else.
|
||||
|
||||
This replaces the deprecated distutils.util.strtobool removed in Python 3.12.
|
||||
"""
|
||||
val = val.lower()
|
||||
if val in ('y', 'yes', 't', 'true', 'on', '1'):
|
||||
return 1
|
||||
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
|
||||
return 0
|
||||
else:
|
||||
raise ValueError(f"invalid truth value {val!r}")
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
"""Create default execution environments, intended for new installs"""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user