SDP Status check.

    Do all the tests to determine, if the SDP state is
    "broken", what could be the cause, and return a
    suitable status message to be sent back by the calling
    function.
173630
def _check_status(sdp_state):
    
    try:
        errval = "error"
        errdict = dict(state="unknown", reason="unknown")
        if sdp_state.current_state == "unknown":
            errdict['reason'] = 'database not initialised.'
            LOG.debug('Current state is unknown;')
            LOG.debug('Target state is %s;', sdp_state.target_state)
            LOG.debug('Current state timestamp is %s;',
                      sdp_state.current_timestamp)
        elif sdp_state.current_state is None:
            errdict['reason'] = 'Master Controller Services may have died.'
            LOG.debug('Current state is NONE;')
            LOG.debug('Target state is %s;', sdp_state.target_state)
            LOG.debug('Current state timestamp is %s;',
                      sdp_state.current_timestamp)
        elif sdp_state.target_state is None:
            errdict['reason'] = 'Master Controller Services may have died.'
            LOG.debug('Current state is  %s;',
                      sdp_state.current_state)
            LOG.debug('Target state is NONE;')
            LOG.debug('Current state timestamp is %s;',
                      sdp_state.current_timestamp)
            LOG.debug('Target state timestamp is %s;',
                      sdp_state.target_timestamp)
        elif sdp_state.current_timestamp is None:
            errdict['reason'] = 'Master Controller Services may have died.'
            LOG.debug('Current state is  %s;',
                      sdp_state.current_state)
            LOG.debug('Target state is %s;', sdp_state.target_state)
            LOG.debug('Current state timestamp is NONE')
            LOG.debug('Target state timestamp is %s;',
                      sdp_state.target_timestamp)
        elif sdp_state.target_timestamp is None:
            errdict['reason'] = 'Master Controller Services may have died.'
            LOG.debug('Current state is  %s;',
                      sdp_state.current_state)
            LOG.debug('Target state is %s;', sdp_state.target_state)
            LOG.debug('Current state timestamp is %s;',
                      sdp_state.current_timestamp)
            LOG.debug('Target state timestamp is NONE')
        elif sdp_state.current_timestamp < sdp_state.target_timestamp:
            errdict['reason'] = \
                'Timestamp for Master Controller Services is stale.'
            LOG.debug('Current state is  %s;',
                      sdp_state.current_state)
            LOG.debug('Target state is %s;', sdp_state.target_state)
            LOG.debug('Current state timestamp is %s;',
                      sdp_state.current_timestamp)
            LOG.debug('Target state timestamp is %s;',
                      sdp_state.target_timestamp)
        else:
            errval = "okay"
    except ConnectionError as err:
        errdict['reason'] = err
        LOG.debug('Connection Error %s', err)
    return errval, errdict
1020375
def check(self):
        
        if not self.enabled():
            return
        try:
            self.fetch()
        except (xmlrpclib.Fault, did.base.ConfigError) as error:
            log.error(error)
            self._error = True
            # Raise the exception if debugging
            if not self.options or self.options.debug:
                raise
        # Show the results stats (unless merging)
        if self.options and not self.options.merge:
            self.show()
1318138
public function checkStatus()
    {
        $status = OneLogin_Saml2_Utils::getStatus($this->document);

        if (isset($status['code']) && $status['code'] !== OneLogin_Saml2_Constants::STATUS_SUCCESS) {
            $explodedCode = explode(':', $status['code']);
            $printableCode = array_pop($explodedCode);

            $statusExceptionMsg = 'The status code of the Response was not Success, was '.$printableCode;
            if (!empty($status['msg'])) {
                $statusExceptionMsg .= ' -> '.$status['msg'];
            }
            throw new OneLogin_Saml2_ValidationError(
                $statusExceptionMsg,
                OneLogin_Saml2_ValidationError::STATUS_CODE_IS_NOT_SUCCESS
            );
        }
    }
490862
def check_response(self, resp):
        """"""
        if resp.status_code == 400:
            raise ApiException(json.loads(resp.content).get('message'))
        return resp
387333
def success(self):
        """"""
        self._check_valid()
        if self._ret_val != 0:
            return False
        return swiglpk.glp_get_status(self._problem._p) == swiglpk.GLP_OPT
885842
def status(self):
        
        message = self.end_message if self.end_message else self.start_message
        if message:
            return message.contents[ACTION_STATUS_FIELD]
        else:
            return None
1069282
def process_status(self, helper, session, check):
        """""""
        snmp_result_status = helper.get_snmp_value(session, helper, DEVICE_GLOBAL_OIDS['oid_' + check])

        if check == "system_lcd":
            helper.update_status(helper, normal_check("global", snmp_result_status, "LCD status"))
        elif check == "global_storage":
            helper.update_status(helper, normal_check("global", snmp_result_status, "Storage status"))
        elif check == "system_power":
            helper.update_status(helper, self.check_system_power_status(snmp_result_status))
        elif check == "global_system":
            helper.update_status(helper,
                                 normal_check("global", snmp_result_status, "Device status"))
329346
def check_status(self):
        
        try:
            r = requests.get(self.host + '/status', auth=self.auth,
                             timeout=(10.0, 10.0))
            if not r.status_code == requests.codes.ok:
                print("Problem connecting to server at %s" % self.host)
                print("status code: %s" % r.status_code)
                return False
            else:
                print("Connected to server at %s" % self.host)
                return True
        except (requests.exceptions.ConnectionError,
                requests.exceptions.MissingSchema,
                requests.exceptions.InvalidSchema) as e:
            print("Problem connecting to server at %s" % self.host)
            print("error: %s" % e)
            return False
744871
def check_for_error(func):
    

    @functools.wraps(func)
    def wrapper(*args, **kwargs):
        try:
            response = func(*args, **kwargs)
            status_code = response.status_code
            if status_code in range(200, 204):
                return response
            if status_code == 204:
                return
            data = response.json()
            e = {
                400: BadRequest,
                401: Unauthorized,
                403: Forbidden,
                404: NotFound,
                405: MethodNotAllowed,
                408: RequestTimeout,
                409: Conflict,
                429: TooManyRequests,
                500: ServerError,
                503: ServiceUnavailable,
            }.get(status_code, SbgError)()
            if 'message' in data:
                e.message = data['message']
            if 'code' in data:
                e.code = data['code']
            if 'status' in data:
                e.status = data['status']
            if 'more_info' in data:
                e.more_info = data['more_info']
            raise e
        except requests.RequestException as e:
            raise SbgError(message=six.text_type(e))
        except JSONDecodeError:
            message = (
                'Service might be unavailable. Can also occur by providing '
                'too many query parameters.'
            )
            raise_from(
                ServiceUnavailable(message=six.text_type(message)), None
            )
        except ValueError as e:
            raise SbgError(message=six.text_type(e))

    return wrapper
843222
def get_current_state():
    """"""
    sdp_state = SDPState()
    errval, errdict = _check_status(sdp_state)
    if errval == "error":
        LOG.debug(errdict['reason'])
        return dict(
            current_state="unknown",
            last_updated="unknown",
            reason=errdict['reason']
        )
    LOG.debug('Current State: %s', sdp_state.current_state)
    LOG.debug('Current State last updated: %s',
              sdp_state.current_timestamp.isoformat())
    return dict(
        current_state=sdp_state.current_state,
        last_updated=sdp_state.current_timestamp.isoformat()
    ), HTTPStatus.OK
1251334
def get_target_state():
    
    sdp_state = SDPState()
    errval, errdict = _check_status(sdp_state)
    if errval == "error":
        LOG.debug(errdict['reason'])
        return dict(
            current_target_state="unknown",
            last_updated="unknown",
            reason=errdict['reason']
        )
    LOG.debug('Getting target state')
    target_state = sdp_state.target_state
    LOG.debug('Target state = %s', target_state)
    return dict(
        current_target_state=target_state,
        allowed_target_states=sdp_state.allowed_target_states[
            sdp_state.current_state],
        last_updated=sdp_state.target_timestamp.isoformat())
124835
def check_status(self):
        
        log = logging.getLogger("%s.%s" % (self.log_name,
                                           inspect.stack()[0][3]))
        log.setLevel(self.log_level)

        if self.url:
            return True
        try:
            result = requests.get(self.ext_url)
            self.url = self.ext_url
            return True
        except requests.exceptions.ConnectionError:
            pass
        try:
            result = requests.get(self.local_url)
            log.warning("Url '%s' not connecting. Using local_url '%s'" % \
                     (self.ext_url, self.local_url))
            self.url = self.local_url
            return True
        except requests.exceptions.ConnectionError:
            self.url = None
            log.warning("Unable to connect using urls: %s" % set([self.ext_url,
                                                               self.local_url]))
            return False
57147
def _check_response_status(self, response):
        
        if response.status_code != requests.codes.ok:
            self._logger.error("%s %s", response.status_code, response.text)
            raise exceptions.RequestNonSuccessException(
                "Url {0} had status_code {1}".format(
                    response.url, response.status_code))
596395
def target_sdp_state(self, state):
        """"""
        LOG.info('Setting SDP target state to %s', state)
        if self._sdp_state.current_state == state:
            LOG.info('Target state ignored, SDP is already "%s"!', state)
        if state == 'on':
            self.set_state(DevState.ON)
        if state == 'off':
            self.set_state(DevState.OFF)
        if state == 'standby':
            self.set_state(DevState.STANDBY)
        if state == 'disable':
            self.set_state(DevState.DISABLE)
        self._sdp_state.update_target_state(state)
285480
def check_status(self):
        """"""
        # Recompute the status of the tasks
        # Ignore OK and LOCKED tasks.
        for task in self:
            if task.status in (task.S_OK, task.S_LOCKED): continue
            task.check_status()

        # Take into account possible dependencies. Use a list instead of generators
        for task in self:
            if task.status == task.S_LOCKED: continue
            if task.status < task.S_SUB and all(status == task.S_OK for status in task.deps_status):
                task.set_status(task.S_READY, "Status set to Ready")
29639
def status(name, sig=None):
    '''
    
    '''

    proxy_fn = 'dummy.service_status'
    resp = __proxy__[proxy_fn](name)
    if resp['comment'] == 'stopped':
        return False
    if resp['comment'] == 'running':
        return True
626966
function TryPaperErrorStatus(response) {
  MessagingServiceStatus.call(this, 'trypaper');

  this.state.message = response.message;

  if (response.status_code == 400) this.state.code = this.StatusCodes.DATA_REJECTED;
  else if (response.status_code == 500) this.state.code = this.StatusCodes.SERVICE_DOWN;
  else this.state.code = this.StatusCodes.DEFAULT;
}