File: custom_python_detect_environment.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 (50 lines) | stat: -rw-r--r-- 1,416 bytes parent folder | download | duplicates (2)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/python
# I am an Ansible new-style Python module. I return details about the Python
# interpreter I run within.

from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.basic import get_module_path

import os
import pwd
import socket
import sys


def main():
    module = AnsibleModule(argument_spec={})
    module.exit_json(
        fs={
            '/tmp': {
                'resolved': os.path.realpath('/tmp'),
            },
        },
        python={
            'version': {
                'full': '%i.%i.%i' % sys.version_info[:3],
                'info': list(sys.version_info),
                'major': sys.version_info[0],
                'minor': sys.version_info[1],
                'patch': sys.version_info[2],
            },
        },
        argv=sys.argv,
        __file__=__file__,
        argv_types_correct=all(type(s) is str for s in sys.argv),
        env=dict(os.environ),
        cwd=os.getcwd(),
        python_path=sys.path,
        pid=os.getpid(),
        ppid=os.getppid(),
        uid=os.getuid(),
        euid=os.geteuid(),
        sys_executable=sys.executable,
        mitogen_loaded='mitogen.core' in sys.modules,
        hostname=socket.gethostname(),
        username=pwd.getpwuid(os.getuid()).pw_name,
        module_tmpdir=getattr(module, 'tmpdir', None),
        module_path=get_module_path(),
    )

if __name__ == '__main__':
    main()