1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Merge pull request #14586 from sivel/python-facts

Add python info to facts
This commit is contained in:
Matt Martz 2016-02-23 11:31:06 -06:00
commit 27a55d3f33

View file

@ -44,6 +44,15 @@ try:
except ImportError:
HAVE_SELINUX=False
try:
# Check if we have SSLContext support
from ssl import create_default_context, SSLContext
del create_default_context
del SSLContext
HAS_SSLCONTEXT = True
except ImportError:
HAS_SSLCONTEXT = False
try:
import json
# Detect python-json which is incompatible and fallback to simplejson in
@ -166,6 +175,7 @@ class Facts(object):
self.get_local_facts()
self.get_env_facts()
self.get_dns_facts()
self.get_python_facts()
def populate(self):
return self.facts
@ -782,6 +792,22 @@ class Facts(object):
pass
return size_total, size_available
def get_python_facts(self):
self.facts['python'] = {
'version': {
'major': sys.version_info[0],
'minor': sys.version_info[1],
'micro': sys.version_info[2],
'releaselevel': sys.version_info[3],
'serial': sys.version_info[4]
},
'version_info': list(sys.version_info),
'executable': sys.executable,
'type': sys.subversion[0],
'has_sslcontext': HAS_SSLCONTEXT
}
class Hardware(Facts):
"""
This is a generic Hardware subclass of Facts. This should be further