Fix unit.test_spm for Windows

This only fixes the test... I don't think it fixes SPM on Windows
This commit is contained in:
twangboy 2017-08-31 17:10:38 -06:00
parent 4f023c4cb6
commit f36efbd6a7

View file

@ -14,9 +14,12 @@ import shutil
import msgpack
import hashlib
import logging
import pwd
import grp
import sys
try:
import pwd
import grp
except ImportError:
pass
# Import Salt libs
import salt.client
@ -491,10 +494,20 @@ class SPMClient(object):
# No defaults for this in config.py; default to the current running
# user and group
uid = self.opts.get('spm_uid', os.getuid())
gid = self.opts.get('spm_gid', os.getgid())
uname = pwd.getpwuid(uid)[0]
gname = grp.getgrgid(gid)[0]
import salt.utils
if salt.utils.is_windows():
import salt.utils.win_functions
cur_user = salt.utils.win_functions.get_current_user()
cur_user_sid = salt.utils.win_functions.get_sid_from_name(cur_user)
uid = self.opts.get('spm_uid', cur_user_sid)
gid = self.opts.get('spm_gid', cur_user_sid)
uname = cur_user
gname = cur_user
else:
uid = self.opts.get('spm_uid', os.getuid())
gid = self.opts.get('spm_gid', os.getgid())
uname = pwd.getpwuid(uid)[0]
gname = grp.getgrgid(gid)[0]
# Second pass: install the files
for member in pkg_files:
@ -710,7 +723,7 @@ class SPMClient(object):
raise SPMInvocationError('A path to a directory must be specified')
if args[1] == '.':
repo_path = os.environ['PWD']
repo_path = os.getcwd()
else:
repo_path = args[1]