Skip to content

Commit 5e1f8a4

Browse files
alikinsabadger
authored andcommittedDec 17, 2018
Bundle a copy of github.com/nir0s/distro/distro.py
Since the 'platform.dist()' and 'platform.linux_distribution()' methods will be removed from future versions of python, this provides an alternative to replace ansibles use of those methods. lib/ansible/module_utils/distro.py is a copy of https://github.com/nir0s/distro/blob/master/distro.py This module is originally from https://github.com/nir0s/distro and is license under the Apache License, Version 2.0.
1 parent 61a649c commit 5e1f8a4

File tree

4 files changed

+1484
-0
lines changed

4 files changed

+1484
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# (c) 2018 Toshio Kuratomi <tkuratomi@ansible.com>
2+
#
3+
# This file is part of Ansible
4+
#
5+
# Ansible is free software: you can redistribute it and/or modify
6+
# it under the terms of the GNU General Public License as published by
7+
# the Free Software Foundation, either version 3 of the License, or
8+
# (at your option) any later version.
9+
#
10+
# Ansible is distributed in the hope that it will be useful,
11+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13+
# GNU General Public License for more details.
14+
#
15+
# You should have received a copy of the GNU General Public License
16+
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
17+
18+
# Make coding more python3-ish
19+
from __future__ import (absolute_import, division, print_function)
20+
__metaclass__ = type
21+
22+
'''
23+
Compat distro library.
24+
'''
25+
# The following makes it easier for us to script updates of the bundled code
26+
_BUNDLED_METADATA = {"pypi_name": "distro", "version": "1.3.0"}
27+
28+
# The following additional changes have been made:
29+
# * The import of argparse has been moved to __main__ (py2.6 compat)
30+
# * A format string including {} has been changed to {0} (py2.6 compat)
31+
# * Port two calls from subprocess.check_output to subprocess.Popen().communicate()
32+
# (py2.6 compat)
33+
34+
35+
import sys
36+
37+
try:
38+
import distro as _system_distro
39+
except ImportError:
40+
_system_distro = None
41+
42+
if _system_distro:
43+
distro = _system_distro
44+
else:
45+
# Our bundled copy
46+
from ansible.module_utils.distro import _distro as distro
47+
sys.modules['ansible.module_utils.distro'] = distro

0 commit comments

Comments
 (0)
Please sign in to comment.