From 07c1a5c9db6bbb03602d9762004fd58f7b85e341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodolfo=20Garc=C3=ADa=20Pe=C3=B1as=20=28kix=29?= Date: Sun, 25 Oct 2020 16:38:16 +0100 Subject: [PATCH] Deprecated linux_distribution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The call from platform.linux_distribution was depdrecated in Python 3.7. This patch solves this problem, using the recomended package distro. Signed-off-by: Rodolfo García Peñas (kix) --- offlineimap/utils/distro_utils.py | 8 +++++++- requirements.txt | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/offlineimap/utils/distro_utils.py b/offlineimap/utils/distro_utils.py index 8146211..4a26da7 100644 --- a/offlineimap/utils/distro_utils.py +++ b/offlineimap/utils/distro_utils.py @@ -5,6 +5,12 @@ import platform import os +# linux_distribution deprecated in Python 3.7 +try: + from platform import linux_distribution +except ImportError: + from distro import linux_distribution + # Each dictionary value is either string or some iterable. # # For the former we will just return the value, for an iterable @@ -45,7 +51,7 @@ def get_os_name(): os_name = platform.system().lower() if os_name.startswith('linux'): - distro_name = platform.linux_distribution()[0] + distro_name = linux_distribution()[0] if distro_name: os_name = os_name + "-%s" % distro_name.split()[0].lower() if os.path.exists('/etc/arch-release'): diff --git a/requirements.txt b/requirements.txt index 9d575fb..f543c51 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ gssapi[kerberos] portalocker[cygwin] rfc6555 +distro