Skip to content

Commit

Permalink
Distro is now a hard dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
s0undt3ch committed May 11, 2020
1 parent 45aaf1f commit 65aeff0
Show file tree
Hide file tree
Showing 23 changed files with 96 additions and 136 deletions.
3 changes: 2 additions & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,8 @@ allowed-3rd-party-modules=msgpack,
pytest,
setuptools,
pytestsalt,
saltfactories
saltfactories,
distro


[EXCEPTIONS]
Expand Down
1 change: 1 addition & 0 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def inner(fn, *iargs, **ikwargs): # pylint: disable=unused-argument
"Crypto.Random",
"Crypto.Signature",
"Crypto.Signature.PKCS1_v1_5",
"distro",
"M2Crypto",
"msgpack",
"yaml",
Expand Down
1 change: 1 addition & 0 deletions pkg/osx/req.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ cffi==1.12.2
CherryPy==17.4.1
click==7.0
cryptography==2.6.1
distro==1.5.0
gitpython==2.1.15
idna==2.8
ipaddress==1.0.22
Expand Down
4 changes: 2 additions & 2 deletions pkg/windows/req.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ certifi
cffi==1.12.2
CherryPy==17.4.1
cryptography==2.6.1
distro==1.4.0
distro==1.5.0
idna==2.8
ioloop==0.1a0
ipaddress==1.0.22
Expand All @@ -19,7 +19,7 @@ pyasn1==0.4.5
pycparser==2.19
pycryptodomex==3.9.7
pycurl==7.43.0.5
pymssql==2.1.4
pymssql==2.1.4 ; python_version < "3.8"
PyMySQL==0.9.3
pyopenssl==19.0.0
python-dateutil==2.8.0
Expand Down
4 changes: 1 addition & 3 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,4 @@ msgpack>=0.5,!=0.5.5,<1.0.0
PyYAML
MarkupSafe
requests>=1.0.0
# Requirements for Tornado 4.5.3 (vendored as salt.ext.tornado)
singledispatch==3.4.0.3; python_version < '3.4'
# Required by Tornado to handle threads stuff.
distro
1 change: 1 addition & 0 deletions requirements/static/py3.5/darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contextlib2==0.5.5 # via cherrypy
croniter==0.3.29
cryptography==2.6.1
distlib==0.3.0 # via virtualenv
distro==1.5.0
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
Expand Down
1 change: 1 addition & 0 deletions requirements/static/py3.5/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ cherrypy==17.3.0
contextlib2==0.5.5 # via cherrypy
croniter==0.3.29
cryptography==2.6.1 # via moto, paramiko, pyopenssl, vcert
distro==1.5.0
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
Expand Down
4 changes: 2 additions & 2 deletions requirements/static/py3.5/windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cherrypy==17.4.1
colorama==0.4.1 # via pytest
contextlib2==0.5.5 # via cherrypy
cryptography==2.6.1
distro==1.4.0
distro==1.5.0
dmidecode==0.9.0
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
Expand Down Expand Up @@ -73,7 +73,7 @@ pycryptodome==3.8.1 # via python-jose
pycryptodomex==3.9.7
pycurl==7.43.0.5
pygit2==0.28.2 ; python_version < "3.8"
pymssql==2.1.4
pymssql==2.1.4 ; python_version < "3.8"
pymysql==0.9.3
pyopenssl==19.0.0
pyparsing==2.4.5 # via packaging
Expand Down
1 change: 1 addition & 0 deletions requirements/static/py3.6/darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contextlib2==0.5.5 # via cherrypy
croniter==0.3.29
cryptography==2.6.1
distlib==0.3.0 # via virtualenv
distro==1.5.0
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
Expand Down
1 change: 1 addition & 0 deletions requirements/static/py3.6/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ cherrypy==17.3.0
contextlib2==0.5.5 # via cherrypy
croniter==0.3.29
cryptography==2.6.1 # via moto, paramiko, pyopenssl, vcert
distro==1.5.0
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
Expand Down
4 changes: 2 additions & 2 deletions requirements/static/py3.6/windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ cherrypy==17.4.1
colorama==0.4.1 # via pytest
contextlib2==0.5.5 # via cherrypy
cryptography==2.6.1
distro==1.4.0
distro==1.5.0
dmidecode==0.9.0
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
Expand Down Expand Up @@ -72,7 +72,7 @@ pycryptodome==3.8.1 # via python-jose
pycryptodomex==3.9.7
pycurl==7.43.0.5
pygit2==0.28.2 ; python_version < "3.8"
pymssql==2.1.4
pymssql==2.1.4 ; python_version < "3.8"
pymysql==0.9.3
pyopenssl==19.0.0
pyparsing==2.4.5 # via packaging
Expand Down
1 change: 1 addition & 0 deletions requirements/static/py3.7/darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contextlib2==0.5.5 # via cherrypy
croniter==0.3.29
cryptography==2.6.1
distlib==0.3.0 # via virtualenv
distro==1.5.0
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
Expand Down
1 change: 1 addition & 0 deletions requirements/static/py3.7/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ cherrypy==17.3.0
contextlib2==0.5.5 # via cherrypy
croniter==0.3.29
cryptography==2.6.1 # via moto, paramiko, pyopenssl, vcert
distro==1.5.0
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
Expand Down
4 changes: 2 additions & 2 deletions requirements/static/py3.7/windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ cherrypy==17.4.1
colorama==0.4.1 # via pytest
contextlib2==0.5.5 # via cherrypy
cryptography==2.6.1
distro==1.4.0
distro==1.5.0
dmidecode==0.9.0
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
Expand Down Expand Up @@ -71,7 +71,7 @@ pycryptodome==3.8.1 # via python-jose
pycryptodomex==3.9.7
pycurl==7.43.0.5
pygit2==0.28.2 ; python_version < "3.8"
pymssql==2.1.4
pymssql==2.1.4 ; python_version < "3.8"
pymysql==0.9.3
pyopenssl==19.0.0
pyparsing==2.4.5 # via packaging
Expand Down
1 change: 1 addition & 0 deletions requirements/static/py3.8/darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contextlib2==0.5.5 # via cherrypy
croniter==0.3.29
cryptography==2.6.1
distlib==0.3.0 # via virtualenv
distro==1.5.0
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
Expand Down
1 change: 1 addition & 0 deletions requirements/static/py3.8/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cherrypy==17.3.0
contextlib2==0.5.5 # via cherrypy
croniter==0.3.29
cryptography==2.6.1 # via moto, paramiko, pyopenssl, vcert
distro==1.5.0
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
Expand Down
1 change: 1 addition & 0 deletions requirements/static/py3.9/darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ contextlib2==0.5.5 # via cherrypy
croniter==0.3.29
cryptography==2.6.1
distlib==0.3.0 # via virtualenv
distro==1.5.0
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
Expand Down
1 change: 1 addition & 0 deletions requirements/static/py3.9/linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ cherrypy==17.3.0
contextlib2==0.5.5 # via cherrypy
croniter==0.3.29
cryptography==2.6.1 # via moto, paramiko, pyopenssl, vcert
distro==1.5.0
dnspython==1.16.0
docker-pycreds==0.4.0 # via docker
docker==3.7.2
Expand Down
74 changes: 17 additions & 57 deletions salt/grains/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
module can be overwritten just by returning dict keys with the same value
as those returned here
"""

# Import python libs
from __future__ import absolute_import, print_function, unicode_literals

import datetime
Expand All @@ -23,10 +21,8 @@
import sys
import time
import uuid
import warnings
from errno import EACCES, EPERM

# Import salt libs
import salt.exceptions
import salt.log

Expand All @@ -42,69 +38,23 @@
import salt.utils.pkg.rpm
import salt.utils.platform
import salt.utils.stringutils
from distro import linux_distribution
from salt.ext import six
from salt.ext.six.moves import range

# pylint: disable=import-error
try:
import dateutil.tz
import dateutil.tz # pylint: disable=import-error

_DATEUTIL_TZ = True
except ImportError:
_DATEUTIL_TZ = False

__proxyenabled__ = ["*"]
__FQDN__ = None

# linux_distribution deprecated in py3.7
try:
from platform import linux_distribution as _deprecated_linux_distribution

# Extend the default list of supported distros. This will be used for the
# /etc/DISTRO-release checking that is part of linux_distribution()
from platform import _supported_dists

_supported_dists += (
"arch",
"mageia",
"meego",
"vmware",
"bluewhite64",
"slamd64",
"ovs",
"system",
"mint",
"oracle",
"void",
)

def linux_distribution(**kwargs):
with warnings.catch_warnings():
warnings.simplefilter("ignore")
return _deprecated_linux_distribution(
supported_dists=_supported_dists, **kwargs
)


except ImportError:
from distro import linux_distribution


if salt.utils.platform.is_windows():
import salt.utils.win_osinfo


__salt__ = {
"cmd.run": salt.modules.cmdmod._run_quiet,
"cmd.retcode": salt.modules.cmdmod._retcode_quiet,
"cmd.run_all": salt.modules.cmdmod._run_all_quiet,
"smbios.records": salt.modules.smbios.records,
"smbios.get": salt.modules.smbios.get,
}
log = logging.getLogger(__name__)

HAS_WMI = False
if salt.utils.platform.is_windows():
import salt.utils.win_osinfo

# attempt to import the python wmi module
# the Windows minion uses WMI for some of its grains
try:
Expand All @@ -119,9 +69,19 @@ def linux_distribution(**kwargs):
"Unable to import Python wmi module, some core grains " "will be missing"
)

HAS_UNAME = True
if not hasattr(os, "uname"):
HAS_UNAME = False

__proxyenabled__ = ["*"]
__FQDN__ = None

__salt__ = {
"cmd.run": salt.modules.cmdmod._run_quiet,
"cmd.retcode": salt.modules.cmdmod._retcode_quiet,
"cmd.run_all": salt.modules.cmdmod._run_all_quiet,
"smbios.records": salt.modules.smbios.records,
"smbios.get": salt.modules.smbios.get,
}

HAS_UNAME = hasattr(os, "uname")

_INTERFACES = {}

Expand Down
17 changes: 1 addition & 16 deletions salt/utils/platform.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,15 @@
"""
Functions for identifying which platform a machine is
"""
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals

import os
import subprocess
import sys
import warnings

# Import Salt libs
from distro import linux_distribution
from salt.utils.decorators import memoize as real_memoize

# linux_distribution deprecated in py3.7
try:
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


@real_memoize
def is_windows():
Expand Down
10 changes: 4 additions & 6 deletions salt/utils/thin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"""
Generate the salt thin tarball from the installed python files
"""

# Import python libs
from __future__ import absolute_import, print_function, unicode_literals

import copy
Expand All @@ -16,11 +14,9 @@
import tempfile
import zipfile

# Import third party libs
import distro
import jinja2
import msgpack

# Import salt libs
import salt
import salt.exceptions
import salt.ext.six as _six
Expand Down Expand Up @@ -195,6 +191,7 @@ def get_tops_python(py_ver, exclude=None):
"""
files = {}
for mod in [
"distro",
"jinja2",
"yaml",
"tornado",
Expand Down Expand Up @@ -245,7 +242,7 @@ def get_ext_tops(config):
"""
config = copy.deepcopy(config)
alternatives = {}
required = ["jinja2", "yaml", "tornado", "msgpack"]
required = ["jinja2", "yaml", "tornado", "msgpack", "distro"]
tops = []
for ns, cfg in salt.ext.six.iteritems(config or {}):
alternatives[ns] = cfg
Expand Down Expand Up @@ -336,6 +333,7 @@ def get_tops(extra_mods="", so_mods=""):
tops = []
for mod in [
salt,
distro,
jinja2,
yaml,
tornado,
Expand Down
Loading

0 comments on commit 65aeff0

Please sign in to comment.