Skip to content

Commit 932fc20

Browse files
committed
WIP
1 parent fca7578 commit 932fc20

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

ansible_mitogen/mixins.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -461,15 +461,8 @@ def _low_level_execute_command(self, cmd, sudoable=True, in_data=None,
461461
# which is required by Ansible's discover_interpreter function
462462
if self._mitogen_discovering_interpreter:
463463
possible_pythons = [
464-
'/usr/bin/python',
465464
'python3',
466-
'python3.7',
467-
'python3.6',
468-
'python3.5',
469-
'python2.7',
470-
'python2.6',
471-
'/usr/libexec/platform-python',
472-
'/usr/bin/python3',
465+
'python2',
473466
'python'
474467
]
475468
else:

ansible_mitogen/transport_config.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,9 @@ def run_interpreter_discovery_if_necessary(s, task_vars, action, rediscover_pyth
107107
# blow away the discovered_interpreter_config cache and rediscover
108108
del task_vars['ansible_facts'][discovered_interpreter_config]
109109

110-
if discovered_interpreter_config not in task_vars['ansible_facts']:
110+
try:
111+
s = task_vars['ansible_facts'][discovered_interpreter_config]
112+
except KeyError:
111113
action._mitogen_discovering_interpreter = True
112114
# fake pipelining so discover_interpreter can be happy
113115
action._connection.has_pipelining = True
@@ -121,8 +123,6 @@ def run_interpreter_discovery_if_necessary(s, task_vars, action, rediscover_pyth
121123
# cache discovered interpreter
122124
task_vars['ansible_facts'][discovered_interpreter_config] = s
123125
action._connection.has_pipelining = False
124-
else:
125-
s = task_vars['ansible_facts'][discovered_interpreter_config]
126126

127127
# propagate discovered interpreter as fact
128128
action._discovered_interpreter_key = discovered_interpreter_config
@@ -140,13 +140,11 @@ def parse_python_path(s, task_vars, action, rediscover_python):
140140
discovery value in `facts_from_task_vars` like how Ansible handles this.
141141
"""
142142
if not s:
143-
# if python_path doesn't exist, default to `auto` and attempt to discover it
144-
s = 'auto'
143+
raise ValueError("Expected Python path or discovery mode, got: %r", s)
145144

146145
s = run_interpreter_discovery_if_necessary(s, task_vars, action, rediscover_python)
147-
# if unable to determine python_path, fallback to '/usr/bin/python'
148146
if not s:
149-
s = '/usr/bin/python'
147+
raise ValueError("Interpreter discovery failed, got: %r", s)
150148

151149
return ansible.utils.shlex.shlex_split(s)
152150

0 commit comments

Comments
 (0)