this helper method checks if
    redis server is available in the sys
    if not fires up one
761738
def _redis_process_checkpoint(host, port):
    '''
    '''
    try:
        subprocess.check_output("pgrep redis", shell=True)
    except Exception:
        logger.warning(
            'Your redis server is offline, fake2db will try to launch it now!',
            extra=extra_information)
        # close_fds = True argument is the flag that is responsible
        # for Popen to launch the process completely independent
        subprocess.Popen("redis-server --bind %s --port %s" % (host, port),
                         close_fds=True,
                         shell=True)
        time.sleep(3)
187051
def is_in_current_deployment(server, extra_prefix=""):
    
    return re.match(r"^%s" % '-'.join([DEFAULT_PREFIX, extra_prefix]),
                    server.name) is not None
1266676
def check_server_running(pid):
    
    if pid == os.getpid():
        # special case--we're in Docker or some other kind of container
        # (or we got really unlucky and got the same PID twice).
        # this PID does not correspond to another running server, either way.
        return False

    try:
        os.kill(pid, 0)
        return True
    except OSError as oe:
        if oe.errno == errno.ESRCH:
            return False
        else:
            raise
974904
def service_available(service_name):
    """"""
    try:
        subprocess.check_output(
            ['service', service_name, 'status'],
            stderr=subprocess.STDOUT).decode('UTF-8')
    except subprocess.CalledProcessError as e:
        return b'unrecognized service' not in e.output
    else:
        return True
857809
private boolean checkVmIsOnline() {

		String zoneName = OpenstackIaasHandler.findZoneName( this.novaApi, this.targetProperties );
		Server server = this.novaApi.getServerApiForZone( zoneName ).get(this.machineId);
		return Status.ACTIVE.equals(server.getStatus());
	}
716212
def _check_available(name):
    '''
    
    '''
    _status = _systemctl_status(name)
    sd_version = salt.utils.systemd.version(__context__)
    if sd_version is not None and sd_version >= 231:
        # systemd 231 changed the output of "systemctl status" for unknown
        # services, and also made it return an exit status of 4. If we are on
        # a new enough version, check the retcode, otherwise fall back to
        # parsing the "systemctl status" output.
        # See: https://github.com/systemd/systemd/pull/3385
        # Also: https://github.com/systemd/systemd/commit/3dced37
        return 0 <= _status['retcode'] < 4

    out = _status['stdout'].lower()
    if 'could not be found' in out:
        # Catch cases where the systemd version is < 231 but the return code
        # and output changes have been backported (e.g. RHEL 7.3).
        return False

    for line in salt.utils.itertools.split(out, '\n'):
        match = re.match(r'\s+loaded:\s+(\S+)', line)
        if match:
            ret = match.group(1) != 'not-found'
            break
    else:
        raise CommandExecutionError(
            'Failed to get information on unit \'%s\'' % name
        )
    return ret
498532
def server_enabled(s_name, **connection_args):
    '''
    
    '''
    server = _server_get(s_name, **connection_args)
    return server is not None and server.get_state() == 'ENABLED'
900031
def check_redis():
        
        from pyoko.db.connection import cache
        from redis.exceptions import ConnectionError

        try:
            cache.ping()
            print(CheckList.OKGREEN + "{0}Redis is working{1}" + CheckList.ENDC)
        except ConnectionError as e:
            print(__(u"{0}Redis is not working{1} ").format(CheckList.FAIL,
                                                            CheckList.ENDC), e.message)
1272605
def check_virtualserver(self, name):
        '''
        
        '''
        vs = self.bigIP.LocalLB.VirtualServer
        for v in vs.get_list():
            if v.split('/')[-1] == name:
                return True
        return False
1080387
def available():
    """"""
    proc = popen_multiple(
        COMMANDS,
        ['-version'],
        stdout=subprocess.PIPE,
        stderr=subprocess.PIPE,
        creationflags=PROC_FLAGS,
    )
    proc.wait()
    return (proc.returncode == 0)
333271
def kill_redis(self, check_alive=True):
        
        self._kill_process_type(
            ray_constants.PROCESS_TYPE_REDIS_SERVER, check_alive=check_alive)
175116
def update_status(status)
      if status.present?
        RRRSpec.redis.hset(key, 'status', status)
      else
        RRRSpec.redis.hdel(key, 'status')
      end
    end
1355504
def check_refresh(opts, refresh=None):
    '''
    
    '''
    return bool(
        salt.utils.data.is_true(refresh) or
        (os.path.isfile(rtag(opts)) and refresh is not False)
    )
80106
def check_server(self):
        
        msg = 'API server not found. Please check your API url configuration.'

        try:
            response = self.session.head(self.domain)
        except Exception as e:
            raise_from(errors.ServerError(msg), e)

        try:
            self._check_response(response)
        except errors.NotFound as e:
            raise raise_from(errors.ServerError(msg), e)
565144
public function check()
    {
        try {
            $client = new Client(array(
                'host' => $this->host,
                'port' => $this->port,
            ));
            if (!$client->ping()) {
                throw new CheckFailedException(
                    sprintf(
                        'No Redis server running at host %s on port %s',
                        $this->host,
                        $this->port
                    )
                );
            }
            $result = $this->buildResult('OK', CheckResult::OK);
        } catch (\Exception $e) {
            $result = $this->buildResult($e->getMessage(), CheckResult::CRITICAL);
        }

        return $result;
    }
782015
def shutdown(host=None, port=None, db=None, password=None):
    '''
    
    '''
    server = _connect(host, port, db, password)
    try:
        # Return false if unable to ping server
        server.ping()
    except redis.ConnectionError:
        return False

    server.shutdown()
    try:
        # This should fail now if the server is shutdown, which we want
        server.ping()
    except redis.ConnectionError:
        return True
    return False
1326881
def _get_serv(ret=None):
    '''
    
    '''
    _options = _get_options(ret)
    global REDIS_POOL
    if REDIS_POOL:
        return REDIS_POOL
    elif _options.get('cluster_mode'):
        REDIS_POOL = StrictRedisCluster(startup_nodes=_options.get('startup_nodes'),
                                        skip_full_coverage_check=_options.get('skip_full_coverage_check'),
                                        decode_responses=True)
    else:
        REDIS_POOL = redis.StrictRedis(host=_options.get('host'),
                                       port=_options.get('port'),
                                       unix_socket_path=_options.get('unix_socket_path', None),
                                       db=_options.get('db'),
                                       decode_responses=True,
                                       password=_options.get('password'))
    return REDIS_POOL