From 9b7991cd45c96191a876e7441e70d5bd4dbe9aed Mon Sep 17 00:00:00 2001 From: David Wilson Date: Thu, 8 Mar 2018 20:22:08 +0545 Subject: [PATCH] issue #118: log exceptions for emulated commands, fix AttributeError in helpers.py Turns out Ansible can't be trusted to actually check the result dictionary everywhere it expects one, so put the real exception text into -vvv output too. --- ansible_mitogen/helpers.py | 2 +- ansible_mitogen/mixins.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ansible_mitogen/helpers.py b/ansible_mitogen/helpers.py index 2bd0b28c..25b091c8 100644 --- a/ansible_mitogen/helpers.py +++ b/ansible_mitogen/helpers.py @@ -289,7 +289,7 @@ def set_file_mode(path, spec): """ mode = os.stat(path).st_mode - if spec.is_digit(): + if spec.isdigit(): new_mode = int(spec, 8) else: new_mode = apply_mode_spec(spec, mode) diff --git a/ansible_mitogen/mixins.py b/ansible_mitogen/mixins.py index db7dac18..9aa133c4 100644 --- a/ansible_mitogen/mixins.py +++ b/ansible_mitogen/mixins.py @@ -28,6 +28,7 @@ from __future__ import absolute_import import commands +import logging import os import pwd import shutil @@ -52,6 +53,9 @@ import ansible_mitogen.helpers from ansible.module_utils._text import to_text +LOG = logging.getLogger(__name__) + + def get_command_module_name(module_name): """ Given the name of an Ansible command module, return its canonical module @@ -157,6 +161,7 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase): if stdout: dct['stdout'] = repr(rc) except mitogen.core.CallError: + LOG.exception('While emulating a shell command') dct['rc'] = 1 dct['stderr'] = traceback.format_exc()