mirror of
https://github.com/ansible/awx.git
synced 2026-04-06 02:29:21 -02:30
Replace pkg_resources with importlib.metadata (#15441)
This commit is contained in:
committed by
GitHub
parent
a5de4652b9
commit
e68370f2aa
@@ -1,9 +1,9 @@
|
||||
import os
|
||||
import pkg_resources
|
||||
import sqlite3
|
||||
import sys
|
||||
import traceback
|
||||
import uuid
|
||||
from importlib.metadata import version as _get_version
|
||||
|
||||
from django.core.cache import cache
|
||||
from django.core.cache.backends.locmem import LocMemCache
|
||||
@@ -70,7 +70,7 @@ class RecordedQueryLog(object):
|
||||
else:
|
||||
progname = os.path.basename(sys.argv[0])
|
||||
filepath = os.path.join(self.dest, '{}.sqlite'.format(progname))
|
||||
version = pkg_resources.get_distribution('awx').version
|
||||
version = _get_version('awx')
|
||||
log = sqlite3.connect(filepath, timeout=3)
|
||||
log.execute(
|
||||
'CREATE TABLE IF NOT EXISTS queries ('
|
||||
|
||||
@@ -5,7 +5,7 @@ import functools
|
||||
import inspect
|
||||
import logging
|
||||
import os
|
||||
from pkg_resources import iter_entry_points
|
||||
from importlib.metadata import entry_points
|
||||
import re
|
||||
import stat
|
||||
import tempfile
|
||||
@@ -56,7 +56,7 @@ from awx_plugins.credentials import injectors as builtin_injectors
|
||||
__all__ = ['Credential', 'CredentialType', 'CredentialInputSource', 'build_safe_env']
|
||||
|
||||
logger = logging.getLogger('awx.main.models.credential')
|
||||
credential_plugins = dict((ep.name, ep.load()) for ep in iter_entry_points('awx_plugins.credentials'))
|
||||
credential_plugins = {entry_point.name: entry_point.load() for entry_point in entry_points(group='awx_plugins.credentials')}
|
||||
|
||||
HIDDEN_PASSWORD = '**********'
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import threading
|
||||
import contextlib
|
||||
import tempfile
|
||||
import functools
|
||||
from importlib.metadata import version as _get_version
|
||||
|
||||
# Django
|
||||
from django.core.exceptions import ObjectDoesNotExist, FieldDoesNotExist
|
||||
@@ -230,9 +231,7 @@ def get_awx_version():
|
||||
from awx import __version__
|
||||
|
||||
try:
|
||||
import pkg_resources
|
||||
|
||||
return pkg_resources.require('awx')[0].version
|
||||
return _get_version('awx')
|
||||
except Exception:
|
||||
return __version__
|
||||
|
||||
|
||||
Reference in New Issue
Block a user