File: connection_passthrough.py

package info (click to toggle)
python-mitogen 0.3.26-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,456 kB
  • sloc: python: 22,134; sh: 183; makefile: 74; perl: 19; ansic: 18
file content (25 lines) | stat: -rw-r--r-- 722 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import traceback

from ansible.plugins.action import ActionBase


class ActionModule(ActionBase):
    def run(self, tmp=None, task_vars=None):
        try:
            method = getattr(self._connection, self._task.args['method'])
            args = tuple(self._task.args.get('args', ()))
            kwargs = self._task.args.get('kwargs', {})

            return {
                'changed': False,
                'failed': False,
                'result': method(*args, **kwargs)
            }
        except Exception as e:
            traceback.print_exc()
            return {
                'changed': False,
                'failed': True,
                'msg': str(e),
                'result': e,
            }