issue #106: working/semantically compatible binary support.

pull/193/head
David Wilson 8 years ago
parent 23366b4580
commit df6daaf3c4

@ -94,7 +94,7 @@ def run_module(kwargs):
runner_name = kwargs.pop('runner_name') runner_name = kwargs.pop('runner_name')
klass = getattr(ansible_mitogen.runner, runner_name) klass = getattr(ansible_mitogen.runner, runner_name)
impl = klass(**kwargs) impl = klass(**kwargs)
return json.dumps(impl.run()) return impl.run()
def _async_main(job_id, runner_name, kwargs): def _async_main(job_id, runner_name, kwargs):

@ -315,18 +315,22 @@ class ActionModuleMixin(ansible.plugins.action.ActionBase):
) )
) )
def _postprocess_response(self, js): def _postprocess_response(self, result):
""" """
Apply fixups mimicking ActionBase._execute_module(); this is copied Apply fixups mimicking ActionBase._execute_module(); this is copied
verbatim from action/__init__.py, the guts of _parse_returned_data are verbatim from action/__init__.py, the guts of _parse_returned_data are
garbage and should be removed or reimplemented once tests exist. garbage and should be removed or reimplemented once tests exist.
:param dict result:
Dictionary with format::
{
"rc": int,
"stdout": "stdout data",
"stderr": "stderr data"
}
""" """
data = self._parse_returned_data({ data = self._parse_returned_data(result)
'rc': 0,
'stdout': js,
'stdout_lines': [js],
'stderr': ''
})
# Cutpasted from the base implementation. # Cutpasted from the base implementation.
if 'stdout' in data and 'stdout_lines' not in data: if 'stdout' in data and 'stdout_lines' not in data:

@ -87,6 +87,16 @@ class Runner(object):
self._env.revert() self._env.revert()
def _run(self): def _run(self):
"""
The _run() method is expected to return a dictionary in the form of
ActionBase._low_level_execute_command() output, i.e. having::
{
"rc": int,
"stdout": "stdout data",
"stderr": "stderr data"
}
"""
raise NotImplementedError() raise NotImplementedError()
def run(self): def run(self):
@ -224,11 +234,16 @@ class NativeRunner(Runner):
# to invoke main explicitly. # to invoke main explicitly.
mod.main() mod.main()
except NativeModuleExit, e: except NativeModuleExit, e:
return e.dct return {
'rc': 0,
'stdout': json.dumps(e.dct),
'stderr': '',
}
return { return {
'failed': True, 'rc': 1,
'msg': 'ansible_mitogen: module did not exit normally.' 'stdout': '',
'stderr': 'ansible_mitogen: module did not exit normally.',
} }
@ -299,8 +314,9 @@ class BinaryRunner(Runner):
) )
except Exception, e: except Exception, e:
return { return {
'failed': True, 'rc': 1,
'msg': '%s: %s' % (type(e), e), 'stdout': '',
'stderr': '%s: %s' % (type(e), e),
} }
return { return {

Loading…
Cancel
Save