From bd2da80cea4cd0c2df4af316da34c001a00a18b4 Mon Sep 17 00:00:00 2001 From: Rebeccah Date: Thu, 3 Jun 2021 15:46:04 -0400 Subject: [PATCH] restructure so the -q is actually completely quiet --- awx/main/management/commands/custom_venv_associations.py | 8 ++++---- awx/main/management/commands/export_custom_venv.py | 6 ++++-- awx/main/management/commands/list_custom_venvs.py | 8 +++++--- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/awx/main/management/commands/custom_venv_associations.py b/awx/main/management/commands/custom_venv_associations.py index e80c97aad0..89c298f589 100644 --- a/awx/main/management/commands/custom_venv_associations.py +++ b/awx/main/management/commands/custom_venv_associations.py @@ -37,12 +37,10 @@ class Command(BaseCommand): results["job_templates"] = jts results["projects"] = proj results["inventory_sources"] = invsrc - print('\n', '# {}'.format("Virtual environments associations:")) - print(yaml.dump(results)) - if not options.get('q'): msg = [ - '', + '# Virtual Environments Associations:', + yaml.dump(results), '- To list all (now deprecated) custom virtual environments run:', 'awx-manage list_custom_venvs', '', @@ -53,6 +51,8 @@ class Command(BaseCommand): '', ] print('\n'.join(msg)) + else: + print(yaml.dump(results)) else: print('\n', '# Incorrect path, verify your path is from the following list:') diff --git a/awx/main/management/commands/export_custom_venv.py b/awx/main/management/commands/export_custom_venv.py index f267baa6be..82065b789d 100644 --- a/awx/main/management/commands/export_custom_venv.py +++ b/awx/main/management/commands/export_custom_venv.py @@ -26,10 +26,10 @@ class Command(BaseCommand): if path[0] in all_venvs: pip_data = get_custom_venv_pip_freeze(options.get('path')[0]) if pip_data: - print('\n', '# {}'.format("Virtual environment contents:")) - print(pip_data) if not options.get('q'): msg = [ + '# Virtual environment contents:', + pip_data, '- To list all (now deprecated) custom virtual environments run:', 'awx-manage list_custom_venvs', '', @@ -40,6 +40,8 @@ class Command(BaseCommand): '', ] print('\n'.join(msg)) + else: + print(pip_data) else: print('\n', '# Incorrect path, verify your path is from the following list:') diff --git a/awx/main/management/commands/list_custom_venvs.py b/awx/main/management/commands/list_custom_venvs.py index 03534881b9..0d84b5e3fd 100644 --- a/awx/main/management/commands/list_custom_venvs.py +++ b/awx/main/management/commands/list_custom_venvs.py @@ -17,10 +17,11 @@ class Command(BaseCommand): super(Command, self).__init__() venvs = get_custom_venv_choices() if venvs: - print('\n', '# {}'.format("Discovered virtual environments:")) - print('\n'.join(venvs), '\n') if not options.get('q'): msg = [ + '# Discovered Virtual Environments:', + '\n'.join(venvs), + '', '- To export the contents of a (deprecated) virtual environment, ' 'run the following command while supplying the path as an argument:', 'awx-manage export_custom_venv /path/to/venv', '', @@ -31,7 +32,8 @@ class Command(BaseCommand): '', ] print('\n'.join(msg)) - + else: + print('\n'.join(venvs), '\n') else: msg = ["No custom virtual environments detected in:", settings.BASE_VENV_PATH]