Return the status for a service via s6, return pid if running

    CLI Example:

    .. code-block:: bash

        salt '*' s6.status <service name>
965403
def status(name, sig=None):
    '''
    
    '''
    cmd = 's6-svstat {0}'.format(_service_path(name))
    out = __salt__['cmd.run_stdout'](cmd)
    try:
        pid = re.search(r'up \(pid (\d+)\)', out).group(1)
    except AttributeError:
        pid = ''
    return pid
507326
def do_status(self):
        
        
        # Get the PID of the service
        pid    = self.pid.get()
        
        # Status color / attributes
        status_color  = 'green' if pid else 'red'
        status_dot    = self._colorize(UNICODE['dot'], status_color, encode=True)
        
        # Active text
        active_txt    = {
            'active':   '{} since {}'.format(self._colorize('active (running)', 'green'), self.pid.birthday()[1]),
            'inactive': 'inactive (dead)'
        }
        
        # Print the status message
        print(status_dot, end=' ')
        print('{}.service - LSB: {}'.format(self.name, self.desc))
        print('   Loaded: loaded (/etc/init.d/{})'.format(self.name))
        print('   Active: {}'.format(active_txt['active' if pid else 'inactive']))
        
        # Extra information if running
        if pid:
            ps = self.pid.ps()
            print('  Process: {}; [{}]'.format(pid, ps[0]))
            if ps[1]:
                for c in ps[1]:
                    print('    Child: {}'.format(c))
        print('')
652256
def status(self, status_code=None):
        
        if status_code is not None:
            self.response_model.status = status_code
        # return string for response support
        return str(self.response_model.status)
518661
def get_status(self):
    
    self.__update_state()
    if self._state.active:
      return self.RUNNING
    else:
      return self._state.result_status
937073
def get_status(self):
        """"""

        result = ''
        if self._data_struct is not None:
            result = self._data_struct[KEY_STATUS]
        return result
675031
def get_instance_status(self):
        
        status_url = self._get_url('status_path')
        res = self.rest_client.session.get(status_url)
        _handle_http_errors(res)
        return res.json()
876377
def get_status(self):
        """"""
        req_url = ENDPOINTS["getStatus"].format(self.ip_address, self.zone_id)
        return request(req_url)
985558
def get_service_status(self, name):
        
        svc = self._query_service(name)
        if svc is not None:
            return {'name': name,
                    'status': self.parse_query(svc['output']),
                    'output': svc['output']
                    }
        else:
            return {'name': name,
                    'status': 'missing',
                    'output': ''
                    }
219068
def status(app_name=None, only_cozy=False, as_boolean=False):
    '''
    '''
    apps = {}
    # Get all apps status & slip them
    apps_status = subprocess.Popen('cozy-monitor status',
                                   shell=True,
                                   stdout=subprocess.PIPE).stdout.read()
    apps_status = apps_status.split('\n')

    # Parse result to store them in apps dictionary
    for app_status in apps_status:
        if app_status:
            app_status = ANSI_ESCAPE.sub('', app_status).split(': ')
            if len(app_status) == 2:
                current_status = app_status[1]
                if as_boolean:
                    if app_status[1] == 'up':
                        current_status = True
                    else:
                        current_status = False
                if only_cozy and app_status[0] not in SYSTEM_APPS:
                    apps[app_status[0]] = current_status
                else:
                    apps[app_status[0]] = current_status

    # Return app status if get as param or return all apps status
    if app_name:
        return apps.get(app_name, None)
    else:
        return apps
723779
def service_status(self, name):
        

        return self._loop.run_coroutine(self._client.service_status(name))
1005631
def get_notebook_status(self, name):
        
        context = comm.get_context(self.get_pid(name))
        if not context:
            return None
        return context
1183288
def _QueryProcessStatus(self, process):
    
    process_is_alive = process.is_alive()
    if process_is_alive:
      rpc_client = self._rpc_clients_per_pid.get(process.pid, None)
      process_status = rpc_client.CallFunction()
    else:
      process_status = None
    return process_status
429862
def get_status(self):
        

        status = yield from self._hypervisor.send('vm get_status "{name}"'.format(name=self._name))
        if len(status) == 0:
            raise DynamipsError("Can't get vm {name} status".format(name=self._name))
        return self._status[int(status[0])]
926822
def getPIDStatus(jobStoreName):
        
        try:
            jobstore = Toil.resumeJobStore(jobStoreName)
        except NoSuchJobStoreException:
            return 'QUEUED'
        except NoSuchFileException:
            return 'QUEUED'

        try:
            with jobstore.readSharedFileStream('pid.log') as pidFile:
                pid = int(pidFile.read())
                try:
                    os.kill(pid, 0)  # Does not kill process when 0 is passed.
                except OSError:  # Process not found, must be done.
                    return 'COMPLETED'
                else:
                    return 'RUNNING'
        except NoSuchFileException:
            pass
        return 'QUEUED'
174516
def process_status(ctx, param, value):
    """"""
    from .models import PIDStatus

    # Allow empty status
    if value is None:
        return None

    if not hasattr(PIDStatus, value):
        raise click.BadParameter('Status needs to be one of {0}.'.format(
            ', '.join([s.name for s in PIDStatus])
        ))
    return getattr(PIDStatus, value)
71630
def status(self):
        """"""
        try:
            # -- Check client
            res = self.run(['info'])
            if res[0]['clientName'] == '*unknown*':
                return ConnectionStatus.INVALID_CLIENT
            # -- Trigger an auth error if not logged in
            self.run(['user', '-o'])
        except errors.CommandError as err:
            if 'password (P4PASSWD) invalid or unset' in str(err.args[0]):
                return ConnectionStatus.NO_AUTH
            if 'Connect to server failed' in str(err.args[0]):
                return ConnectionStatus.OFFLINE

        return ConnectionStatus.OK
1318506
def status(self, name=''):
        
        logger.warn(
            'Note that `status` is currently not so robust and may break on '
            'different systems')
        init = self._get_implementation(name)
        if name:
            self._assert_service_installed(init, name)
        logger.info('Retrieving status...')
        return init.status(name)