<s> import abc <EOL> import pkg_resources <EOL> from six import add_metaclass <EOL> from alerta . app import app <EOL> LOG = app . logger <EOL> class RejectException ( Exception ) : <EOL> """<STR_LIT>""" <EOL> @ add_metaclass ( abc . ABCMeta ) <EOL> class PluginBase ( object ) : <EOL> @ abc . abstractmethod <EOL> def pre_receive ( self , alert ) : <EOL> """<STR_LIT>""" <EOL> return alert <EOL> @ abc . abstractmethod <EOL> def post_receive ( self , alert ) : <EOL> """<STR_LIT>""" <EOL> return None <EOL> @ abc . abstractmethod <EOL> def status_change ( self , alert , status , text ) : <EOL> """<STR_LIT>""" <EOL> return None <EOL> def load_plugins ( namespace = '<STR_LIT>' ) : <EOL> plugins = [ ] <EOL> for ep in list ( pkg_resources . iter_entry_points ( namespace ) ) : <EOL> LOG . debug ( "<STR_LIT>" , ep . name ) <EOL> try : <EOL> if ep . name in app . config [ '<STR_LIT>' ] : <EOL> plugin = ep . load ( ) <EOL> if plugin : <EOL> plugins . append ( plugin ( ) ) <EOL> LOG . info ( "<STR_LIT>" , ep . name ) <EOL> else : <EOL> LOG . debug ( "<STR_LIT>" , ep . name ) <EOL> except Exception as e : <EOL> LOG . error ( "<STR_LIT>" , ep . name , e ) <EOL> return plugins </s>
