Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
moreati committed Jan 23, 2025
1 parent fca7578 commit 932fc20
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 15 deletions.
9 changes: 1 addition & 8 deletions ansible_mitogen/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,15 +461,8 @@ def _low_level_execute_command(self, cmd, sudoable=True, in_data=None,
# which is required by Ansible's discover_interpreter function
if self._mitogen_discovering_interpreter:
possible_pythons = [
'/usr/bin/python',
'python3',
'python3.7',
'python3.6',
'python3.5',
'python2.7',
'python2.6',
'/usr/libexec/platform-python',
'/usr/bin/python3',
'python2',
'python'
]
else:
Expand Down
12 changes: 5 additions & 7 deletions ansible_mitogen/transport_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@ def run_interpreter_discovery_if_necessary(s, task_vars, action, rediscover_pyth
# blow away the discovered_interpreter_config cache and rediscover
del task_vars['ansible_facts'][discovered_interpreter_config]

if discovered_interpreter_config not in task_vars['ansible_facts']:
try:
s = task_vars['ansible_facts'][discovered_interpreter_config]
except KeyError:
action._mitogen_discovering_interpreter = True
# fake pipelining so discover_interpreter can be happy
action._connection.has_pipelining = True
Expand All @@ -121,8 +123,6 @@ def run_interpreter_discovery_if_necessary(s, task_vars, action, rediscover_pyth
# cache discovered interpreter
task_vars['ansible_facts'][discovered_interpreter_config] = s
action._connection.has_pipelining = False
else:
s = task_vars['ansible_facts'][discovered_interpreter_config]

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

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

return ansible.utils.shlex.shlex_split(s)

Expand Down

0 comments on commit 932fc20

Please sign in to comment.