def launchctl(sub_cmd, *args, **kwargs):
 return_stdout = kwargs.pop('return_stdout', False)
 cmd = ['launchctl', sub_cmd]
 cmd.extend(args)
 kwargs['python_shell'] = False
 ret = __salt__['cmd.run_all'](cmd, **kwargs)
 if ret['retcode']:
  out = 'Failed to {0} service:\n'.format(sub_cmd)
  out += 'stdout: {0}\n'.format(ret['stdout'])
  out += 'stderr: {0}\n'.format(ret['stderr'])
  out += 'retcode: {0}\n'.format(ret['retcode'])
  raise CommandExecutionError(out)
 else:
  return (ret['stdout'] if return_stdout else True)

def launchctl ( sub_cmd , * args , ** kwargs ) : return_stdout = kwargs . pop ( 'return_stdout' , False ) cmd = [ 'launchctl' , sub_cmd ] cmd . extend ( args ) kwargs [ 'python_shell' ] = False ret = __salt__ [ 'cmd.run_all' ] ( cmd , ** kwargs ) if ret [ 'retcode' ] : out = 'Failed to {0} service:\n' . format ( sub_cmd ) out += 'stdout: {0}\n' . format ( ret [ 'stdout' ] ) out += 'stderr: {0}\n' . format ( ret [ 'stderr' ] ) out += 'retcode: {0}\n' . format ( ret [ 'retcode' ] ) raise CommandExecutionError ( out ) else : return ( ret [ 'stdout' ] if return_stdout else True )
run a launchctl command and raise an error if it fails .