Execute a check command.

        Returns:
            True if the exit code of the command is 0 otherwise False.
502025
def _run_check(self):
        
        cmd = shlex.split(self.config['check_cmd'])
        self.log.info("running %s", ' '.join(cmd))
        proc = subprocess.Popen(cmd, stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE)

        start_time = time.time()
        try:
            outs, errs = proc.communicate(timeout=self.config['check_timeout'])
        except subprocess.TimeoutExpired:
            self.log.error("check timed out")
            if proc.poll() is None:
                try:
                    proc.kill()
                except PermissionError:
                    self.log.warning("failed to kill check due to adequate "
                                     "access rights, check could be running "
                                     "under another user(root) via sudo")

            return False
        else:
            msg = "check duration {t:.3f}ms".format(
                t=(time.time() - start_time) * 1000)
            self.log.info(msg)

            if proc.returncode != 0:
                self.log.info("stderr from the check %s", errs)
                self.log.info("stdout from the check %s", outs)

            return proc.returncode == 0
1091439
def _execute(self, p_command, p_args):
        
        self._backup(p_command, p_args)

        command = p_command(
            p_args,
            self.todolist,
            output,
            error,
            input)

        if command.execute() != False:
            self._post_archive_action = command.execute_post_archive_actions
            return True

        return False
680574
private boolean tryCheckEmptyRunGitCommand(File directory, long nativeGitTimeoutInMs, String gitCommand) {
    try {
      String env = System.getenv("GIT_PATH");
      String exec = env == null ? "git" : env;
      String command = String.format("%s %s", exec, gitCommand);

      return getRunner().runEmpty(directory, nativeGitTimeoutInMs, command);
    } catch (IOException ex) {
      // Error means "non-empty"
      return false;
      // do nothing...
    }
  }
559032
async def checked_run(*cmd):
  

  # Start the subprocess.
  logging.info('Running: %s', expand_cmd_str(cmd))
  with logged_timer('{} finished'.format(get_cmd_name(cmd))):
    p = await asyncio.create_subprocess_exec(
        *cmd, stdout=asyncio.subprocess.PIPE, stderr=asyncio.subprocess.STDOUT)

    # Stream output from the process stdout.
    chunks = []
    while True:
      chunk = await p.stdout.read(16 * 1024)
      if not chunk:
        break
      chunks.append(chunk)

    # Wait for the process to finish, check it was successful & build stdout.
    await p.wait()
    stdout = b''.join(chunks).decode()[:-1]
    if p.returncode:
      raise RuntimeError('Return code {} from process: {}\n{}'.format(
          p.returncode, expand_cmd_str(cmd), stdout))

    return stdout
1293178
def run!(cmd)
      cmd = @before_run_block.call(cmd) if @before_run_block
      return false unless cmd
      say "!txtgrn!> #{cmd}" unless Runfile.quiet
      exec cmd
    end
596174
public function doExecute()
	{
		$command  = $this->getRootCommand();

		if ((!$command->getHandler() && !count($this->input->args)))
		{
			array_unshift($this->input->args, 'help');
		}

		try
		{
			/*
			 * Exit code is the Linux/Unix command/shell return code to see
			 * whether this script executed is successful or not.
			 *
			 * @see  http://tldp.org/LDP/abs/html/exitcodes.html
			 */
			$exitCode = $command->execute();
		}
		catch (\Exception $e)
		{
			$command->renderException($e);

			$exitCode = $e->getHandler();
		}

		if ($this->autoExit)
		{
			if ($exitCode > 255 || $exitCode == -1)
			{
				$exitCode = 255;
			}

			exit($exitCode);
		}

		return $exitCode;
	}
911186
def running(processid):
    
    try:
        # From kill(2)
        #   If sig is 0 (the null signal), error checking is performed but no
        #   signal is actually sent. The null signal can be used to check the
        #   validity of pid
        os.kill(processid, 0)
    except OverflowError as exc:
        print("checking validity of pid ({p}) failed with: {e}"
              .format(p=processid, e=exc))
        sys.exit(1)
    except OSError:
        return False
    else:
        return True
455821
def _check_output(self, command):
        """"""
        try:
            if sys.version_info[0] > 2:
                return check_output(self.base_command + command, stderr=STDOUT).decode('utf8')
            else:
                return check_output(self.base_command + command, stderr=STDOUT)
        except CalledProcessError as command_error:
            raise GitCommandException(*command_error.args)
327720
def _run_all(cmd, log_lvl=None, log_msg=None, exitcode=0):
    '''
    
    '''
    res = __salt__['cmd.run_all'](cmd)
    if res['retcode'] == exitcode:
        if res['stdout']:
            return res['stdout']
        else:
            return True

    if log_lvl is not None:
        log.log(LOG[log_lvl], log_msg, res['stderr'])
    return False
535846
def _check_cmd(call):
    '''
    
    '''
    if call['retcode'] != 0:
        comment = ''
        std_err = call.get('stderr')
        std_out = call.get('stdout')
        if std_err:
            comment += std_err
        if std_out:
            comment += std_out

        raise CommandExecutionError('Error running command: {0}'.format(comment))

    return call
998229
def execute_return_success(cmd):
    '''
    
    '''

    ret = _run_all(cmd)

    if ret['retcode'] != 0 or 'not supported' in ret['stdout'].lower():
        msg = 'Command Failed: {0}\n'.format(cmd)
        msg += 'Return Code: {0}\n'.format(ret['retcode'])
        msg += 'Output: {0}\n'.format(ret['stdout'])
        msg += 'Error: {0}\n'.format(ret['stderr'])
        raise CommandExecutionError(msg)

    return True
526875
def execute(command, silent = false, &block)
      result = run_with_timeout(command)
      if result.success? or silent
        warn command if @verbose
        return result unless block
        return block.call(result)
      end
      raise Error, cmd_error_message(command, result.data)
    rescue Errno::ENOENT
      raise Error, cmd_error_message(command, $!.message)
    end
721801
def run(command, get_output=False, cwd=None):
    
    if cwd is None:
        cwd = GITPATH

    cprint('===')
    cprint('===  Command: ', command)
    cprint('===  CWD:     ', cwd)
    cprint('===')

    if get_output:
        proc = capture_stdout(command, cwd=cwd)
        out = proc.stdout.read().decode()
        print(out, end='')
        check_exit_code(proc.returncode)
        return out
    else:
        proc = sarge_run(command, cwd=cwd)
        check_exit_code(proc.returncode)
365298
def execute(self):
        
        last_operation = len(self._operations) - 1
        for i, operation in enumerate(self._operations):
            command = self._cmd(operation)

            if command.execute() is False:
                return False
            else:
                action = command.execute_post_archive_actions
                self._post_archive_actions.append(action)

                if i == last_operation:
                    return True
1196881
def run(cmd):
    

    status, output = commands.getstatusoutput(cmd)
    if status:
        print(output)
    return status == 0
1260985
def exec_or_exit(cmd)
      status = execute(cmd)
      if (status.to_i.nonzero?)
        error("The command '#{cmd}' failed with exit status #{status.to_i}")
      end
      status
    end
767135
def validate_command(cmd = ARGV)
      fail 'Specify one action.' unless cmd.count == 1
      cmd = cmd.shift
      fail 'Invalid action.' unless SUB_COMMANDS.include?(cmd)
      cmd
    end