File: mitogen_test_gethostbyname.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 (19 lines) | stat: -rw-r--r-- 475 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/usr/bin/python

# I am a module that indirectly depends on glibc cached /etc/resolv.conf state.

import socket
import sys

from ansible.module_utils.basic import AnsibleModule

def main():
    module = AnsibleModule(argument_spec={'name': {'type': 'str'}})
    try:
        module.exit_json(addr=socket.gethostbyname(module.params['name']))
    except socket.error:
        e = sys.exc_info()[1]
        module.fail_json(msg=str(e))

if __name__ == '__main__':
    main()