Merge pull request #51541 from bdrung/silence-linux_distribution-deprecation-warning

Silence linux_distribution deprecation warning
This commit is contained in:
Daniel Wozniak 2019-02-12 21:18:01 -07:00 committed by GitHub
commit 231d6e2d39
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 2 deletions

View File

@ -22,6 +22,7 @@ import locale
import uuid
from errno import EACCES, EPERM
import datetime
import warnings
__proxyenabled__ = ['*']
__FQDN__ = None
@ -34,7 +35,12 @@ _supported_dists += ('arch', 'mageia', 'meego', 'vmware', 'bluewhite64',
# linux_distribution deprecated in py3.7
try:
from platform import linux_distribution
from platform import linux_distribution as _deprecated_linux_distribution
def linux_distribution(**kwargs):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
return _deprecated_linux_distribution(**kwargs)
except ImportError:
from distro import linux_distribution

View File

@ -8,10 +8,16 @@ from __future__ import absolute_import, print_function, unicode_literals
import re
import sys
import platform
import warnings
# linux_distribution deprecated in py3.7
try:
from platform import linux_distribution
from platform import linux_distribution as _deprecated_linux_distribution
def linux_distribution(**kwargs):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
return _deprecated_linux_distribution(**kwargs)
except ImportError:
from distro import linux_distribution