mirror of
https://github.com/ansible/awx.git
synced 2026-02-20 12:40:06 -03:30
add an awx-manage command that gets pip freeze data from custom_venvs and outputs to command line stdout
remove analytics tests for counts of custom venvs, bump collector version, and remove list of custom venvs from API
This commit is contained in:
@@ -6,6 +6,7 @@ import json
|
||||
import yaml
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import re
|
||||
import stat
|
||||
import urllib.parse
|
||||
@@ -890,30 +891,34 @@ def get_current_apps():
|
||||
return current_apps
|
||||
|
||||
|
||||
def get_custom_venv_choices(custom_paths=None):
|
||||
def get_custom_venv_choices():
|
||||
from django.conf import settings
|
||||
|
||||
custom_paths = custom_paths or settings.CUSTOM_VENV_PATHS
|
||||
all_venv_paths = [settings.BASE_VENV_PATH] + custom_paths
|
||||
all_venv_paths = settings.CUSTOM_VENV_PATHS + [settings.BASE_VENV_PATH]
|
||||
custom_venv_choices = []
|
||||
|
||||
for custom_venv_path in all_venv_paths:
|
||||
for venv_path in all_venv_paths:
|
||||
try:
|
||||
if os.path.exists(custom_venv_path):
|
||||
if os.path.exists(venv_path):
|
||||
custom_venv_choices.extend(
|
||||
[
|
||||
os.path.join(custom_venv_path, x, '')
|
||||
for x in os.listdir(custom_venv_path)
|
||||
if x != 'awx'
|
||||
and os.path.isdir(os.path.join(custom_venv_path, x))
|
||||
and os.path.exists(os.path.join(custom_venv_path, x, 'bin', 'activate'))
|
||||
]
|
||||
[os.path.join(venv_path, x) for x in os.listdir(venv_path) if os.path.exists(os.path.join(venv_path, x, 'bin', 'pip'))]
|
||||
)
|
||||
except Exception:
|
||||
logger.exception("Encountered an error while discovering custom virtual environments.")
|
||||
return custom_venv_choices
|
||||
|
||||
|
||||
def get_custom_venv_pip_freeze(venv_path):
|
||||
venv_path = os.path.join(venv_path, 'bin', 'pip')
|
||||
try:
|
||||
if os.path.exists(venv_path):
|
||||
freeze_data = subprocess.run([venv_path, "freeze"], capture_output=True)
|
||||
pip_data = (freeze_data.stdout).decode('UTF-8')
|
||||
return pip_data
|
||||
except Exception:
|
||||
logger.exception("Encountered an error while discovering Pip Freeze data for custom virtual environments.")
|
||||
|
||||
|
||||
def is_ansible_variable(key):
|
||||
return key.startswith('ansible_')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user