Browse Source

Make Python Interpreter option for Ansible Validation Run

This patch adds the --python-interpreter argument to the run
subcommand and allows the user to specify their own python interpreter.

Change-Id: Ie76d0238f117a48b2f919cd5bdc4dfae8b47ac5e
Signed-off-by: Gael Chamoulaud (Strider) <gchamoul@redhat.com>
changes/97/790897/5
Gael Chamoulaud (Strider) 1 month ago
committed by Gael Chamoulaud
parent
commit
f2e37b0f27
2 changed files with 22 additions and 0 deletions
  1. +11
    -0
      validations_libs/cli/run.py
  2. +11
    -0
      validations_libs/tests/cli/test_run.py

+ 11
- 0
validations_libs/cli/run.py View File

@ -71,6 +71,16 @@ class Run(Command):
help=("Path where the run result in JUnitXML "
"format will be stored."))
parser.add_argument(
'--python-interpreter',
metavar="--python-interpreter <PYTHON_INTERPRETER_PATH>",
action="store",
default="{}".format(
sys.executable if sys.executable else "/usr/bin/python"
),
help=("Python interpreter for Ansible execution. ")
)
parser.add_argument(
'--extra-env-vars',
action=KeyValueAction,
@ -171,6 +181,7 @@ class Run(Command):
base_dir=parsed_args.ansible_base_dir,
validation_name=parsed_args.validation_name,
extra_env_vars=extra_env_vars,
python_interpreter=parsed_args.python_interpreter,
quiet=quiet_mode,
ssh_user=parsed_args.ssh_user,
)


+ 11
- 0
validations_libs/tests/cli/test_run.py View File

@ -12,6 +12,8 @@
# License for the specific language governing permissions and limitations
# under the License.
#
import sys
try:
from unittest import mock
except ImportError:
@ -72,6 +74,7 @@ class TestRun(BaseCommand):
'base_dir': '/usr/share/ansible/',
'validation_name': ['foo'],
'extra_env_vars': None,
'python_interpreter': sys.executable,
'quiet': True,
'ssh_user': 'doe'}
@ -101,6 +104,7 @@ class TestRun(BaseCommand):
'base_dir': '/usr/share/ansible/',
'validation_name': ['foo'],
'extra_env_vars': None,
'python_interpreter': sys.executable,
'quiet': True,
'ssh_user': 'doe'}
@ -142,6 +146,7 @@ class TestRun(BaseCommand):
'base_dir': '/usr/share/ansible/',
'validation_name': ['foo'],
'extra_env_vars': None,
'python_interpreter': sys.executable,
'quiet': True,
'ssh_user': 'doe'}
@ -169,6 +174,7 @@ class TestRun(BaseCommand):
'base_dir': '/usr/share/ansible/',
'validation_name': ['foo'],
'extra_env_vars': {'key': 'value'},
'python_interpreter': sys.executable,
'quiet': True,
'ssh_user': 'doe'}
@ -198,6 +204,7 @@ class TestRun(BaseCommand):
'base_dir': '/usr/share/ansible/',
'validation_name': ['foo'],
'extra_env_vars': {'ANSIBLE_STDOUT_CALLBACK': 'default'},
'python_interpreter': sys.executable,
'quiet': False,
'ssh_user': 'doe'}
@ -225,6 +232,7 @@ class TestRun(BaseCommand):
'base_dir': '/usr/share/ansible/',
'validation_name': ['foo'],
'extra_env_vars': {'key': 'value2'},
'python_interpreter': sys.executable,
'quiet': True,
'ssh_user': 'doe'}
@ -254,6 +262,7 @@ class TestRun(BaseCommand):
'base_dir': '/usr/share/ansible/',
'validation_name': ['foo'],
'extra_env_vars': {'key2': 'value2'},
'python_interpreter': sys.executable,
'quiet': True,
'ssh_user': 'doe'}
@ -292,6 +301,7 @@ class TestRun(BaseCommand):
'base_dir': '/usr/share/ansible/',
'validation_name': ['foo'],
'extra_env_vars': {'key2': 'value2'},
'python_interpreter': sys.executable,
'quiet': True,
'ssh_user': 'doe'}
@ -315,6 +325,7 @@ class TestRun(BaseCommand):
'base_dir': '/usr/share/ansible/',
'validation_name': ['foo'],
'extra_env_vars': {'key2': 'value2'},
'python_interpreter': sys.executable,
'quiet': True,
'ssh_user': 'doe'}


Loading…
Cancel
Save