mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Silence linux_distribution deprecation warning
The salt master log is flooded with deprecation warnings: ``` Feb 07 10:45:34 debian salt-master[1657]: [WARNING ] /usr/lib/python3/dist-packages/salt/grains/core.py:1759: DeprecationWarning: dist() and linux_distribution() functions are deprecated in Python 3.5 Feb 07 10:45:34 debian salt-master[1657]: linux_distribution(supported_dists=_supported_dists)] Feb 07 10:45:34 debian salt-master[1657]: [WARNING ] /usr/lib/python3/dist-packages/salt/grains/core.py:1759: DeprecationWarning: dist() and linux_distribution() functions are deprecated in Python 3.5 ``` Since the import statement already falls back to use distro.linux_distribution, silence the deprecation warning. Bug-Debian: https://bugs.debian.org/921630 Signed-off-by: Benjamin Drung <benjamin.drung@cloud.ionos.com>
This commit is contained in:
parent
c6dfded555
commit
e1dcbb541e
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user