mirror of
https://github.com/valitydev/salt.git
synced 2024-11-06 16:45:27 +00:00
Merge pull request #40094 from twangboy/win_fix_testing
Fix problems with the test suite on Py3
This commit is contained in:
commit
8f462b6331
@ -87,6 +87,7 @@ import salt.utils
|
||||
import tempfile
|
||||
import salt.utils.locales
|
||||
import salt.utils.url
|
||||
import salt.ext.six as six
|
||||
from salt.ext.six import string_types, iteritems
|
||||
from salt.exceptions import CommandExecutionError, CommandNotFoundError
|
||||
|
||||
@ -119,17 +120,20 @@ def _get_pip_bin(bin_env):
|
||||
'''
|
||||
if not bin_env:
|
||||
which_result = __salt__['cmd.which_bin'](['pip', 'pip2', 'pip3', 'pip-python'])
|
||||
if salt.utils.is_windows() and six.PY2:
|
||||
which_result.encode('string-escape')
|
||||
if which_result is None:
|
||||
raise CommandNotFoundError('Could not find a `pip` binary')
|
||||
if salt.utils.is_windows():
|
||||
return which_result.encode('string-escape')
|
||||
return which_result
|
||||
|
||||
# try to get pip bin from virtualenv, bin_env
|
||||
if os.path.isdir(bin_env):
|
||||
if salt.utils.is_windows():
|
||||
pip_bin = os.path.join(
|
||||
bin_env, 'Scripts', 'pip.exe').encode('string-escape')
|
||||
if six.PY2:
|
||||
pip_bin = os.path.join(
|
||||
bin_env, 'Scripts', 'pip.exe').encode('string-escape')
|
||||
else:
|
||||
pip_bin = os.path.join(bin_env, 'Scripts', 'pip.exe')
|
||||
else:
|
||||
pip_bin = os.path.join(bin_env, 'bin', 'pip')
|
||||
if os.path.isfile(pip_bin):
|
||||
|
@ -287,6 +287,7 @@ from salt.exceptions import CommandExecutionError, SaltInvocationError
|
||||
|
||||
if salt.utils.is_windows():
|
||||
import salt.utils.win_dacl
|
||||
import salt.utils.win_functions
|
||||
|
||||
# Import 3rd-party libs
|
||||
import salt.ext.six as six
|
||||
@ -2598,7 +2599,7 @@ def directory(name,
|
||||
|
||||
# If win_owner not passed, use user
|
||||
if win_owner is None:
|
||||
win_owner = user if user else None
|
||||
win_owner = user if user else salt.utils.win_functions.get_current_user()
|
||||
|
||||
# Group isn't relevant to Windows, use win_perms/win_deny_perms
|
||||
if group is not None:
|
||||
|
@ -913,7 +913,7 @@ def dacl(obj_name=None, obj_type='file'):
|
||||
self.ace_perms[obj_type]['advanced'][perm])
|
||||
|
||||
# If still nothing, it must be undefined
|
||||
if not ace_perms[0]:
|
||||
if not ace_perms:
|
||||
ace_perms = ['Undefined Permission: {0}'.format(ace[1])]
|
||||
|
||||
return principal, ace_type, ace_prop, ace_perms, inherited
|
||||
@ -1035,6 +1035,10 @@ def get_sid(principal):
|
||||
# Verify that the sid is valid
|
||||
salt.utils.win_dacl.get_sid('S-1-5-32-544')
|
||||
'''
|
||||
# If None is passed, use the Universal Well-known SID "Null SID"
|
||||
if principal is None:
|
||||
principal = 'NULL SID'
|
||||
|
||||
# Test if the user passed a sid or a name
|
||||
try:
|
||||
sid = salt.utils.win_functions.get_sid_from_name(principal)
|
||||
@ -1074,6 +1078,10 @@ def get_sid_string(principal):
|
||||
# Get the string version of the SID
|
||||
salt.utils.win_dacl.get_sid_string(py_sid)
|
||||
'''
|
||||
# If None is passed, use the Universal Well-known SID "Null SID"
|
||||
if principal is None:
|
||||
principal = 'NULL SID'
|
||||
|
||||
try:
|
||||
return win32security.ConvertSidToStringSid(principal)
|
||||
except TypeError:
|
||||
@ -1104,6 +1112,10 @@ def get_name(principal):
|
||||
salt.utils.win_dacl.get_name('S-1-5-32-544')
|
||||
salt.utils.win_dacl.get_name('adminisTrators')
|
||||
'''
|
||||
# If None is passed, use the Universal Well-known SID for "Null SID"
|
||||
if principal is None:
|
||||
principal = 'S-1-0-0'
|
||||
|
||||
# Assume PySID object
|
||||
sid_obj = principal
|
||||
|
||||
|
@ -100,6 +100,10 @@ def get_sid_from_name(name):
|
||||
Returns:
|
||||
str: The corresponding SID
|
||||
'''
|
||||
# If None is passed, use the Universal Well-known SID "Null SID"
|
||||
if name is None:
|
||||
name = 'NULL SID'
|
||||
|
||||
try:
|
||||
sid = win32security.LookupAccountName(None, name)[0]
|
||||
except pywintypes.error as exc:
|
||||
|
Loading…
Reference in New Issue
Block a user