ooiservices/app/main/c2_direct_access.py
def verify_state_and_capabilities(reference_designator, state, capabilities, expected_state, expected_capability):
    """ Verify current state and capabilities match expected state and capability. Raise if not.
    """
    NOT_NONE = 'NOT_NONE'
    try:
        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        # Verify state
        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        # If expected_state is None, raise exception
        if expected_state is None:
            message = 'Instrument (%s) not in %s, current state is %s.' % \
                              (reference_designator, expected_state, state)
            raise Exception(message)

        # If current state is not the state expected, raise exception
        if state != expected_state:
            message = 'Instrument (%s) not in %s state, current state is %s.' % \
                      (reference_designator, expected_state, state)
            raise Exception(message)

        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        # Verify capability
        # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        # If not capabilities provided in current state, raise exception
        if not capabilities:
            message = 'Instrument (%s) did not return capabilities; current state %s.' % \
                      (reference_designator, state)
            raise Exception(message)

        # If capabilities expected but unknown use NOT_NONE, there are no capabilities, raise exception
        if expected_capability == NOT_NONE:
            if not capabilities:
                message = 'Instrument (%s) does not have any capabilities; current state %s.' % \
                      (reference_designator, state)
                raise Exception(message)

        # If expected capability not provided, raise exception
        elif expected_capability not in capabilities:
            message = 'Instrument (%s) does not have %s capability; current state %s.' % \
                      (reference_designator, expected_capability, state)
            raise Exception(message)

    except Exception:
        raise
 Verify current state and capabilities match expected state and capability. Raise if not.
    
Verify current state and capabilities match expected state and capability. Raise if not.
Verify current state and capabilities match expected state and capability . Raise if not .
def verify_state_and_capabilities(reference_designator, state, capabilities, expected_state, expected_capability):
    NOT_NONE = 'NOT_NONE'
    try:
        if expected_state is None:
            message = 'Instrument (%s) not in %s, current state is %s.' % \
                              (reference_designator, expected_state, state)
            raise Exception(message)
        if state != expected_state:
            message = 'Instrument (%s) not in %s state, current state is %s.' % \
                      (reference_designator, expected_state, state)
            raise Exception(message)
        if not capabilities:
            message = 'Instrument (%s) did not return capabilities; current state %s.' % \
                      (reference_designator, state)
            raise Exception(message)
        if expected_capability == NOT_NONE:
            if not capabilities:
                message = 'Instrument (%s) does not have any capabilities; current state %s.' % \
                      (reference_designator, state)
                raise Exception(message)
        elif expected_capability not in capabilities:
            message = 'Instrument (%s) does not have %s capability; current state %s.' % \
                      (reference_designator, expected_capability, state)
            raise Exception(message)
    except Exception:
        raise
def verify_state_and_capabilities ( reference_designator , state , capabilities , expected_state , expected_capability ) : NOT_NONE = 'NOT_NONE' try : if expected_state is None : message = 'Instrument (%s) not in %s, current state is %s.' % ( reference_designator , expected_state , state ) raise Exception ( message ) if state != expected_state : message = 'Instrument (%s) not in %s state, current state is %s.' % ( reference_designator , expected_state , state ) raise Exception ( message ) if not capabilities : message = 'Instrument (%s) did not return capabilities; current state %s.' % ( reference_designator , state ) raise Exception ( message ) if expected_capability == NOT_NONE : if not capabilities : message = 'Instrument (%s) does not have any capabilities; current state %s.' % ( reference_designator , state ) raise Exception ( message ) elif expected_capability not in capabilities : message = 'Instrument (%s) does not have %s capability; current state %s.' % ( reference_designator , expected_capability , state ) raise Exception ( message ) except Exception : raise
Verify current state and capabilities match expected state and capability.
Verify current state and capabilities match expected state and capability .
""" Verify current state and capabilities match expected state and capability. Raise if not.
    """ # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Verify state # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # If expected_state is None, raise exception # If current state is not the state expected, raise exception # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # Verify capability # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # If not capabilities provided in current state, raise exception # If capabilities expected but unknown use NOT_NONE, there are no capabilities, raise exception # If expected capability not provided, raise exception
reference_designator
state
capabilities
expected_state
expected_capability