fix Mac chown/chmod -R issue, add error checks

The changes to chown/chmod were broken on Mac (-R was being appended to the end of the command- OSX requires it before the file list).

A number of base action remote setup commands were also blindly proceeding without checking for success. Added error raises for unrecoverable failure cases.
This commit is contained in:
nitzmahone 2016-03-28 22:07:14 -07:00
parent 5fdac707fd
commit 05af5c88ea
2 changed files with 29 additions and 13 deletions

View file

@ -54,23 +54,29 @@ class ShellBase(object):
def chmod(self, mode, path, recursive=True):
path = pipes.quote(path)
cmd = ['chmod', mode, path]
cmd = ['chmod']
if recursive:
cmd.append('-R')
cmd.append('-R') # many chmods require -R before file list
cmd.extend([mode, path])
return ' '.join(cmd)
def chown(self, path, user, group=None, recursive=True):
path = pipes.quote(path)
user = pipes.quote(user)
if group is None:
cmd = ['chown', user, path]
else:
group = pipes.quote(group)
cmd = ['chown', '%s:%s' % (user, group), path]
cmd = ['chown']
if recursive:
cmd.append('-R')
cmd.append('-R') # many chowns require -R before file list
if group is None:
cmd.extend([user, path])
else:
group = pipes.quote(group)
cmd.extend(['%s:%s' % (user, group), path])
return ' '.join(cmd)