Debian Codegraph @

tests/ansible/lib/modules/custom_python_detect_environment.py

raw
1 #!/usr/bin/python
2 # I am an Ansible new-style Python module. I return details about the Python
3 # interpreter I run within.
4
5 from ansible.module_utils.basic import AnsibleModule
6 from ansible.module_utils.basic import get_module_path
7
8 import os
9 import pwd
10 import socket
11 import sys
12
13
14 def main():
15 module = AnsibleModule(argument_spec={})
16 module.exit_json(
17 fs={
18 '/tmp': {
19 'resolved': os.path.realpath('/tmp'),
20 },
21 },
22 python={
23 'version': {
24 'full': '%i.%i.%i' % sys.version_info[:3],
25 'info': list(sys.version_info),
26 'major': sys.version_info[0],
27 'minor': sys.version_info[1],
28 'patch': sys.version_info[2],
29 },
30 },
31 argv=sys.argv,
32 __file__=__file__,
33 argv_types_correct=all(type(s) is str for s in sys.argv),
34 env=dict(os.environ),
35 cwd=os.getcwd(),
36 python_path=sys.path,
37 pid=os.getpid(),
38 ppid=os.getppid(),
39 uid=os.getuid(),
40 euid=os.geteuid(),
41 sys_executable=sys.executable,
42 mitogen_loaded='mitogen.core' in sys.modules,
43 hostname=socket.gethostname(),
44 username=pwd.getpwuid(os.getuid()).pw_name,
45 module_tmpdir=getattr(module, 'tmpdir', None),
46 module_path=get_module_path(),
47 )
48
49 if __name__ == '__main__':
50 main()