parameters: (os_cmd, logger, dry_run=False)
docstring: Execute os command and log results.
  
    Runs command, waits until it finishes, then analyses the return code, and
    reports either "SUCCESS" or "FAILED".
    Use if output of command is not desired, otherwise it should be redirected
    to a file or use RunCmd below.
  
    Args:
      os_cmd: Linux shell command to execute.
      logger: Logger responsible for outputting log messages.
      dry_run: Whether command should only be printed but not run.
    Throws:
      OsCommandError
docstring_summary: Execute os command and log results.
docstring_tokens: Execute os command and log results .
function: def ExecuteCmd(os_cmd, logger, dry_run=False):
    """Execute os command and log results.
  
    Runs command, waits until it finishes, then analyses the return code, and
    reports either "SUCCESS" or "FAILED".
    Use if output of command is not desired, otherwise it should be redirected
    to a file or use RunCmd below.
  
    Args:
      os_cmd: Linux shell command to execute.
      logger: Logger responsible for outputting log messages.
      dry_run: Whether command should only be printed but not run.
    Throws:
      OsCommandError
    """
    PrintAndLog("Executing: %s" % os_cmd, logger)
    if dry_run:
      PrintAndLog("-- dry run --", logger)
      return
    try:
      if isinstance(os_cmd, str):
        os_cmd = shlex.split(os_cmd)
      p = subprocess.Popen(os_cmd, shell=False,
                           stdout=subprocess.PIPE,
                           stderr=subprocess.PIPE)
      err_data = p.communicate()[1]
      return_code = p.returncode
      if return_code != 0:
        PrintAndLog("Raising error: %s (return code %d)\n"
                    % (err_data, return_code), logger)
        raise OsCommandError()
      else:
        PrintAndLog("SUCCESS", logger, None)
    except Exception, e:
      PrintAndLog("FAILED: %s" % e.__str__(), logger)
      raise OsCommandError()
function_tokens: def ExecuteCmd ( os_cmd , logger , dry_run = False ) : PrintAndLog ( "Executing: %s" % os_cmd , logger ) if dry_run : PrintAndLog ( "-- dry run --" , logger ) return try : if isinstance ( os_cmd , str ) : os_cmd = shlex . split ( os_cmd ) p = subprocess . Popen ( os_cmd , shell = False , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) err_data = p . communicate ( ) [ 1 ] return_code = p . returncode if return_code != 0 : PrintAndLog ( "Raising error: %s (return code %d)\n" % ( err_data , return_code ) , logger ) raise OsCommandError ( ) else : PrintAndLog ( "SUCCESS" , logger , None ) except Exception , e : PrintAndLog ( "FAILED: %s" % e . __str__ ( ) , logger ) raise OsCommandError ( )