Update bundled version of distro from 1.4.0 to 1.5.0 (#69709)
Includes changes we made in our version that were merged upstream ci_complete
This commit is contained in:
parent
86f1cba3a6
commit
8dd0356719
3 changed files with 33 additions and 33 deletions
2
changelogs/fragments/distro-update-version.yml
Normal file
2
changelogs/fragments/distro-update-version.yml
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- distro - Update bundled version of distro from 1.4.0 to 1.5.0
|
|
@ -23,13 +23,12 @@ __metaclass__ = type
|
||||||
Compat distro library.
|
Compat distro library.
|
||||||
'''
|
'''
|
||||||
# The following makes it easier for us to script updates of the bundled code
|
# The following makes it easier for us to script updates of the bundled code
|
||||||
_BUNDLED_METADATA = {"pypi_name": "distro", "version": "1.4.0"}
|
_BUNDLED_METADATA = {"pypi_name": "distro", "version": "1.5.0"}
|
||||||
|
|
||||||
# The following additional changes have been made:
|
# The following additional changes have been made:
|
||||||
# * The import of argparse has been moved to __main__ (py2.6 compat)
|
# * Remove optparse since it is not needed for our use.
|
||||||
# * A format string including {} has been changed to {0} (py2.6 compat)
|
# * A format string including {} has been changed to {0} (py2.6 compat)
|
||||||
# * Port two calls from subprocess.check_output to subprocess.Popen().communicate()
|
# * Port two calls from subprocess.check_output to subprocess.Popen().communicate() (py2.6 compat)
|
||||||
# (py2.6 compat)
|
|
||||||
|
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
|
@ -35,10 +35,8 @@ more information.
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import json
|
|
||||||
import shlex
|
import shlex
|
||||||
import logging
|
import logging
|
||||||
import optparse
|
|
||||||
import subprocess
|
import subprocess
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +51,7 @@ _OS_RELEASE_BASENAME = 'os-release'
|
||||||
#:
|
#:
|
||||||
#: * Value: Normalized value.
|
#: * Value: Normalized value.
|
||||||
NORMALIZED_OS_ID = {
|
NORMALIZED_OS_ID = {
|
||||||
'ol': 'oracle', # Oracle Enterprise Linux
|
'ol': 'oracle', # Oracle Linux
|
||||||
}
|
}
|
||||||
|
|
||||||
#: Translation table for normalizing the "Distributor ID" attribute returned by
|
#: Translation table for normalizing the "Distributor ID" attribute returned by
|
||||||
|
@ -64,9 +62,11 @@ NORMALIZED_OS_ID = {
|
||||||
#:
|
#:
|
||||||
#: * Value: Normalized value.
|
#: * Value: Normalized value.
|
||||||
NORMALIZED_LSB_ID = {
|
NORMALIZED_LSB_ID = {
|
||||||
'enterpriseenterprise': 'oracle', # Oracle Enterprise Linux
|
'enterpriseenterpriseas': 'oracle', # Oracle Enterprise Linux 4
|
||||||
|
'enterpriseenterpriseserver': 'oracle', # Oracle Linux 5
|
||||||
'redhatenterpriseworkstation': 'rhel', # RHEL 6, 7 Workstation
|
'redhatenterpriseworkstation': 'rhel', # RHEL 6, 7 Workstation
|
||||||
'redhatenterpriseserver': 'rhel', # RHEL 6, 7 Server
|
'redhatenterpriseserver': 'rhel', # RHEL 6, 7 Server
|
||||||
|
'redhatenterprisecomputenode': 'rhel', # RHEL 6 ComputeNode
|
||||||
}
|
}
|
||||||
|
|
||||||
#: Translation table for normalizing the distro ID derived from the file name
|
#: Translation table for normalizing the distro ID derived from the file name
|
||||||
|
@ -95,8 +95,7 @@ _DISTRO_RELEASE_IGNORE_BASENAMES = (
|
||||||
'oem-release',
|
'oem-release',
|
||||||
_OS_RELEASE_BASENAME,
|
_OS_RELEASE_BASENAME,
|
||||||
'system-release',
|
'system-release',
|
||||||
# Fixed in upstream via https://github.com/nir0s/distro/pull/246
|
'plesk-release',
|
||||||
'plesk-release'
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -219,6 +218,7 @@ def id():
|
||||||
"openbsd" OpenBSD
|
"openbsd" OpenBSD
|
||||||
"netbsd" NetBSD
|
"netbsd" NetBSD
|
||||||
"freebsd" FreeBSD
|
"freebsd" FreeBSD
|
||||||
|
"midnightbsd" MidnightBSD
|
||||||
============== =========================================
|
============== =========================================
|
||||||
|
|
||||||
If you have a need to get distros for reliable IDs added into this set,
|
If you have a need to get distros for reliable IDs added into this set,
|
||||||
|
@ -665,7 +665,7 @@ class LinuxDistribution(object):
|
||||||
distro release file can be found, the data source for the distro
|
distro release file can be found, the data source for the distro
|
||||||
release file will be empty.
|
release file will be empty.
|
||||||
|
|
||||||
* ``include_name`` (bool): Controls whether uname command output is
|
* ``include_uname`` (bool): Controls whether uname command output is
|
||||||
included as a data source. If the uname command is not available in
|
included as a data source. If the uname command is not available in
|
||||||
the program execution path the data source for the uname command will
|
the program execution path the data source for the uname command will
|
||||||
be empty.
|
be empty.
|
||||||
|
@ -1023,8 +1023,6 @@ class LinuxDistribution(object):
|
||||||
# * commands or their arguments (not allowed in os-release)
|
# * commands or their arguments (not allowed in os-release)
|
||||||
if '=' in token:
|
if '=' in token:
|
||||||
k, v = token.split('=', 1)
|
k, v = token.split('=', 1)
|
||||||
if isinstance(v, bytes):
|
|
||||||
v = v.decode('utf-8')
|
|
||||||
props[k.lower()] = v
|
props[k.lower()] = v
|
||||||
else:
|
else:
|
||||||
# Ignore any tokens that are not variable assignments
|
# Ignore any tokens that are not variable assignments
|
||||||
|
@ -1068,7 +1066,7 @@ class LinuxDistribution(object):
|
||||||
stdout = _check_output(cmd, stderr=devnull)
|
stdout = _check_output(cmd, stderr=devnull)
|
||||||
except OSError: # Command not found
|
except OSError: # Command not found
|
||||||
return {}
|
return {}
|
||||||
content = stdout.decode(sys.getfilesystemencoding()).splitlines()
|
content = self._to_str(stdout).splitlines()
|
||||||
return self._parse_lsb_release_content(content)
|
return self._parse_lsb_release_content(content)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -1103,7 +1101,7 @@ class LinuxDistribution(object):
|
||||||
stdout = _check_output(cmd, stderr=devnull)
|
stdout = _check_output(cmd, stderr=devnull)
|
||||||
except OSError:
|
except OSError:
|
||||||
return {}
|
return {}
|
||||||
content = stdout.decode(sys.getfilesystemencoding()).splitlines()
|
content = self._to_str(stdout).splitlines()
|
||||||
return self._parse_uname_content(content)
|
return self._parse_uname_content(content)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -1123,6 +1121,20 @@ class LinuxDistribution(object):
|
||||||
props['release'] = version
|
props['release'] = version
|
||||||
return props
|
return props
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _to_str(text):
|
||||||
|
encoding = sys.getfilesystemencoding()
|
||||||
|
encoding = 'utf-8' if encoding == 'ascii' else encoding
|
||||||
|
|
||||||
|
if sys.version_info[0] >= 3:
|
||||||
|
if isinstance(text, bytes):
|
||||||
|
return text.decode(encoding)
|
||||||
|
else:
|
||||||
|
if isinstance(text, unicode): # noqa pylint: disable=undefined-variable
|
||||||
|
return text.encode(encoding)
|
||||||
|
|
||||||
|
return text
|
||||||
|
|
||||||
@cached_property
|
@cached_property
|
||||||
def _distro_release_info(self):
|
def _distro_release_info(self):
|
||||||
"""
|
"""
|
||||||
|
@ -1225,8 +1237,6 @@ class LinuxDistribution(object):
|
||||||
Returns:
|
Returns:
|
||||||
A dictionary containing all information items.
|
A dictionary containing all information items.
|
||||||
"""
|
"""
|
||||||
if isinstance(line, bytes):
|
|
||||||
line = line.decode('utf-8')
|
|
||||||
matches = _DISTRO_RELEASE_CONTENT_REVERSED_PATTERN.match(
|
matches = _DISTRO_RELEASE_CONTENT_REVERSED_PATTERN.match(
|
||||||
line.strip()[::-1])
|
line.strip()[::-1])
|
||||||
distro_info = {}
|
distro_info = {}
|
||||||
|
@ -1250,22 +1260,11 @@ def main():
|
||||||
logger.setLevel(logging.DEBUG)
|
logger.setLevel(logging.DEBUG)
|
||||||
logger.addHandler(logging.StreamHandler(sys.stdout))
|
logger.addHandler(logging.StreamHandler(sys.stdout))
|
||||||
|
|
||||||
parser = optparse.OptionParser(description="OS distro info tool")
|
logger.info('Name: %s', name(pretty=True))
|
||||||
parser.add_option(
|
distribution_version = version(pretty=True)
|
||||||
'--json',
|
logger.info('Version: %s', distribution_version)
|
||||||
'-j',
|
distribution_codename = codename()
|
||||||
help="Output in machine readable format",
|
logger.info('Codename: %s', distribution_codename)
|
||||||
action="store_true")
|
|
||||||
args, opts = parser.parse_args()
|
|
||||||
|
|
||||||
if args.json:
|
|
||||||
logger.info(json.dumps(info(), indent=4, sort_keys=True))
|
|
||||||
else:
|
|
||||||
logger.info('Name: %s', name(pretty=True))
|
|
||||||
distribution_version = version(pretty=True)
|
|
||||||
logger.info('Version: %s', distribution_version)
|
|
||||||
distribution_codename = codename()
|
|
||||||
logger.info('Codename: %s', distribution_codename)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in a new issue