def _run_command(command, shell=True, pty=True, combine_stderr=True, sudo=False, user=None, quiet=False, warn_only=False, stdout=None, stderr=None, group=None, timeout=None, shell_escape=None, capture_buffer_size=None):
 manager = _noop
 if warn_only:
  manager = warn_only_manager
 if quiet:
  manager = quiet_manager
 with manager():
  given_command = command
  if (shell_escape is None):
   shell_escape = env.get('shell_escape', True)
  wrapped_command = _shell_wrap(_prefix_env_vars(_prefix_commands(command, 'remote')), shell_escape, shell, (_sudo_prefix(user, group) if sudo else None))
  which = ('sudo' if sudo else 'run')
  if output.debug:
   print ('[%s] %s: %s' % (env.host_string, which, wrapped_command))
  elif output.running:
   print ('[%s] %s: %s' % (env.host_string, which, given_command))
  (result_stdout, result_stderr, status) = _execute(channel=default_channel(), command=wrapped_command, pty=pty, combine_stderr=combine_stderr, invoke_shell=False, stdout=stdout, stderr=stderr, timeout=timeout, capture_buffer_size=capture_buffer_size)
  out = _AttributeString(result_stdout)
  err = _AttributeString(result_stderr)
  out.failed = False
  out.command = given_command
  out.real_command = wrapped_command
  if (status not in env.ok_ret_codes):
   out.failed = True
   msg = ('%s() received nonzero return code %s while executing' % (which, status))
   if env.warn_only:
    msg += (" '%s'!" % given_command)
   else:
    msg += ('!\n\nRequested: %s\nExecuted: %s' % (given_command, wrapped_command))
   error(message=msg, stdout=out, stderr=err)
  out.return_code = status
  out.succeeded = (not out.failed)
  out.stderr = err
  return out

def _run_command ( command , shell = True , pty = True , combine_stderr = True , sudo = False , user = None , quiet = False , warn_only = False , stdout = None , stderr = None , group = None , timeout = None , shell_escape = None , capture_buffer_size = None ) : manager = _noop if warn_only : manager = warn_only_manager if quiet : manager = quiet_manager with manager ( ) : given_command = command if ( shell_escape is None ) : shell_escape = env . get ( 'shell_escape' , True ) wrapped_command = _shell_wrap ( _prefix_env_vars ( _prefix_commands ( command , 'remote' ) ) , shell_escape , shell , ( _sudo_prefix ( user , group ) if sudo else None ) ) which = ( 'sudo' if sudo else 'run' ) if output . debug : print ( '[%s] %s: %s' % ( env . host_string , which , wrapped_command ) ) elif output . running : print ( '[%s] %s: %s' % ( env . host_string , which , given_command ) ) ( result_stdout , result_stderr , status ) = _execute ( channel = default_channel ( ) , command = wrapped_command , pty = pty , combine_stderr = combine_stderr , invoke_shell = False , stdout = stdout , stderr = stderr , timeout = timeout , capture_buffer_size = capture_buffer_size ) out = _AttributeString ( result_stdout ) err = _AttributeString ( result_stderr ) out . failed = False out . command = given_command out . real_command = wrapped_command if ( status not in env . ok_ret_codes ) : out . failed = True msg = ( '%s() received nonzero return code %s while executing' % ( which , status ) ) if env . warn_only : msg += ( " '%s'!" % given_command ) else : msg += ( '!\n\nRequested: %s\nExecuted: %s' % ( given_command , wrapped_command ) ) error ( message = msg , stdout = out , stderr = err ) out . return_code = status out . succeeded = ( not out . failed ) out . stderr = err return out
runs the command cmd with options as its cli parameters and returns the result as a dictionary .