<s> import logging <EOL> logger = logging . getLogger ( __name__ ) <EOL> from nymms . schemas import types <EOL> def always_true ( result , previous_state ) : <EOL> """<STR_LIT>""" <EOL> return True <EOL> def hard_state ( result , previous_state ) : <EOL> if result . state_type == types . STATE_TYPE_HARD : <EOL> logger . debug ( "<STR_LIT>" , result . id ) <EOL> return True <EOL> return False <EOL> def changed_state ( result , previous_state ) : <EOL> """<STR_LIT>""" <EOL> if not previous_state : <EOL> logger . debug ( "<STR_LIT>" ) <EOL> return True <EOL> if not previous_state . state == result . state : <EOL> logger . debug ( "<STR_LIT>" <EOL> "<STR_LIT>" , previous_state . state . name , <EOL> result . state . name ) <EOL> return True <EOL> if not previous_state . state_type == result . state_type : <EOL> logger . debug ( "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> previous_state . state . name , <EOL> result . state_type . name ) <EOL> return True <EOL> return False <EOL> def ok_state ( result , previous_state ) : <EOL> if result . state == types . STATE_OK : <EOL> return True <EOL> return False <EOL> def warning_state ( result , previous_state ) : <EOL> if result . state == types . STATE_WARNING : <EOL> return True <EOL> return False <EOL> def critical_state ( result , previous_state ) : <EOL> if result . state == types . STATE_CRITICAL : <EOL> return True <EOL> return False <EOL> def unknown_state ( result , previous_state ) : <EOL> if result . state >= types . STATE_UNKNOWN : <EOL> return True <EOL> return False <EOL> def not_ok_state ( result , previous_state ) : <EOL> return not ( ok_state ( result , previous_state ) ) <EOL> def passive_command ( result , previous_state ) : <EOL> return result . task_context [ '<STR_LIT>' ] == '<STR_LIT>' <EOL> def active_command ( result , previous_state ) : <EOL> return not passive_command ( result , previous_state ) <EOL> def not_soft_recovery ( result , previous_state ) : <EOL> if ( previous_state and <EOL> previous_state . state_type == types . STATE_TYPE_SOFT and <EOL> result . state == types . STATE_OK ) : <EOL> return False <EOL> return True <EOL> def no_previous ( result , previous_state ) : <EOL> return not previous_state <EOL> def not_first_ok ( result , previous_state ) : <EOL> if no_previous ( result , previous_state ) and result . state == types . STATE_OK : <EOL> return False <EOL> return True </s>
