Update old utils paths with new utils paths

This commit is contained in:
rallytime 2018-05-07 13:36:47 -04:00
parent 786076ac03
commit 5565d5e9b1
No known key found for this signature in database
GPG Key ID: E8F1A4B90D0DEA19
7 changed files with 25 additions and 22 deletions

View File

@ -81,6 +81,7 @@ import logging
import os
import pkg_resources
import re
import shutil
import sys
import tempfile
@ -137,7 +138,7 @@ def _get_pip_bin(bin_env):
logger.debug('pip: Using pip from currently-running Python')
return [os.path.normpath(sys.executable), '-m', 'pip']
python_bin = 'python.exe' if salt.utils.is_windows() else 'python'
python_bin = 'python.exe' if salt.utils.platform.is_windows() else 'python'
def _search_paths(*basedirs):
ret = []
@ -314,7 +315,7 @@ def _process_requirements(requirements, cmd, cwd, saltenv, user):
__salt__['file.chown'](treq, user, None)
# In Windows, just being owner of a file isn't enough. You also
# need permissions
if salt.utils.is_windows():
if salt.utils.platform.is_windows():
__utils__['win_dacl.set_permissions'](
obj_name=treq,
principal=user,
@ -628,7 +629,7 @@ def install(pkgs=None, # pylint: disable=R0912,R0913,R0914
'''
if 'no_chown' in kwargs:
salt.utils.warn_until(
salt.utils.versions.warn_until(
'Flourine',
'The no_chown argument has been deprecated and is no longer used. '
'Its functionality was removed in Boron.')
@ -1252,7 +1253,7 @@ def list_upgrades(bin_env=None,
pip_version = version(bin_env)
# Pip started supporting the ability to output json starting with 9.0.0
if salt.utils.compare_versions(ver1=pip_version, oper='>=', ver2='9.0.0'):
if salt.utils.versions.compare(ver1=pip_version, oper='>=', ver2='9.0.0'):
cmd.extend(['--format', 'json'])
# If pip >= 9.0 use --format=json
@ -1274,14 +1275,14 @@ def list_upgrades(bin_env=None,
packages = {}
# Pip started supporting the ability to output json starting with 9.0.0
# Older versions will have to parse stdout
if salt.utils.compare_versions(ver1=pip_version, oper='<', ver2='9.0.0'):
if salt.utils.versions.compare(ver1=pip_version, oper='<', ver2='9.0.0'):
# Pip versions < 8.0.0 had a different output format
# Sample data:
# pip (Current: 7.1.2 Latest: 10.0.1 [wheel])
# psutil (Current: 5.2.2 Latest: 5.4.5 [wheel])
# pyasn1 (Current: 0.2.3 Latest: 0.4.2 [wheel])
# pycparser (Current: 2.17 Latest: 2.18 [sdist])
if salt.utils.compare_versions(ver1=pip_version, oper='<', ver2='8.0.0'):
if salt.utils.versions.compare(ver1=pip_version, oper='<', ver2='8.0.0'):
logger.debug('pip module: Old output format')
pat = re.compile(r'(\S*)\s+\(.*Latest:\s+(.*)\)')
@ -1427,7 +1428,7 @@ def upgrade(bin_env=None,
errors = False
for pkg in list_upgrades(bin_env=bin_env, user=user, cwd=cwd):
if pkg == 'salt':
if salt.utils.is_windows():
if salt.utils.platform.is_windows():
continue
result = __salt__['cmd.run_all'](cmd + [pkg], **cmd_kwargs)
if result['retcode'] != 0:

View File

@ -585,7 +585,7 @@ def installed(name,
.. _`virtualenv`: http://www.virtualenv.org/en/latest/
'''
if 'no_chown' in kwargs:
salt.utils.warn_until(
salt.utils.versions.warn_until(
'Flourine',
'The no_chown argument has been deprecated and is no longer used. '
'Its functionality was removed in Boron.')

View File

@ -136,7 +136,7 @@ def managed(name,
PATH_VAR: '/usr/local/bin/'
'''
if 'no_chown' in kwargs:
salt.utils.warn_until(
salt.utils.versions.warn_until(
'Flourine',
'The no_chown argument has been deprecated and is no longer used. '
'Its functionality was removed in Boron.')

View File

@ -23,6 +23,7 @@ from tests.support.helpers import skip_if_not_root
# Import salt libs
import salt.utils.files
import salt.utils.path
import salt.utils.platform
from salt.modules.virtualenv_mod import KNOWN_BINARY_NAMES
@ -76,7 +77,7 @@ class PipModuleTest(ModuleCase):
pip_bin = os.path.join(self.venv_dir, 'bin', 'pip')
py_dir = 'python{0}.{1}'.format(*sys.version_info[:2])
site_dir = os.path.join(self.venv_dir, 'lib', py_dir, 'site-packages')
if salt.utils.is_windows():
if salt.utils.platform.is_windows():
pip_bin = os.path.join(self.venv_dir, 'Scripts', 'pip.exe')
site_dir = os.path.join(self.venv_dir, 'lib', 'site-packages')
if not os.path.isfile(pip_bin):

View File

@ -37,6 +37,7 @@ from tests.support.unit import skipIf
# Import salt libs
import salt.utils.files
import salt.utils.path
import salt.utils.platform
import salt.utils.versions
import salt.utils.win_dacl
import salt.utils.win_functions
@ -127,7 +128,7 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
shutil.rmtree(venv_dir, ignore_errors=True)
@skipIf(six.PY3, 'Issue is specific to carbon module, which is PY2-only')
@skipIf(salt.utils.is_windows(), "Carbon does not install in Windows")
@skipIf(salt.utils.platform.is_windows(), "Carbon does not install in Windows")
@requires_system_grains
def test_pip_installed_weird_install(self, grains=None):
# First, check to see if this is running on CentOS 5 or MacOS.
@ -194,7 +195,7 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
)
pep8_bin = os.path.join(venv_dir, 'bin', 'pep8')
if salt.utils.is_windows():
if salt.utils.platform.is_windows():
pep8_bin = os.path.join(venv_dir, 'Scripts', 'pep8.exe')
try:
@ -220,7 +221,7 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
pip_bin = os.path.join(venv_dir, 'bin', 'pip')
py_dir = 'python{0}.{1}'.format(*sys.version_info[:2])
site_dir = os.path.join(venv_dir, 'lib', py_dir, 'site-packages')
if salt.utils.is_windows():
if salt.utils.platform.is_windows():
pip_bin = os.path.join(venv_dir, 'Scripts', 'pip.exe')
site_dir = os.path.join(venv_dir, 'lib', 'site-packages')
if not os.path.isfile(pip_bin):
@ -282,7 +283,7 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
# The virtual environment needs to be in a location that is accessible
# by both the user running the test and the runas user
if salt.utils.is_windows():
if salt.utils.platform.is_windows():
salt.utils.win_dacl.set_permissions(temp_dir, username, 'full_control')
else:
uid = self.run_function('file.user_to_uid', [username])
@ -310,7 +311,7 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
for path in glob.glob(globmatch):
if HAS_PWD:
self.assertEqual(uid, os.stat(path).st_uid)
elif salt.utils.is_windows():
elif salt.utils.platform.is_windows():
self.assertEqual(
salt.utils.win_dacl.get_owner(path), username)
@ -325,7 +326,7 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
# The virtual environment needs to be in a location that is accessible
# by both the user running the test and the runas user
if salt.utils.is_windows():
if salt.utils.platform.is_windows():
salt.utils.win_dacl.set_permissions(temp_dir, username, 'full_control')
else:
uid = self.run_function('file.user_to_uid', [username])
@ -360,7 +361,7 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
for path in glob.glob(globmatch):
if HAS_PWD:
self.assertEqual(uid, os.stat(path).st_uid)
elif salt.utils.is_windows():
elif salt.utils.platform.is_windows():
self.assertEqual(
salt.utils.win_dacl.get_owner(path), username)
@ -490,7 +491,7 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
)
false_cmd = '/bin/false'
if salt.utils.is_windows():
if salt.utils.platform.is_windows():
false_cmd = 'exit 1 >nul'
try:
ret = self.run_state(
@ -503,7 +504,7 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin):
shutil.rmtree(venv_dir, ignore_errors=True)
@skipIf(sys.version_info[:2] >= (3, 6), 'Old version of virtualenv too old for python3.6')
@skipIf(salt.utils.is_windows(), "Carbon does not install in Windows")
@skipIf(salt.utils.platform.is_windows(), "Carbon does not install in Windows")
def test_46127_pip_env_vars(self):
'''
Test that checks if env_vars passed to pip.installed are also passed

View File

@ -300,7 +300,7 @@ class PipTestCase(TestCase, LoaderModuleMockMixin):
mock_path.isdir.return_value = True
mock_path.join = join
if salt.utils.is_windows():
if salt.utils.platform.is_windows():
venv_path = 'C:\\test_env'
bin_path = os.path.join(venv_path, 'python.exe')
else:

View File

@ -17,7 +17,7 @@ from tests.support.mock import NO_MOCK, NO_MOCK_REASON, MagicMock, patch
# Import salt libs
import salt.states.pip_state as pip_state
import salt.utils
import salt.utils.versions
# Import 3rd-party libs
try:
@ -50,7 +50,7 @@ class PipStateTest(TestCase, SaltReturnAssertsMixin, LoaderModuleMockMixin):
with patch.dict(pip_state.__salt__, {'cmd.run_all': mock,
'pip.list': pip_list}):
with patch.dict(pip_state.__opts__, {'test': True}):
if salt.utils.compare_versions(ver1=pip_version,
if salt.utils.versions.compare(ver1=pip_version,
oper='<',
ver2='10.0'):
ret = pip_state.installed('pep8=1.3.2')