Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filter out deprecation warnings for platform.dist in get_os_version and platform.linux_distribution in get_os_name #4175

Merged
merged 1 commit into from
Jan 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions easybuild/tools/systemtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import struct
import sys
import termios
import warnings
from ctypes.util import find_library
from socket import gethostname
from easybuild.tools.py2vs3 import subprocess_popen_text
Expand Down Expand Up @@ -734,7 +735,10 @@ def get_os_name():
if hasattr(platform, 'linux_distribution'):
# platform.linux_distribution is more useful, but only available since Python 2.6
# this allows to differentiate between Fedora, CentOS, RHEL and Scientific Linux (Rocks is just CentOS)
os_name = platform.linux_distribution()[0].strip()
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=PendingDeprecationWarning)
warnings.simplefilter("ignore", category=DeprecationWarning)
os_name = platform.linux_distribution()[0].strip()

# take into account that on some OSs, platform.distribution returns an empty string as OS name,
# for example on OpenSUSE Leap 15.2
Expand Down Expand Up @@ -771,7 +775,10 @@ def get_os_version():

# platform.dist was removed in Python 3.8
if hasattr(platform, 'dist'):
os_version = platform.dist()[1]
with warnings.catch_warnings():
warnings.simplefilter("ignore", category=PendingDeprecationWarning)
warnings.simplefilter("ignore", category=DeprecationWarning)
os_version = platform.dist()[1]

# take into account that on some OSs, platform.dist returns an empty string as OS version,
# for example on OpenSUSE Leap 15.2
Expand Down