From 56fc7f6160dfe96a564e04f04e7aa2612c4fae5e Mon Sep 17 00:00:00 2001 From: James Page Date: Fri, 22 May 2020 07:49:19 +0100 Subject: [PATCH] Fix compatibility with Python 3.8 The deprecated platform.linux_distribution function was removed in Python 3.8 - fallback to using parse_os_release if the function is not found. Signed-off-by: James Page --- ceph_deploy/hosts/remotes.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ceph_deploy/hosts/remotes.py b/ceph_deploy/hosts/remotes.py index 72dd1f6..47dd0bf 100644 --- a/ceph_deploy/hosts/remotes.py +++ b/ceph_deploy/hosts/remotes.py @@ -13,8 +13,13 @@ import re def platform_information(_linux_distribution=None): """ detect platform information from remote host """ - linux_distribution = _linux_distribution or platform.linux_distribution - distro, release, codename = linux_distribution() + distro = release = codename = None + try: + linux_distribution = _linux_distribution or platform.linux_distribution + distro, release, codename = linux_distribution() + except AttributeError: + # NOTE: py38 does not have platform.linux_distribution + pass if not distro: distro, release, codename = parse_os_release() if not codename and 'debian' in distro.lower(): # this could be an empty string in Debian -- 2.47.3