Checks to see if a given check command exists on the device.

        Args:
            command: A string that is the name of the command to check.

        Returns:
            A boolean that is True if the command exists and False otherwise.
979746
def has_shell_command(self, command):
        
        try:
            output = self.shell(['command', '-v',
                                 command]).decode('utf-8').strip()
            return command in output
        except AdbError:
            # If the command doesn't exist, then 'command -v' can return
            # an exit code > 1.
            return False
724501
def check_success(self, device_id, sent_cmd1, sent_cmd2):
        """"""
        device_id = device_id.upper()

        self.logger.info('check_success: for device %s cmd1 %s cmd2 %s',
                         device_id, sent_cmd1, sent_cmd2)

        sleep(2)
        status = self.get_buffer_status(device_id)
        check_id = status.get('id_from', '')
        cmd1 = status.get('cmd1', '')
        cmd2 = status.get('cmd2', '')
        if (check_id == device_id) and (cmd1 == sent_cmd1) and (cmd2 == sent_cmd2):
            self.logger.info("check_success: Response device %s cmd %s cmd2 %s SUCCESS",
                             check_id, cmd1, cmd2)
            return True

        self.logger.info("check_success: No valid response found for device %s cmd %s cmd2 %s",
                         device_id, sent_cmd1, sent_cmd2)
        return False
161399
def get_command(self):
        
        cmd = None
        count = len(self.command_list)
        if count > 0:
            cmd = self.command_list.pop(0)
        ## If that was the last line, turn off lines_pending
        if count == 1:
            self.cmd_ready = False
        return cmd
50885
def available(name):
    '''
    
    '''
    cmd = '{0} get {1}'.format(_cmd(), name)
    if __salt__['cmd.retcode'](cmd) == 2:
        return False
    return True
1238015
def command(self, command):
        
        return self._conn.command('[con_id="{}"] {}'.format(self.id, command))
677291
def find_command(self, argv):
        
        search_args = argv[:]
        name = ''
        while search_args:
            if search_args[0].startswith('-'):
                name = '%s %s' % (name, search_args[0])
                raise ValueError('Invalid command %r' % name)
            next_val = search_args.pop(0)
            name = '%s %s' % (name, next_val) if name else next_val
            if name in self.commands:
                cmd_ep = self.commands[name]
                if hasattr(cmd_ep, 'resolve'):
                    cmd_factory = cmd_ep.resolve()
                else:
                    # NOTE(dhellmann): Some fake classes don't take
                    # require as an argument. Yay?
                    arg_spec = inspect.getargspec(cmd_ep.load)
                    if 'require' in arg_spec[0]:
                        cmd_factory = cmd_ep.load(require=False)
                    else:
                        cmd_factory = cmd_ep.load()
                return (cmd_factory, name, search_args)
        else:
            raise ValueError('Unknown command %r' % next(iter(argv), ''))
864304
def check_command(self, **new_attributes):
        
        # let's parse arguments if we didn't before.
        if not self._is_parsed:
            self.parse_args()
        if not self.commands:
            # if we don't have commands raise an Exception
            raise exceptions.ArgParseInatorNoCommandsFound
        elif self._single:
            # if we have a single function we get it directly
            func = self._single
        else:
            if not self.args.command:
                self.parser.error("too few arguments")
            # get the right command
            func = self.commands[self.args.command]

        if hasattr(func, '__subcommands__') and func.__subcommands__:
            # if we have subcommands get the command from them
            command = func.__subcommands__[self.args.subcommand]
        else:
            # else the command IS the function
            command = func
        # get the command name
        self.cmd_name = command.__cmd_name__
        # check authorization
        if not self.check_auth(id(command)):
            return 0
        # let's execute the command.
        return self._execute(func, command, **new_attributes)
410859
def which(command)
      ENV['PATH'].split(File::PATH_SEPARATOR).map {|e| File.join(e, command) }.find {|e| File.exists?(e) }
    end
1236972
def command(command, options)
      options = {
          'print_command' => false,
          'failure_message' => "required command '#{command}' is not available."
      }.merge(string_keys(options))
      system_exit_on_error("which #{command}", options)
    end
837990
def mod_run_check(cmd_kwargs, onlyif, unless, creates):
    '''
    
    '''
    # never use VT for onlyif/unless executions because this will lead
    # to quote problems
    cmd_kwargs = copy.deepcopy(cmd_kwargs)
    cmd_kwargs['use_vt'] = False
    cmd_kwargs['bg'] = False

    if onlyif is not None:
        if isinstance(onlyif, six.string_types):
            cmd = __salt__['cmd.retcode'](onlyif, ignore_retcode=True, python_shell=True, **cmd_kwargs)
            log.debug('Last command return code: %s', cmd)
            if cmd != 0:
                return {'comment': 'onlyif condition is false',
                        'skip_watch': True,
                        'result': True}
        elif isinstance(onlyif, list):
            for entry in onlyif:
                cmd = __salt__['cmd.retcode'](entry, ignore_retcode=True, python_shell=True, **cmd_kwargs)
                log.debug('Last command \'%s\' return code: %s', entry, cmd)
                if cmd != 0:
                    return {'comment': 'onlyif condition is false: {0}'.format(entry),
                            'skip_watch': True,
                            'result': True}
        elif not isinstance(onlyif, six.string_types):
            if not onlyif:
                log.debug('Command not run: onlyif did not evaluate to string_type')
                return {'comment': 'onlyif condition is false',
                        'skip_watch': True,
                        'result': True}

    if unless is not None:
        if isinstance(unless, six.string_types):
            cmd = __salt__['cmd.retcode'](unless, ignore_retcode=True, python_shell=True, **cmd_kwargs)
            log.debug('Last command return code: %s', cmd)
            if cmd == 0:
                return {'comment': 'unless condition is true',
                        'skip_watch': True,
                        'result': True}
        elif isinstance(unless, list):
            cmd = []
            for entry in unless:
                cmd.append(__salt__['cmd.retcode'](entry, ignore_retcode=True, python_shell=True, **cmd_kwargs))
                log.debug('Last command return code: %s', cmd)
            if all([c == 0 for c in cmd]):
                return {'comment': 'unless condition is true',
                        'skip_watch': True,
                        'result': True}
        elif not isinstance(unless, six.string_types):
            if unless:
                log.debug('Command not run: unless did not evaluate to string_type')
                return {'comment': 'unless condition is true',
                        'skip_watch': True,
                        'result': True}

    if isinstance(creates, six.string_types) and os.path.exists(creates):
        return {'comment': '{0} exists'.format(creates),
                'result': True}
    elif isinstance(creates, list) and all([
        os.path.exists(path) for path in creates
    ]):
        return {'comment': 'All files in creates exist',
                'result': True}

    # No reason to stop, return True
    return True
469753
def is_command_callable(command, name=""):
    

    # Use `command` to see if command is callable, store exit code
    code = os.system(
        "command -v {0} >/dev/null 2>&1 || {{ exit 1; }}".format(command))

    if code != 0:
        alias_value = " ('{}') ".format(name) if name else " "
        _LOGGER.debug("Command '{0}' is not callable: {1}".
                      format(alias_value, command))
    return not bool(code)
1077990
def block_by_command(cls, command):
        
        for block in cls.blocks:
            if block.has_command(command):
                return block
1171962
def execute(cls, command, shell=True):
        
        cls.debug('execute command (shell flag:%r): %r ' % (shell, command))
        try:
            check_call(command, shell=shell)
            return True
        except CalledProcessError:
            return False
1277922
private static function commandExists($command) {
		$whereIsCommand = (PHP_OS == 'WINNT') ? 'where' : 'which';
		$process = proc_open("$whereIsCommand $command", [
			0 => array("pipe", "r"), //STDIN
			1 => array("pipe", "w"), //STDOUT
			2 => array("pipe", "w"), //STDERR
				], $pipes);

		if ($process !== false) {
			$stdout = stream_get_contents($pipes[1]);
			$stderr = stream_get_contents($pipes[2]);
			fclose($pipes[1]);
			fclose($pipes[2]);
			proc_close($process);

			return $stdout != '';
		}

		return false;
	}
329797
def _run_check_cmd(self, low_data):
        '''
        
        '''
        ret = {'result': False}
        cmd_opts = {}
        if 'shell' in self.opts['grains']:
            cmd_opts['shell'] = self.opts['grains'].get('shell')
        for entry in low_data['check_cmd']:
            cmd = self.functions['cmd.retcode'](
                entry, ignore_retcode=True, python_shell=True, **cmd_opts)
            log.debug('Last command return code: %s', cmd)
            if cmd == 0 and ret['result'] is False:
                ret.update({'comment': 'check_cmd determined the state succeeded', 'result': True})
            elif cmd != 0:
                ret.update({'comment': 'check_cmd determined the state failed', 'result': False})
                return ret
        return ret
244208
def if_device_path_exists(device_serial, device_path)
      return if run_adb_command("adb -s #{device_serial} shell ls #{device_path}",
                                print_all: false,
                                print_command: false).include?('No such file')

      yield(device_path)
    rescue
      # Some versions of ADB will have a non-zero exit status for this, which will cause the executor to raise.
      # We can safely ignore that and treat it as if it returned 'No such file'
    end
832525
def command_exists?(command)
      ENV['PATH'].split(File::PATH_SEPARATOR).any? {|d| File.exist? File.join(d, command) }
    end