sb/linux.py: Workaround for Python >= 3.8

The platform.dist() interface has been deprecated since Python 3.5, and
has been removed in Python 3.8.

Fixes:
Traceback (most recent call last):
  File "/home/anders/work/rtems/rsb/source-builder/sb/options.py", line 682, in load
    overrides = linux.load()
  File "/home/anders/work/rtems/rsb/source-builder/sb/linux.py", line 60, in load
    distro = platform.dist()[0]
AttributeError: module 'platform' has no attribute 'dist'

Signed-off-by: Anders Montonen <Anders.Montonen@iki.fi>
This commit is contained in:
Anders Montonen 2020-04-27 22:15:27 +03:00 committed by Chris Johns
parent 0c7965c093
commit ae9faa2726

View File

@ -55,6 +55,8 @@ def load():
'__tar': ('exe', 'required', '/bin/tar') '__tar': ('exe', 'required', '/bin/tar')
} }
# platform.dist() was removed in Python 3.8
if hasattr(platform, 'dist'):
# Works for LSB distros # Works for LSB distros
try: try:
distro = platform.dist()[0] distro = platform.dist()[0]
@ -62,6 +64,8 @@ def load():
except ValueError: except ValueError:
# Non LSB distro found, use failover" # Non LSB distro found, use failover"
pass pass
else:
distro = ''
# Non LSB - fail over to issue # Non LSB - fail over to issue
if distro == '': if distro == '':