Make AnsibleActionDone a private exception

We're going to remove this in the future so mark it private so people
are less likely to use it.
This commit is contained in:
Toshio Kuratomi 2018-01-22 17:44:22 -08:00
parent ca8e4c806a
commit 32eef49062
4 changed files with 8 additions and 7 deletions

View file

@ -254,6 +254,7 @@ class AnsibleFileNotFound(AnsibleRuntimeError):
# These Exceptions are temporary, using them as flow control until we can get a better solution.
# DO NOT USE as they will probably be removed soon.
# We will port the action modules in our tree to use a context manager instead.
class AnsibleAction(AnsibleRuntimeError):
''' Base Exception for Action plugin flow control '''
@ -284,6 +285,6 @@ class AnsibleActionFail(AnsibleAction):
self.result.update({'failed': True, 'msg': message})
class AnsibleActionDone(AnsibleAction):
class _AnsibleActionDone(AnsibleAction):
''' an action runtime early exit'''
pass

View file

@ -26,7 +26,7 @@ import re
import tempfile
from ansible import constants as C
from ansible.errors import AnsibleError, AnsibleAction, AnsibleActionDone, AnsibleActionFail
from ansible.errors import AnsibleError, AnsibleAction, _AnsibleActionDone, AnsibleActionFail
from ansible.module_utils._text import to_native, to_text
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.plugins.action import ActionBase
@ -105,7 +105,7 @@ class ActionModule(ActionBase):
if boolean(remote_src, strict=False):
result.update(self._execute_module(tmp=tmp, task_vars=task_vars))
raise AnsibleActionDone()
raise _AnsibleActionDone()
else:
try:
src = self._find_needle('files', src)

View file

@ -20,7 +20,7 @@ __metaclass__ = type
import os
from ansible.errors import AnsibleError, AnsibleAction, AnsibleActionDone, AnsibleActionFail
from ansible.errors import AnsibleError, AnsibleAction, _AnsibleActionDone, AnsibleActionFail
from ansible.module_utils._text import to_native
from ansible.module_utils.parsing.convert_bool import boolean
from ansible.plugins.action import ActionBase
@ -47,7 +47,7 @@ class ActionModule(ActionBase):
elif remote_src:
# everything is remote, so we just execute the module
# without changing any of the module arguments
raise AnsibleActionDone(result=self._execute_module(task_vars=task_vars))
raise _AnsibleActionDone(result=self._execute_module(task_vars=task_vars))
try:
src = self._find_needle('files', src)

View file

@ -21,7 +21,7 @@ import os
import re
import shlex
from ansible.errors import AnsibleError, AnsibleAction, AnsibleActionDone, AnsibleActionFail, AnsibleActionSkip
from ansible.errors import AnsibleError, AnsibleAction, _AnsibleActionDone, AnsibleActionFail, AnsibleActionSkip
from ansible.module_utils._text import to_bytes, to_native, to_text
from ansible.plugins.action import ActionBase
from ansible.plugins.shell.powershell import exec_wrapper
@ -112,7 +112,7 @@ class ActionModule(ActionBase):
script_cmd = ' '.join([env_string, target_command])
if self._play_context.check_mode:
raise AnsibleActionDone()
raise _AnsibleActionDone()
script_cmd = self._connection._shell.wrap_for_exec(script_cmd)